a9f5eba54d406f4c888bda465201b90ee37a3f7c
- Author
- chrisruff <chrisruff@live.ca>
- Committer
- chrisruff <chrisruff@live.ca>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index 04036c4d1247e2b68773cb8d88ff7666873d6351..0ec0452c68d463c96f818901fbb283c90b2eb260 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -896,14 +896,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 direction_char = direction == ShiftDirection::Left ? 'l'
16- : direction == ShiftDirection::Up ? 'u'
17- : direction == ShiftDirection::Down ? 'd'
18- : 'r';
19- auto next_window = g_pCompositor->getWindowInDirection(current_window, direction_char);
20+ auto next_window =
21+ g_pCompositor->getWindowInDirection(current_window, getShiftDirectionChar(direction));
22 if (next_window != nullptr) {
23 g_pCompositor->focusWindow(next_window);
24 if (warp) Hy3Layout::warpCursorToBox(next_window->m_vPosition, next_window->m_vSize);
25@@ -914,15 +913,7 @@ void Hy3Layout::shiftFocus(
26
27 auto* node = this->getWorkspaceFocusedNode(workspace);
28 if (node == nullptr) {
29- auto direction_char = direction == ShiftDirection::Left ? 'l'
30- : direction == ShiftDirection::Up ? 'u'
31- : direction == ShiftDirection::Down ? 'd'
32- : 'r';
33- auto* next_monitor = g_pCompositor->getMonitorInDirection(direction_char);
34- if (next_monitor) {
35- g_pCompositor->setActiveMonitor(next_monitor);
36- g_pCompositor->warpCursorTo(next_monitor->vecPosition + next_monitor->vecSize / 2);
37- }
38+ focusMonitor(direction);
39 return;
40 }
41
42@@ -940,6 +931,42 @@ void Hy3Layout::shiftFocus(
43 target->recalcSizePosRecursive();
44 }
45 }
46+std::optional<Hy3Node*> Hy3Layout::focusMonitor(ShiftDirection direction) {
47+ auto* next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction));
48+ if (next_monitor) {
49+ bool found = false;
50+ g_pCompositor->setActiveMonitor(next_monitor);
51+ auto next_workspace = next_monitor->activeWorkspace;
52+
53+ if (next_workspace) {
54+ auto target_window = next_workspace->getLastFocusedWindow();
55+ if (target_window) {
56+ found = true;
57+
58+ // Move the cursor to the window we selected
59+ auto found_node = getNodeFromWindow(target_window);
60+ found_node->focus(true);
61+ return found_node;
62+ }
63+ }
64+ if (!found) {
65+ g_pCompositor->warpCursorTo(next_monitor->vecPosition + next_monitor->vecSize / 2);
66+ }
67+ }
68+ return std::nullopt;
69+}
70+bool Hy3Layout::shiftMonitor(Hy3Node& node, ShiftDirection direction, bool follow) {
71+ auto* next_monitor = g_pCompositor->getMonitorInDirection(getShiftDirectionChar(direction));
72+ if (next_monitor) {
73+ g_pCompositor->setActiveMonitor(next_monitor);
74+ auto next_workspace = next_monitor->activeWorkspace;
75+ if (next_workspace) {
76+ moveNodeToWorkspace(node.workspace, next_workspace->m_szName, follow);
77+ return true;
78+ }
79+ }
80+ return false;
81+}
82
83 void Hy3Layout::warpCursor() {
84 auto current_window = g_pCompositor->m_pLastWindow.lock();
85@@ -1673,38 +1700,20 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
86 ))
87 break;
88 }
89-
90 if (break_parent->parent == nullptr) {
91- auto direction_char = direction == ShiftDirection::Left ? 'l'
92- : direction == ShiftDirection::Up ? 'u'
93- : direction == ShiftDirection::Down ? 'd'
94- : 'r';
95- auto* next_monitor = g_pCompositor->getMonitorInDirection(direction_char);
96- if (next_monitor) {
97- g_pCompositor->setActiveMonitor(next_monitor);
98- auto next_workspace = next_monitor->activeWorkspace;
99- if (next_workspace) {
100- if (shift) {
101- moveNodeToWorkspace(node.workspace, next_workspace->m_szName, true);
102- } else {
103- auto target_window = next_workspace->getLastFocusedWindow();
104-
105diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
106index e73938afbbe581c982d2edf51cab1d1866f3ad08..7b3c79ce4e9df8d503556bb66b64a68540d3d2d9 100644
107--- a/src/Hy3Layout.hpp
108+++ b/src/Hy3Layout.hpp
109@@ -10,6 +10,7 @@ enum class GroupEphemeralityOption {
110 };
111
112 #include <list>
113+#include <optional>
114 #include <set>
115
116 #include <hyprland/src/layout/IHyprLayout.hpp>
117@@ -20,6 +21,12 @@ enum class ShiftDirection {
118 Down,
119 Right,
120 };
121+inline static constexpr char getShiftDirectionChar(ShiftDirection direction) {
122+ return direction == ShiftDirection::Left ? 'l'
123+ : direction == ShiftDirection::Up ? 'u'
124+ : direction == ShiftDirection::Down ? 'd'
125+ : 'r';
126+}
127
128 enum class Axis { None, Horizontal, Vertical };
129
130@@ -113,6 +120,9 @@ public:
131 void shiftNode(Hy3Node&, ShiftDirection, bool once, bool visible);
132 void shiftWindow(const PHLWORKSPACE& workspace, ShiftDirection, bool once, bool visible);
133 void shiftFocus(const PHLWORKSPACE& workspace, ShiftDirection, bool visible, bool warp);
134+ bool shiftMonitor(Hy3Node&, ShiftDirection, bool follow);
135+ std::optional<Hy3Node*> focusMonitor(ShiftDirection);
136+
137 void warpCursor();
138 void moveNodeToWorkspace(const PHLWORKSPACE& origin, std::string wsname, bool follow);
139 void changeFocus(const PHLWORKSPACE& workspace, FocusShift);
140diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp
141index e4b59c38d94b3ca8eb63a119604feda554b44d14..122b65dc6f9eaaf848b012b72d222f6ed89704f7 100644
142--- a/src/dispatchers.cpp
143+++ b/src/dispatchers.cpp
144@@ -109,7 +109,7 @@ void dispatch_movewindow(std::string value) {
145 }
146
147 void dispatch_movefocus(std::string value) {
148- auto workspace = workspace_for_action();
149+ auto workspace = workspace_for_action(true);
150 if (!valid(workspace)) return;
151
152 auto args = CVarList(value);
153@@ -120,6 +120,10 @@ void dispatch_movefocus(std::string value) {
154 int argi = 0;
155 auto shift = parseShiftArg(args[argi++]);
156 if (!shift) return;
157+ if (workspace->m_bHasFullscreenWindow) {
158+ g_Hy3Layout->focusMonitor(shift.value());
159+ return;
160+ }
161
162 auto visible = args[argi] == "visible";
163 if (visible) argi++;