b341fe60a75eae94a2ee612387dafd280ed62208

Author
outfoxxed <outfoxxed@outfoxxed.me>
Committer
outfoxxed <outfoxxed@outfoxxed.me>
Date

Message

Fix crash when moving focus of a node containing multiple windows

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 7182bd8f4a44ea9f92ff3de9fe5a4a208bdd96c8..9cd184e36693dd38820df9a8200a36f3c4be0ca7 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -938,20 +938,23 @@ void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once,
 6 
 7 void Hy3Layout::shiftFocus(int workspace, ShiftDirection direction, bool visible) {
 8 	auto* current_window = g_pCompositor->m_pLastWindow;
 9-	auto* p_workspace = g_pCompositor->getWorkspaceByID(current_window->m_iWorkspaceID);
10-	if (p_workspace->m_bHasFullscreenWindow) return;
11-
12-	if (current_window != nullptr && current_window->m_bIsFloating) {
13-		auto* next_window = g_pCompositor->getWindowInDirection(
14-		    current_window,
15-		    direction == ShiftDirection::Left   ? 'l'
16-		    : direction == ShiftDirection::Up   ? 'u'
17-		    : direction == ShiftDirection::Down ? 'd'
18-		                                        : 'r'
19-		);
20 
21-		if (next_window != nullptr) g_pCompositor->focusWindow(next_window);
22-		return;
23+	if (current_window != nullptr) {
24+		auto* p_workspace = g_pCompositor->getWorkspaceByID(current_window->m_iWorkspaceID);
25+		if (p_workspace->m_bHasFullscreenWindow) return;
26+
27+		if (current_window->m_bIsFloating) {
28+			auto* next_window = g_pCompositor->getWindowInDirection(
29+			    current_window,
30+			    direction == ShiftDirection::Left   ? 'l'
31+			    : direction == ShiftDirection::Up   ? 'u'
32+			    : direction == ShiftDirection::Down ? 'd'
33+			                                        : 'r'
34+			);
35+
36+			if (next_window != nullptr) g_pCompositor->focusWindow(next_window);
37+			return;
38+		}
39 	}
40 
41 	auto* node = this->getWorkspaceFocusedNode(workspace);