]> git.mdlowis.com Git - proto/labwc.git/commitdiff
workspaces: Allow switching/sending to the last used workspace
authorConsus <consus@ftml.net>
Sat, 18 Jun 2022 00:09:18 +0000 (03:09 +0300)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sat, 18 Jun 2022 16:34:58 +0000 (18:34 +0200)
Actions GoToDesktop and SendToDesktop now support the new direction
called "last" that corresponds to the last used workspace (see Openbox
help[1] for reference).

[1]: http://openbox.org/wiki/Help:Actions#GoToDesktop

docs/labwc-actions.5.scd
include/labwc.h
src/workspaces.c

index 2c5c12a691774ffa627dfd78f64b9745f611900d..6d74700d25e1d1c8596f524af3ee8e62f7ffa060 100644 (file)
@@ -67,8 +67,9 @@ Actions are used in menus and keyboard/mouse bindings.
        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.
+       Switch to workspace. Supported values are "last", "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.
index 41778345bea6e2cc8ca9b3fba86ee561217b29f1..416fb03cdb2c7a495f086a17af29eb9aa8e802b7 100644 (file)
@@ -203,6 +203,7 @@ struct server {
        /* Workspaces */
        struct wl_list workspaces;  /* struct workspace.link */
        struct workspace *workspace_current;
+       struct workspace *workspace_last;
 
        struct wl_list outputs;
        struct wl_listener new_output;
index d481c63db2a0cbe76f41eab75f43b169294cb67f..1c029b8a95d9c0e54be8503018f78a366d0caf73 100644 (file)
@@ -283,6 +283,9 @@ workspaces_switch_to(struct workspace *target)
        /* Enable the new workspace */
        wlr_scene_node_set_enabled(&target->tree->node, true);
 
+       /* Save the last visited workspace */
+       target->server->workspace_last = target->server->workspace_current;
+
        /* Make sure new views will spawn on the new workspace */
        target->server->workspace_current = target;
 
@@ -342,6 +345,8 @@ workspaces_find(struct workspace *anchor, const char *name)
                                return target;
                        }
                }
+       } else if (!strcasecmp(name, "last")) {
+               return anchor->server->workspace_last;
        } else if (!strcasecmp(name, "left")) {
                return get_prev(anchor, workspaces);
        } else if (!strcasecmp(name, "right")) {