xfwm: switching to previously selected workspace

Caspar Schutijser caspar at schutijser.com
Sat May 22 14:15:52 CEST 2021


Hi,

I have a patch for xfwm4 and libxfce4ui. They add a keyboard shortcut to
switch back to the previously selected workspace (and also to move a
window to the previously selected workspace). I use both Xfce and dwm
and I'm really used to being able to use that feature in dwm. It makes
it easy to repeatedly switch back and forth between two workspaces.

Is this a feature that you're interested in? If so, I assume I'll have
to submit this patch via your gitlab instance. If this is not
the right place to ask about adding features, please point me to the
right place if possible.

The patches are included as attachments for reference. Feedback welcome,
of course.

Caspar Schutijser

-------------- next part --------------
>From 90b7065bb168cdad3c675315c1a99448e54a3464 Mon Sep 17 00:00:00 2001
From: Caspar Schutijser <caspar at schutijser.com>
Date: Sat, 22 May 2021 13:45:41 +0200
Subject: [PATCH] Add shortcuts for xfwm4 to switch to previously selected
 workplace

---
 libxfce4kbd-private/xfce-shortcuts-xfwm4.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libxfce4kbd-private/xfce-shortcuts-xfwm4.c b/libxfce4kbd-private/xfce-shortcuts-xfwm4.c
index 9caf627..a5c7b5f 100644
--- a/libxfce4kbd-private/xfce-shortcuts-xfwm4.c
+++ b/libxfce4kbd-private/xfce-shortcuts-xfwm4.c
@@ -60,6 +60,7 @@ const ShortcutTemplate xfwm4_shortcut_values[] = {
   { N_("Fill window vertically"), "fill_vert_key" },
   { N_("Toggle above"), "above_key" },
   { N_("Toggle fullscreen"), "fullscreen_key" },
+  { N_("Move window to previously selected workspace"), "move_window_prev_selected_workspace_key" },
   { N_("Move window to upper workspace"), "move_window_up_workspace_key" },
   { N_("Move window to bottom workspace"), "move_window_down_workspace_key" },
   { N_("Move window to left workspace"), "move_window_left_workspace_key" },
@@ -87,6 +88,7 @@ const ShortcutTemplate xfwm4_shortcut_values[] = {
   { N_("Tile window to the bottom-left"), "tile_down_left_key" },
   { N_("Tile window to the bottom-right"), "tile_down_right_key" },
   { N_("Show desktop"), "show_desktop_key" },
+  { N_("Previously selected workspace"), "prev_selected_workspace_key" },
   { N_("Upper workspace"), "up_workspace_key" },
   { N_("Bottom workspace"), "down_workspace_key" },
   { N_("Left workspace"), "left_workspace_key" },
-- 
2.31.1

-------------- next part --------------
>From 9fae3441ad8cad82cf7eb07b2776a87108981e9b Mon Sep 17 00:00:00 2001
From: Caspar Schutijser <caspar at schutijser.com>
Date: Sat, 22 May 2021 13:47:17 +0200
Subject: [PATCH] events: add shortcut to switch to previously selected
 workspace

Together with a shortcut to move a window to the previously selected
workspace.
---
 src/events.c   | 7 +++++++
 src/settings.c | 2 ++
 src/settings.h | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/src/events.c b/src/events.c
index 99c29212b..9f074d28d 100644
--- a/src/events.c
+++ b/src/events.c
@@ -378,6 +378,9 @@ handleKeyPress (DisplayInfo *display_info, XfwmEventKey *event)
             case KEY_TOGGLE_FULLSCREEN:
                 clientToggleFullscreen (c);
                 break;
+            case KEY_MOVE_PREV_SELECTED_WORKSPACE:
+                workspaceSwitch (screen_info, screen_info->previous_ws, c, TRUE, event->time);
+                break;
             case KEY_MOVE_NEXT_WORKSPACE:
                 workspaceSwitch (screen_info, screen_info->current_ws + 1, c, TRUE, event->time);
                 break;
@@ -488,6 +491,10 @@ handleKeyPress (DisplayInfo *display_info, XfwmEventKey *event)
         case KEY_SWITCH_APPLICATION:
             clientSwitchApp ();
             break;
+        case KEY_PREV_SELECTED_WORKSPACE:
+            status = EVENT_FILTER_REMOVE;
+            workspaceSwitch (ev_screen_info, ev_screen_info->previous_ws, NULL, TRUE, event->time);
+            break;
         case KEY_NEXT_WORKSPACE:
             status = EVENT_FILTER_REMOVE;
             workspaceSwitch (ev_screen_info, ev_screen_info->current_ws + 1, NULL, TRUE, event->time);
diff --git a/src/settings.c b/src/settings.c
index ce4a05e8a..ff910fc34 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -580,6 +580,7 @@ loadKeyBindings (ScreenInfo *screen_info)
     parseShortcut (screen_info, KEY_FILL_VERT, "fill_vert_key", shortcuts);
     parseShortcut (screen_info, KEY_FILL_WINDOW, "fill_window_key", shortcuts);
     parseShortcut (screen_info, KEY_HIDE_WINDOW, "hide_window_key", shortcuts);
+    parseShortcut (screen_info, KEY_PREV_SELECTED_WORKSPACE, "prev_selected_workspace_key", shortcuts);
     parseShortcut (screen_info, KEY_LEFT_WORKSPACE, "left_workspace_key", shortcuts);
     parseShortcut (screen_info, KEY_LOWER_WINDOW, "lower_window_key", shortcuts);
     parseShortcut (screen_info, KEY_MOVE, "move_window_key", shortcuts);
@@ -587,6 +588,7 @@ loadKeyBindings (ScreenInfo *screen_info)
     parseShortcut (screen_info, KEY_MAXIMIZE_VERT, "maximize_vert_key", shortcuts);
     parseShortcut (screen_info, KEY_MAXIMIZE_WINDOW, "maximize_window_key", shortcuts);
     parseShortcut (screen_info, KEY_MOVE_DOWN_WORKSPACE, "move_window_down_workspace_key", shortcuts);
+    parseShortcut (screen_info, KEY_MOVE_PREV_SELECTED_WORKSPACE, "move_window_prev_selected_workspace_key", shortcuts);
     parseShortcut (screen_info, KEY_MOVE_LEFT_WORKSPACE, "move_window_left_workspace_key", shortcuts);
     parseShortcut (screen_info, KEY_MOVE_NEXT_WORKSPACE, "move_window_next_workspace_key", shortcuts);
     parseShortcut (screen_info, KEY_MOVE_PREV_WORKSPACE, "move_window_prev_workspace_key", shortcuts);
diff --git a/src/settings.h b/src/settings.h
index 4293dc096..d00b088a3 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -81,6 +81,7 @@ enum
     KEY_MOVE_DOWN_WORKSPACE,
     KEY_MOVE_LEFT_WORKSPACE,
     KEY_MOVE_NEXT_WORKSPACE,
+    KEY_MOVE_PREV_SELECTED_WORKSPACE,
     KEY_MOVE_PREV_WORKSPACE,
     KEY_MOVE_RIGHT_WORKSPACE,
     KEY_MOVE_UP_WORKSPACE,
@@ -98,6 +99,7 @@ enum
     KEY_MOVE_WORKSPACE_9,
     KEY_NEXT_WORKSPACE,
     KEY_POPUP_MENU,
+    KEY_PREV_SELECTED_WORKSPACE,
     KEY_PREV_WORKSPACE,
     KEY_RAISE_WINDOW,
     KEY_RAISELOWER_WINDOW,
-- 
2.31.1



More information about the Xfce4-dev mailing list