From: Dana Jansens Date: Wed, 13 Jun 2007 15:01:27 +0000 (+0000) Subject: add AddDesktopLast RemoveDesktopLast AddDesktopCurrent RemoveDesktopCurrent X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=1443e17317950d5bb096a55aca81bc8fa419ffe7;p=chaz%2Fopenbox add AddDesktopLast RemoveDesktopLast AddDesktopCurrent RemoveDesktopCurrent --- diff --git a/openbox/action.c b/openbox/action.c index 6ba52c89..52b1de3d 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -470,6 +470,16 @@ void setup_action_showmenu(ObAction **a, ObUserAction uact) } } +void setup_action_addremove_desktop_current(ObAction **a, ObUserAction uact) +{ + (*a)->data.addremovedesktop.current = TRUE; +} + +void setup_action_addremove_desktop_last(ObAction **a, ObUserAction uact) +{ + (*a)->data.addremovedesktop.current = FALSE; +} + void setup_action_focus(ObAction **a, ObUserAction uact) { (*a)->data.any.client_action = OB_CLIENT_ACTION_OPTIONAL; @@ -927,6 +937,26 @@ ActionString actionstrings[] = action_break_chroot, NULL }, + { + "adddesktoplast", + action_add_desktop, + setup_action_addremove_desktop_last + }, + { + "removedesktoplast", + action_remove_desktop, + setup_action_addremove_desktop_last + }, + { + "adddesktopcurrent", + action_add_desktop, + setup_action_addremove_desktop_current + }, + { + "removedesktopcurrent", + action_remove_desktop, + setup_action_addremove_desktop_current + }, { NULL, NULL, @@ -2003,3 +2033,37 @@ void action_break_chroot(union ActionData *data) /* break out of one chroot */ keyboard_reset_chains(1); } + +void action_add_desktop(union ActionData *data) +{ + screen_set_num_desktops(screen_num_desktops+1); + + /* move all the clients over */ + if (data->addremovedesktop.current) { + GList *it; + + for (it = client_list; it; it = g_list_next(it)) { + ObClient *c = it->data; + if (c->desktop != DESKTOP_ALL && c->desktop >= screen_desktop) + client_set_desktop(c, c->desktop+1, FALSE); + } + } +} + +void action_remove_desktop(union ActionData *data) +{ + if (screen_num_desktops < 2) return; + + /* move all the clients over */ + if (data->addremovedesktop.current) { + GList *it; + + for (it = client_list; it; it = g_list_next(it)) { + ObClient *c = it->data; + if (c->desktop != DESKTOP_ALL && c->desktop > screen_desktop) + client_set_desktop(c, c->desktop-1, FALSE); + } + } + + screen_set_num_desktops(screen_num_desktops-1); +} diff --git a/openbox/action.h b/openbox/action.h index 38452e44..17e35766 100644 --- a/openbox/action.h +++ b/openbox/action.h @@ -142,6 +142,11 @@ struct ShowMenu { gchar *name; }; +struct AddRemoveDesktop { + struct AnyAction any; + gboolean current; +}; + struct CycleWindows { struct InteractiveAction inter; gboolean linear; @@ -175,6 +180,7 @@ union ActionData { struct CycleWindows cycle; struct Layer layer; struct Stacking stacking; + struct AddRemoveDesktop addremovedesktop; }; struct _ObAction { @@ -356,5 +362,9 @@ void action_show_desktop(union ActionData *data); void action_unshow_desktop(union ActionData *data); /* Any */ void action_break_chroot(union ActionData *data); +/* AddRemoveDesktop */ +void action_add_desktop(union ActionData *data); +/* AddRemoveDesktop */ +void action_remove_desktop(union ActionData *data); #endif