5e9852cfcc9de3645ce0beff62b8aebbfcb64f28

Author
chrisruff <chrisruff@live.ca>
Committer
chrisruff <chrisruff@live.ca>
Date

Message

Got nodes moving correctly, and being focused correctly

Some minor bugs, mainly fullscreen or empty workspaces do not work
properly.

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index b05a5d69601332894a002c213d755a701cc952d6..729bc7dcd880a7d72092ae4d6d012f188e1b3918 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -1667,7 +1667,31 @@ Hy3Node* Hy3Layout::shiftOrGetFocus(
 6 		}
 7 
 8 		if (break_parent->parent == nullptr) {
 9-			if (!shift) return nullptr;
10+			auto direction_char = direction == ShiftDirection::Left ? 'l'
11+			                    : direction == ShiftDirection::Up   ? 'u'
12+			                    : direction == ShiftDirection::Down ? 'd'
13+			                                                        : 'r';
14+			auto* next_monitor = g_pCompositor->getMonitorInDirection(direction_char);
15+			if (next_monitor) {
16+				g_pCompositor->setActiveMonitor(next_monitor);
17+				auto next_workspace = next_monitor->activeWorkspace;
18+				if (next_workspace) {
19+					if (shift) {
20+						moveNodeToWorkspace(node.workspace, next_workspace->m_szName, true);
21+					} else {
22+						auto target_window = next_workspace->getLastFocusedWindow();
23+
24+						if (target_window) {
25+							// Move the cursor to the window we selected
26+							g_pCompositor->warpCursorTo(target_window->m_vPosition + target_window->m_vSize / 2);
27+							return getNodeFromWindow(target_window);
28+						}
29+					}
30+				}
31+				// If window wasnt found, then select middle of the monitor
32+				g_pCompositor->warpCursorTo(next_monitor->vecPosition + next_monitor->vecSize / 2);
33+				return nullptr;
34+			}
35 
36 			// if we haven't gone up any levels and the group is in the same direction
37 			// there's no reason to wrap the root group.