diff --git a/docs/labwc-actions.5.scd b/docs/labwc-actions.5.scd index 9a7c1349..2c5c12a6 100644 --- a/docs/labwc-actions.5.scd +++ b/docs/labwc-actions.5.scd @@ -66,6 +66,14 @@ Actions are used in menus and keyboard/mouse bindings. ** Toggle always-on-top of focused window. +** + 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. + +** + Send active window to workspace. + Supported values are the same as for GoToDesktop. + # SEE ALSO labwc(1), labwc-config(5), labwc-theme(5) diff --git a/src/action.c b/src/action.c index d9f22eb1..c2a0566c 100644 --- a/src/action.c +++ b/src/action.c @@ -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", diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 31a7c138..19bd2133 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -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); } } diff --git a/src/menu/menu.c b/src/menu/menu.c index 403cfe7c..1ccf0c49 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -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); } }