From ee26f7f3df7d8bf93f10e5923ce418fed1f67782 Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Sun, 28 Aug 2022 22:28:09 +0200
Subject: [PATCH] Qt: Swap and move workspace by keyboard

---
 woman/help.py |  3 +++
 woman/qt.py   | 13 +++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/woman/help.py b/woman/help.py
index b511c6b..8de8e1f 100644
--- a/woman/help.py
+++ b/woman/help.py
@@ -112,6 +112,9 @@ c<id>...          - select container/window/workspace and ...
     qy            - quit window or all windows in container/workspace
     kY            - xkill window or all windows in container/workspace
     e             - expand container to parent container
+s<id/workspace>   - swap current workspace with window/container/workspace
+d<workspace>      - move current workspace to workspace
+d<id><key>        - move current workspace near to container (see `m`)
 
 
 Shortcuts in search bar (input mode):
diff --git a/woman/qt.py b/woman/qt.py
index cd3bcb4..fae2974 100755
--- a/woman/qt.py
+++ b/woman/qt.py
@@ -1266,6 +1266,19 @@ def qt_main():
                                 raise NoSutchKey(key, mod)
                         else:
                             raise NoSutchKey(key, mod)
+                elif mod == 0 and key == ord('S'):
+                    nd_from = self.focused_widget
+                    with nd_from.marked_context(QColor(255, 0, 0)):
+                        nd_to = await get_container_or_workspace()
+                        if isinstance(nd_to, WorkspaceWidget):
+                            nd_to.swap_with_workspace(nd_from.master, nd_from.slave)
+                        else:
+                            nd_from.move(nd_to, swap=True)
+                    self.load_i3_tree()
+                elif mod == 0 and key == ord('D'):
+                    nd_from = self.focused_widget
+                    with nd_from.marked_context(QColor(255, 0, 0)):
+                        await ck_move(nd_from)
                 elif mod == 0 and key == ord('R'):  # Undocumented
                     for i in self._workspaces.values():
                         i.metadata_changed()
-- 
GitLab