e452d045072779c4776b4993cdd09ca1ad094eba

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

Message

prevent mouse based tab focusing without a focused window surface.

Diff

 1diff --git a/CHANGELOG.md b/CHANGELOG.md
 2index 10bb0aad7a05f783f03b6be6853a7df98117d0dc..dcda93ed108d5ddd57d6726d4f036e9002e339f3 100644
 3--- a/CHANGELOG.md
 4+++ b/CHANGELOG.md
 5@@ -6,6 +6,7 @@
 6 - Renamed `hy3:tabs:rounding` to `hy3:tabs:radius`.
 7 - Changed default tab style.
 8 - Fixed floating windows losing their size after maximizing and then going into fullscreen.
 9+- Fixed tab bars being clickable while covered by layers or with active pointer grabs.
10 
11 # hl0.46.0 and before
12 
13diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
14index d3c14d6b473660a826a0ad3345d6ac64b63a96a8..3ed7a8df353c8a7b58dde279c9c45db583e95f33 100644
15--- a/src/Hy3Layout.cpp
16+++ b/src/Hy3Layout.cpp
17@@ -6,6 +6,7 @@
18 #include <hyprland/src/desktop/DesktopTypes.hpp>
19 #include <hyprland/src/desktop/Workspace.hpp>
20 #include <hyprland/src/managers/PointerManager.hpp>
21+#include <hyprland/src/managers/SeatManager.hpp>
22 #include <hyprland/src/plugins/PluginAPI.hpp>
23 #include <ranges>
24 
25@@ -14,6 +15,7 @@
26 #include "SelectionHook.hpp"
27 #include "TabGroup.hpp"
28 #include "globals.hpp"
29+#include "src/desktop/WLSurface.hpp"
30 #include "src/desktop/Window.hpp"
31 
32 std::string operationWorkspaceForName(const std::string& workspace) {
33@@ -1257,16 +1259,20 @@ void Hy3Layout::focusTab(
34 	Hy3Node* tab_focused_node;
35 
36 	if (target == TabFocus::MouseLocation || mouse != TabFocusMousePriority::Ignore) {
37+		// no surf focused at all
38+		auto ptrSurfaceResource = g_pSeatManager->state.pointerFocus.lock();
39+		if (!ptrSurfaceResource) return;
40+
41+		auto ptrSurface = CWLSurface::fromResource(ptrSurfaceResource);
42+		if (!ptrSurface) return;
43+
44+		// non window-parented surface focused, cant have a tab
45+		auto window = ptrSurface->getWindow();
46+		if (!window || window->m_bIsFloating) return;
47+
48 		auto mouse_pos = g_pInputManager->getMouseCoordsInternal();
49-		if (g_pCompositor->vectorToWindowUnified(
50-		        mouse_pos,
51-		        RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING | FLOATING_ONLY
52-		    )
53-		    == nullptr)
54-		{
55-			tab_node = findTabBarAt(*node, mouse_pos, &tab_focused_node);
56-			if (tab_node != nullptr) goto hastab;
57-		}
58+		tab_node = findTabBarAt(*node, mouse_pos, &tab_focused_node);
59+		if (tab_node != nullptr) goto hastab;
60 
61 		if (target == TabFocus::MouseLocation || mouse == TabFocusMousePriority::Require) return;
62 	}