]> git.mdlowis.com Git - proto/labwc.git/commitdiff
workspaces: Add workspace actions
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 14 Jun 2022 23:38:22 +0000 (01:38 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 15 Jun 2022 20:26:21 +0000 (22:26 +0200)
docs/labwc-actions.5.scd
src/action.c
src/config/rcxml.c
src/menu/menu.c

index 9a7c13499b2a02654c8e1afdc9772163839b8c95..2c5c12a691774ffa627dfd78f64b9745f611900d 100644 (file)
@@ -66,6 +66,14 @@ Actions are used in menus and keyboard/mouse bindings.
 *<action name="ToggleAlwaysOnTop">*
        Toggle always-on-top of focused window.
 
+*<action name="GoToDesktop"><to>*
+       Switch to workspace. Supported values are "left", "right" or the full
+       name of a workspace or its index (starting at 1) as configured in rc.xml.
+
+*<action name="SendToDesktop"><to>*
+       Send active window to workspace.
+       Supported values are the same as for GoToDesktop.
+
 # SEE ALSO
 
 labwc(1), labwc-config(5), labwc-theme(5)
index d9f22eb1b2eec341199bf1513b01996d1c282683..c2a0566c5dc963edf54bd14b10c7ce2a7d5280d8 100644 (file)
@@ -9,6 +9,7 @@
 #include "menu/menu.h"
 #include "ssd.h"
 #include "action.h"
+#include "workspaces.h"
 
 enum action_type {
        ACTION_TYPE_NONE = 0,
@@ -31,6 +32,8 @@ enum action_type {
        ACTION_TYPE_MOVE,
        ACTION_TYPE_RAISE,
        ACTION_TYPE_RESIZE,
+       ACTION_TYPE_GO_TO_DESKTOP,
+       ACTION_TYPE_SEND_TO_DESKTOP,
 };
 
 const char *action_names[] = {
@@ -54,6 +57,8 @@ const char *action_names[] = {
        "Move",
        "Raise",
        "Resize",
+       "GoToDesktop",
+       "SendToDesktop",
        NULL
 };
 
@@ -255,6 +260,24 @@ actions_run(struct view *activator, struct server *server,
                                        resize_edges);
                        }
                        break;
+               case ACTION_TYPE_GO_TO_DESKTOP:
+                       {
+                               struct workspace *target;
+                               target = workspaces_find(server->workspace_current, action->arg);
+                               if (target) {
+                                       workspaces_switch_to(target);
+                               }
+                       }
+                       break;
+               case ACTION_TYPE_SEND_TO_DESKTOP:
+                       if (view) {
+                               struct workspace *target;
+                               target = workspaces_find(view->workspace, action->arg);
+                               if (target) {
+                                       workspaces_send_to(view, target);
+                               }
+                       }
+                       break;
                case ACTION_TYPE_NONE:
                        wlr_log(WLR_ERROR,
                                "Not executing unknown action with arg %s",
index 31a7c1384e619e9fc30146b55f1489ce2494d9e1..19bd2133f16207883900bf07905a4fe0c07f7cc7 100644 (file)
@@ -75,10 +75,16 @@ fill_keybind(char *nodename, char *content)
                wlr_log(WLR_ERROR, "Action argument already set: %s",
                        current_keybind_action->arg);
        } else if (!strcmp(nodename, "command.action")) {
+               /* Execute */
                current_keybind_action->arg = strdup(content);
        } else if (!strcmp(nodename, "direction.action")) {
+               /* MoveToEdge, SnapToEdge */
                current_keybind_action->arg = strdup(content);
        } else if (!strcmp(nodename, "menu.action")) {
+               /* ShowMenu */
+               current_keybind_action->arg = strdup(content);
+       } else if (!strcmp(nodename, "to.action")) {
+               /* GoToDesktop, SendToDesktop */
                current_keybind_action->arg = strdup(content);
        }
 }
index 403cfe7c6939e22f6ea0011c0be05c353e3f0e34..1ccf0c495f875df2b59e3ea484c6d56d7941b702 100644 (file)
@@ -203,6 +203,8 @@ fill_item(char *nodename, char *content)
                 * compatibility with old openbox-menu generators
                 */
                current_item_action->arg = strdup(content);
+       } else if (!strcmp(nodename, "to.action")) {
+               current_item_action->arg = strdup(content);
        }
 }