Skip to content
Snippets Groups Projects
Commit 8626b8ca authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Qt: Container switch

Part of #4
parent 98e53d39
Branches
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ On middle-click on a container, floating will be toggled. ...@@ -54,6 +54,7 @@ On middle-click on a container, floating will be toggled.
You can use drag-and-drop for windows/containers or whole workspaces. You can use drag-and-drop for windows/containers or whole workspaces.
Using left button only members of container will be taken. Using left button only members of container will be taken.
Using middle button containers will be swapped.
You can search for a window by its name by typing the query to the relevant You can search for a window by its name by typing the query to the relevant
input field (labeled find). input field (labeled find).
...@@ -98,6 +99,7 @@ m<id><id><key> - Move window/container/workspace near other container ...@@ -98,6 +99,7 @@ m<id><id><key> - Move window/container/workspace near other container
m - expand in front of m - expand in front of
j/b/y/d - expand to new horizontal/vertical/tabbed/stacked layout j/b/y/d - expand to new horizontal/vertical/tabbed/stacked layout
J/B/Y/D - expand to new layout before the target container J/B/Y/D - expand to new layout before the target container
c - change (swap) workspaces
(the second part is the same moved one key right) (the second part is the same moved one key right)
c<id>... - select container/window/workspace and ... c<id>... - select container/window/workspace and ...
m<workspace> - move to workspace m<workspace> - move to workspace
......
...@@ -171,9 +171,13 @@ def qt_main(): ...@@ -171,9 +171,13 @@ def qt_main():
shared.i3_cmd(f'[con_id={target.container_id}] mark tmp') shared.i3_cmd(f'[con_id={target.container_id}] mark tmp')
shared.i3_cmd(f'[con_id={self.container_id}] move container to mark tmp') shared.i3_cmd(f'[con_id={self.container_id}] move container to mark tmp')
def move(self, target, before=False, expand=False, new_container=None): def move(self, target, swap=False, before=False, expand=False, new_container=None):
self.workspace_widget.screenshot_changed() self.workspace_widget.screenshot_changed()
target.workspace_widget.screenshot_changed() target.workspace_widget.screenshot_changed()
if swap:
shared.i3_cmd(f'[con_id={self.container_id}] mark tmp')
shared.i3_cmd(f'[con_id={target.container_id}] swap container with mark tmp')
else:
if new_container is not None: if new_container is not None:
target.put_in_new_container(None if new_container is True else new_container) target.put_in_new_container(None if new_container is True else new_container)
if expand and type(self) != I3InnerNodeWidget: if expand and type(self) != I3InnerNodeWidget:
...@@ -276,6 +280,9 @@ def qt_main(): ...@@ -276,6 +280,9 @@ def qt_main():
m_win.cmd_msg_clean() m_win.cmd_msg_clean()
button = s.press_event_buttons button = s.press_event_buttons
try: try:
if button == Qt.MiddleButton:
s.move(self, swap=True)
else:
s.move(self, s.move(self,
expand=s.press_event_buttons == Qt.RightButton, expand=s.press_event_buttons == Qt.RightButton,
**[{"before":True}, {"new_container": True}, {}][self.drop_place] **[{"before":True}, {"new_container": True}, {}][self.drop_place]
...@@ -311,6 +318,10 @@ def qt_main(): ...@@ -311,6 +318,10 @@ def qt_main():
self.drop_place = 1 self.drop_place = 1
s = event.source() s = event.source()
if s is not None and isinstance(s, WorkspaceWidget) or isinstance(s, I3NodeWidget): if s is not None and isinstance(s, WorkspaceWidget) or isinstance(s, I3NodeWidget):
button = s.press_event_buttons
if button == Qt.MiddleButton:
style = "background-color: green;"
else:
style = ["border-top: 3px solid green;", "background-color: green;", "border:no; border-bottom: 3px solid green;"][self.drop_place] style = ["border-top: 3px solid green;", "background-color: green;", "border:no; border-bottom: 3px solid green;"][self.drop_place]
self.setStyleSheet(f"#{id(self)} {{ {style} }}"); self.setStyleSheet(f"#{id(self)} {{ {style} }}");
...@@ -632,11 +643,11 @@ def qt_main(): ...@@ -632,11 +643,11 @@ def qt_main():
def move_to_otput(self, output="next"): def move_to_otput(self, output="next"):
shared.i3_cmd(f"move workspace to output {output}") shared.i3_cmd(f"move workspace to output {output}")
def move(self, target, before=False, expand=False, new_container=None): def move(self, target, swap=False, before=False, expand=False, new_container=None):
for f in self._tree.floating_nodes: for f in self._tree.floating_nodes:
f.move_to_workspace(target.workspace_widget.master, target.workspace_widget.slave) f.move_to_workspace(target.workspace_widget.master, target.workspace_widget.slave)
if (w := self.root_i3_tree_widget()) is not None: if (w := self.root_i3_tree_widget()) is not None:
w.move(target, before=before, expand=expand, new_container=new_container) w.move(target, swap=swap, before=before, expand=expand, new_container=new_container)
def move_to_workspace(self, master, slave, expand=False): def move_to_workspace(self, master, slave, expand=False):
for f in self._tree.floating_nodes: for f in self._tree.floating_nodes:
...@@ -1094,6 +1105,8 @@ def qt_main(): ...@@ -1094,6 +1105,8 @@ def qt_main():
nd_from.move(nd_to, new_container="tabbed", before=mod==SHIFT, expand=True) nd_from.move(nd_to, new_container="tabbed", before=mod==SHIFT, expand=True)
elif mod in [0, SHIFT] and key == ord('D'): elif mod in [0, SHIFT] and key == ord('D'):
nd_from.move(nd_to, new_container="stacked", before=mod==SHIFT, expand=True) nd_from.move(nd_to, new_container="stacked", before=mod==SHIFT, expand=True)
elif mod in [0] and key == ord('C'):
nd_from.move(nd_to, swap=True)
else: else:
raise NoSutchKey(key, mod) raise NoSutchKey(key, mod)
self.load_i3_tree() self.load_i3_tree()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment