From fd29ce1756761ddbcdb971e2132825103cbaea3a Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Sat, 27 Aug 2022 22:25:32 +0200
Subject: [PATCH] Qt: Container expansion

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

diff --git a/woman/help.py b/woman/help.py
index 91ce06f..b52b05b 100644
--- a/woman/help.py
+++ b/woman/help.py
@@ -111,6 +111,7 @@ c<id>...          - select container/window/workspace and ...
     a             - set workspace as active
     qy            - quit window or all windows in container/workspace
     kY            - xkill window or all windows in container/workspace
+    e             - expand container to parent container
 
 
 Shortcuts in search bar (input mode):
diff --git a/woman/qt.py b/woman/qt.py
index bcaca54..0e63b29 100755
--- a/woman/qt.py
+++ b/woman/qt.py
@@ -420,6 +420,18 @@ def qt_main():
             for i in self.nodes:
                 i.quit_windows(*arg, **kvarg)
 
+        def expand(self):
+            if isinstance(self.parentWidget(), I3InnerNodeWidget):
+                self.workspace_widget.screenshot_changed()
+                tmp_win = TmpWin()
+                shared.i3_cmd(f'[con_id={self.container_id}] swap container with id {tmp_win.id}')
+                marks = []
+                for (i, it) in enumerate(self.nodes):
+                    shared.i3_cmd(f'[con_id={it.container_id}] mark tmp_from_{i}')
+                    marks.append(f"tmp_from_{i}")
+                shared.i3_cmd(f'[id={tmp_win.id}] mark tmp')
+                shared.i3_cmd(f'[con_mark="{"|".join(marks)}"] move container to mark tmp')
+
 
         def redraw(self):
             p = QPalette()
@@ -1170,6 +1182,9 @@ def qt_main():
                             nd.change_layout("tabbed")
                         elif type(nd) == I3InnerNodeWidget and mod == 0 and key == ord('S'):
                             nd.change_layout("stacked")
+                        elif type(nd) == I3InnerNodeWidget and mod == 0 and key == ord('E'):
+                            nd.expand()
+                            self.load_i3_tree()
                         elif type(nd) == I3InnerNodeWidget and mod == 0 and key == ord('F'):
                             nd.focus()
                         elif mod == 0 and key == ord('A'):
-- 
GitLab