61bad2aa106fb3b5b77ed411c8f489c3220a32a7
- Author
- outfoxxed <outfoxxed@outfoxxed.me>
- Committer
- outfoxxed <outfoxxed@outfoxxed.me>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index 459f64248a51dc83f3d8f23bd30c4469b2fe4a30..8fadaac89474525da866b6237329fab8da4fc4e1 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -913,16 +913,13 @@ void Hy3Layout::shiftFocus(
6 auto current_window = g_pCompositor->m_pLastWindow.lock();
7
8 if (current_window != nullptr) {
9- if (current_window->m_pWorkspace->m_bHasFullscreenWindow) return;
10+ if (current_window->m_pWorkspace->m_bHasFullscreenWindow) {
11+ return;
12+ }
13
14 if (current_window->m_bIsFloating) {
15- auto next_window = g_pCompositor->getWindowInDirection(
16- current_window,
17- direction == ShiftDirection::Left ? 'l'
18- : direction == ShiftDirection::Up ? 'u'
19- : direction == ShiftDirection::Down ? 'd'
20- : 'r'
21- );
22+ auto next_window =
23+ g_pCompositor->getWindowInDirection(current_window, getShiftDirectionChar(direction));
24
25 if (next_window != nullptr) {
26 g_pCompositor->focusWindow(next_window);
27@@ -933,7 +930,10 @@ void Hy3Layout::shiftFocus(
28 }
29
30 auto* node = this->getWorkspaceFocusedNode(workspace);
31- if (node == nullptr) return;
32+ if (node == nullptr) {
33+ focusMonitor(direction);
34+ return;
35+ }
36
37 auto* target = this->shiftOrGetFocus(*node, direction, false, false, visible);
38
39@@ -950,6 +950,48 @@ void Hy3Layout::shiftFocus(
40 }
41 }
42
43+Hy3Node* Hy3Layout::focusMonitor(ShiftDirection direction) {
44+ auto next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction));
45+
46+ if (next_monitor) {
47+ bool found = false;
48+ g_pCompositor->setActiveMonitor(next_monitor);
49+ auto next_workspace = next_monitor->activeWorkspace;
50+
51+ if (next_workspace) {
52+ auto target_window = next_workspace->getLastFocusedWindow();
53+ if (target_window) {
54+ found = true;
55+
56+ // Move the cursor to the window we selected
57+ auto found_node = getNodeFromWindow(target_window);
58+ if (found_node) {
59+ found_node->focus(true);
60+ return found_node;
61+ }
62+ }
63+ }
64+ if (!found) {
65+ g_pCompositor->warpCursorTo(next_monitor->vecPosition + next_monitor->vecSize / 2);
66+ }
67+ }
68+ return nullptr;
69+}
70+
71+bool Hy3Layout::shiftMonitor(Hy3Node& node, ShiftDirection direction, bool follow) {
72+ auto next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction));
73+
74+ if (next_monitor) {
75+ g_pCompositor->setActiveMonitor(next_monitor);
76+ auto next_workspace = next_monitor->activeWorkspace;
77+ if (next_workspace) {
78+ moveNodeToWorkspace(node.workspace, next_workspace->m_szName, follow);
79+ return true;
80+ }
81+ }
82+ return false;
83+}
84+
85 void Hy3Layout::toggleFocusLayer(const PHLWORKSPACE& workspace, bool warp) {
86 auto current_window = g_pCompositor->m_pLastWindow.lock();
87 if (!current_window) return;
88@@ -1674,14 +1716,14 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
89 ))
90 break;
91 }
92-
93 if (break_parent->parent == nullptr) {
94- if (!shift) return nullptr;
95+ if (!shift) return focusMonitor(direction);
96
97 // if we haven't gone up any levels and the group is in the same direction
98 // there's no reason to wrap the root group.
99- if (group.layout != Hy3GroupLayout::Tabbed && shiftMatchesLayout(group.layout, direction))
100+ if (group.layout != Hy3GroupLayout::Tabbed && shiftMatchesLayout(group.layout, direction)) {
101 break;
102+ }
103
104 if (group.layout != Hy3GroupLayout::Tabbed && group.children.size() == 2
105diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
106index af57092e1f8990b8d64cd3fb7219745fa4aea0ac..39aa8338fbff2f4c726c55bda99e8255fcd5ebb9 100644
107--- a/src/Hy3Layout.hpp
108+++ b/src/Hy3Layout.hpp
109@@ -20,6 +20,12 @@ enum class ShiftDirection {
110 Down,
111 Right,
112 };
113+inline static constexpr char getShiftDirectionChar(ShiftDirection direction) {
114+ return direction == ShiftDirection::Left ? 'l'
115+ : direction == ShiftDirection::Up ? 'u'
116+ : direction == ShiftDirection::Down ? 'd'
117+ : 'r';
118+}
119
120 enum class Axis { None, Horizontal, Vertical };
121
122@@ -114,6 +120,9 @@ public:
123 void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible);
124 void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp);
125 void toggleFocusLayer(const PHLWORKSPACE& workspace, bool warp);
126+ bool shiftMonitor(Hy3Node&, ShiftDirection, bool follow);
127+ Hy3Node* focusMonitor(ShiftDirection);
128+
129 void warpCursor();
130 void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow);
131 void changeFocus(const PHLWORKSPACE& workspace, FocusShift);
132diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp
133index 27ab212bf6334614259bb9fd40903647b2a51abe..6eab8888884e0a807a5390781fef84a3da3e1305 100644
134--- a/src/dispatchers.cpp
135+++ b/src/dispatchers.cpp
136@@ -110,7 +110,7 @@ void dispatch_movewindow(std::string value) {
137 }
138
139 void dispatch_movefocus(std::string value) {
140- auto workspace = workspace_for_action();
141+ auto workspace = workspace_for_action(true);
142 if (!valid(workspace)) return;
143
144 auto args = CVarList(value);
145@@ -121,6 +121,10 @@ void dispatch_movefocus(std::string value) {
146 int argi = 0;
147 auto shift = parseShiftArg(args[argi++]);
148 if (!shift) return;
149+ if (workspace->m_bHasFullscreenWindow) {
150+ g_Hy3Layout->focusMonitor(shift.value());
151+ return;
152+ }
153
154 auto visible = args[argi] == "visible";
155 if (visible) argi++;