7f1989689df71da8e2081dc24453ccd41341bf50

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

Message

Fix starting with a horizontal layout on vertical monitors

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 09ba804626a9ac99dbeba552736995405e3d1f36..1a8948e51d2052cad28b81b6bc5ac2354055f0ce 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -156,8 +156,10 @@ void Hy3Layout::insertNode(Hy3Node& node) {
 6 		{
 7 			opening_after = this->getNodeFromWindow(g_pCompositor->m_pLastWindow);
 8 		} else {
 9-			auto* mouse_window =
10-			    g_pCompositor->vectorToWindowUnified(g_pInputManager->getMouseCoordsInternal(), RESERVED_EXTENTS | INPUT_EXTENTS);
11+			auto* mouse_window = g_pCompositor->vectorToWindowUnified(
12+			    g_pInputManager->getMouseCoordsInternal(),
13+			    RESERVED_EXTENTS | INPUT_EXTENTS
14+			);
15 
16 			if (mouse_window != nullptr && mouse_window->m_iWorkspaceID == node.workspace_id) {
17 				opening_after = this->getNodeFromWindow(mouse_window);
18@@ -180,8 +182,13 @@ void Hy3Layout::insertNode(Hy3Node& node) {
19 			static const auto* tab_first_window =
20 			    &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tab_first_window")->intValue;
21 
22+			auto width =
23+			    monitor->vecSize.x - monitor->vecReservedBottomRight.x - monitor->vecReservedTopLeft.x;
24+			auto height =
25+			    monitor->vecSize.y - monitor->vecReservedBottomRight.y - monitor->vecReservedTopLeft.y;
26+
27 			this->nodes.push_back({
28-			    .data = Hy3GroupLayout::SplitH,
29+			    .data = height > width ? Hy3GroupLayout::SplitV : Hy3GroupLayout::SplitH,
30 			    .position = monitor->vecPosition + monitor->vecReservedTopLeft,
31 			    .size = monitor->vecSize - monitor->vecReservedTopLeft - monitor->vecReservedBottomRight,
32 			    .workspace_id = node.workspace_id,
33@@ -1228,7 +1235,12 @@ void Hy3Layout::focusTab(
34 
35 	if (target == TabFocus::MouseLocation || mouse != TabFocusMousePriority::Ignore) {
36 		auto mouse_pos = g_pInputManager->getMouseCoordsInternal();
37-		if (g_pCompositor->vectorToWindowUnified(mouse_pos, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY) == nullptr) {
38+		if (g_pCompositor->vectorToWindowUnified(
39+		        mouse_pos,
40+		        RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY
41+		    )
42+		    == nullptr)
43+		{
44 			tab_node = findTabBarAt(*node, mouse_pos, &tab_focused_node);
45 			if (tab_node != nullptr) goto hastab;
46 		}