From 3f67982948ab73e4e9be53b84af14ac7de9be228 Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Fri, 26 Aug 2022 23:03:58 +0200
Subject: [PATCH] QT: Move workspace to output

Closes #2
---
 woman/help.py |  2 ++
 woman/qt.py   | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/woman/help.py b/woman/help.py
index 5929019..b561e00 100644
--- a/woman/help.py
+++ b/woman/help.py
@@ -47,6 +47,7 @@ Window information (I3 container tree) is loaded on each jump to GUI (by `i3-wom
 or on key `T` press.
 
 When you click on a workspace, you will be moved to it.
+On right-click on a workspaces, workspaces will be moved to next output.
 When you click on a container or a window, it will be focused.
 On left-click on a container, layout will be changed.
 On middle-click on a container, floating will be toggled.
@@ -81,6 +82,7 @@ Shift + <RIGHT> / <LEFT>
 or L / H         - Focus next / previous slave will be active
 <ENTER>          - Go to the active workspace
 <ESC>            - Go to the previous used workspace
+o                - Move workspace to next output
 w / e            - Increase / decrease screenshot size
 `, 1-9, 0, -, =  - Active the corresponding slave
 F1-F12           - Active the corresponding master
diff --git a/woman/qt.py b/woman/qt.py
index e36f521..1bca128 100755
--- a/woman/qt.py
+++ b/woman/qt.py
@@ -629,6 +629,9 @@ def qt_main():
         def focus(self):
             shared.i3_cmd(f'workspace {workspace(self.master, self.slave)}')
 
+        def move_to_otput(self, output="next"):
+            shared.i3_cmd(f"move workspace to output {output}")
+
         def move(self, target, before=False, expand=False, new_container=None):
             for f in self._tree.floating_nodes:
                 f.move_to_workspace(target.workspace_widget.master, target.workspace_widget.slave)
@@ -648,7 +651,14 @@ def qt_main():
                 self._tree.root_node.quit_windows(*arg, **kvarg)
 
         def clicked(self, pos, buttons):
-            self.focus()
+            if buttons == Qt.RightButton:
+                try:
+                    self.move_to_otput()
+                except I3CmdException as e:
+                    m_win.cmd_msg(e.error, QColor(255, 100, 100))
+                    traceback.print_exc()
+            else:
+                self.focus()
 
         def root_i3_tree_widget(self):
             r = self._tree.root_node
@@ -1150,6 +1160,8 @@ def qt_main():
                 elif mod == 0 and key == ord('T'):
                     m_win.end_get_continuing_key()
                     self.load_i3_tree()
+                elif mod == 0 and key == ord('O'):
+                    self.focused_widget.move_to_otput()
                 elif mod == 0 and key == ord('W'):
                     try:
                         self.set_screenshot_size([x for x in SCREENSHOTS_SIZES if x > self.screenshot_size][0])
-- 
GitLab