Bug 5974 - Create shortcut action for add desktop to position
Status: ASSIGNED
Alias: None
Product: Openbox
Classification: Unclassified
Component: general
Version: 3.5.0
Hardware: All Linux
: P3 enhancement
Assignee: Dana Jansens
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2013-06-20 14:40 EDT by Jamie Macdonald
Modified: 2013-08-24 07:47:06 EDT
1 user (show)

See Also:


Attachments
Patch to add/remove desktops at given indices (7.48 KB, patch)
2013-06-21 03:12 EDT, Jamie Macdonald
Patch to add/remove desktops at given indices (8.88 KB, patch)
2013-07-12 19:17 EDT, Jamie Macdonald

Description Jamie Macdonald 2013-06-20 14:40:25 EDT
Currently the only actions for adding (resp. removing) desktops are to (resp. from) the "current" desktop or the "last" desktop. 

I would like to see an action for adding (resp. removing) desktops to (resp. from) a certain index.

e.g.
<keybind key="W-F1">
  <action name="AddDesktop">
     <where>1</where>
  </action>
</keybind>

would insert a new desktop at the front of the current desktops and would become the desktop with index 1, shifting all other desktop indices up by one.

and 
<keybind key="W-F3">
  <action name="RemoveDesktop">
     <where>3</where>
  </action>
</keybind>

would remove the desktop with index 3, and moving all windows from there to an adjacent desktop.
Comment 1 Jamie Macdonald 2013-06-21 03:12:12 EDT
Created attachment 3360 [details]
Patch to add/remove desktops at given indices

Please review this patch for merging. I have changed the API for functions screen_remove_desktop() and screen_add_desktop() to support this functionality (see commit message).

COMMIT_EDITMSG:
"""
Add functionality to add/remove workspaces at given indices.
Example usage in rc.xml:
...
    <keybind key="C-4">
      <action name="AddDesktop">
        <where>4</where>
      </action>
    </keybind>
...
will add a desktop in position 4 (one-indexed), shifting windows from 
higher desktop indices up one desktop. If there are less than 3 
desktops currently, the in between desktops will also be created.
...
    <keybind key="C-S-3">
      <action name="RemoveDesktop">
        <where>3</where>
      </action>
    </keybind>
...
will remove desktop at position 3 (one-indexed), moving its windows to 
desktop 4. If there are exactly 3 desktops, the windows are moved to 
desktop 2. If there are less than 3 desktops, nothing happens.

API changes:
screen.c:
screen_add_desktop(gboolean current); // is now
screen_add_desktop(guint index);

screen_remove_desktop(gboolean current); // is now
screen_remove_desktop(guint index);

This should be fully backwards compatible with previous scheme due to the 
changes made to openbox/actions/addremovedesktop.c
"""
Comment 2 Jamie Macdonald 2013-06-23 23:01:54 EDT
Remove desktop functionality. I also would be motivated to code a more general solution for workspace management than this. I plan on posting to the mailing list asking for input.
Comment 3 loredan 2013-07-06 16:25:43 EDT
The general workspace management idea sounds great. I am pretty sure that the added functionality of being able to add/remove desktops by index will also help a lot. 
This still leaves room for adding a basic system tray and/or window/task manager though. The standard version that installs with both the older 2.6 kernels and the current 3.x ones doesn't have any of this stuff which should be pretty basic for a desktop environment these days.
Comment 4 Jamie Macdonald 2013-07-12 19:17:35 EDT
Created attachment 3365 [details]
Patch to add/remove desktops at given indices

Working patch, requires testing. See commit log for functionality specification.
Comment 5 loredan 2013-07-13 06:40:42 EDT
I can test the patch
Comment 6 Jamie Macdonald 2013-07-13 09:39:26 EDT
(In reply to comment #5)
> I can test the patch

Sweet, if you don't know what to do:
download the patch (add_remove_desktop_indices.patch)

#apply the patch against latest release
git clone git://git.openbox.org/dana/openbox openbox
cd openbox
git checkout release-3.5.0
git am ~/Downloads/add_remove_desktop_indices.patch

#build & install
./bootstrap
./configure
make
sudo make install

#Edit ~/.config/openbox/rc.xml to add some bindings to test out e.g.
    <keybind key="C-3">
      <action name="AddDesktop">
        <where>3</where>
      </action>
    </keybind>

    <keybind key="C-S-1">
      <action name="RemoveDesktop">
        <where>1</where>
      </action>
    </keybind>

#Then openbox restart might do the trick
openbox --restart
#or restart your login manager

And confirm these cases:
(1) <where>first</where>, <where>current</where>, <where>last</where> work as expected (as before) 

(2)
    <keybind key="C-3">
      <action name="AddDesktop">
        <where>5</where>
      </action>
    </keybind>
when there are 3 or less desktops results in new empty desktops in positions 4 and 5

(3)
    <keybind key="C-3">
      <action name="AddDesktop">
        <where>3</where>
      </action>
    </keybind>
when there are 5 desktops results in a new empty desktop at position 3, with windows relocated from previous desktops 3,4,5 to current desktops 4,5,6

(4)
    <keybind key="C-3">
      <action name="RemoveDesktop">
        <where>3</where>
      </action>
    </keybind>
removes one desktop from the lineup, merging 4 into 3, relocating 5->4, 6->5 etc.

(4.5)
if you are on the desktop you remove, the windows merging from the other desktop should go under your current windows

(5)
    <keybind key="C-3">
      <action name="RemoveDesktop">
        <where>5</where>
      </action>
    </keybind>
when there are 4 or less desktops does nothing
Comment 7 Jamie Macdonald 2013-08-15 16:49:05 EDT
See pull request at github: https://github.com/danakj/openbox/pull/3
Comment 8 Dana Jansens 2013-08-15 20:52:36 EDT
Not sure why resolved, see no comment saying anything.
Comment 9 Jamie Macdonald 2013-08-15 22:31:46 EDT
I'm just getting tired of Bugzilla reminding me that it's open when I finished this patch a month ago.

I thought "Resolved - Works for me" was appropriate until it passed whatever screening to get into master. Or is that status reserved for something else?

In any case, I've been using this for a month and everything works as far as I've described with no regressions.
Comment 10 Dana Jansens 2013-08-15 22:38:15 EDT
(In reply to comment #9)
> I'm just getting tired of Bugzilla reminding me that it's open when I
> finished this patch a month ago.

Hm, I don't get those, maybe you can turn them off :)

> I thought "Resolved - Works for me" was appropriate until it passed whatever
> screening to get into master. Or is that status reserved for something else?
> 
> In any case, I've been using this for a month and everything works as far as
> I've described with no regressions.

Resolved => No more work to be done for the bug. So, we can close this when the patch is merged.
Comment 11 Mikachu 2013-08-16 06:33:20 EDT
that would probably be because it was set as assigned to you.
Comment 12 Dana Jansens 2013-08-16 12:40:40 EDT
Not sure why not keep it assigned to jamie as they are working on the CL.
Comment 13 loredan 2013-08-22 07:00:01 EDT
Hey Jamie sorry I didn't get around to testing the patch yet. I couldn't clone the repository on my system (do I need the entire gcc toolchain to use git?) 

Anyway though, if you just send me a source tarball then I can compile and test it on my system

Cheers