f2e3c4d000efe7fab52f6b70ada3797ab15ac54f
- Author
- outfoxxed <outfoxxed@outfoxxed.me>
- Committer
- outfoxxed <outfoxxed@outfoxxed.me>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
2index a37281d018b85a2cb6476c6fc4daf82d1e2cf8be..ae203852e2a2dd143753ec2d8f5b543a8ca89f11 100644
3--- a/src/Hy3Layout.cpp
4+++ b/src/Hy3Layout.cpp
5@@ -1710,15 +1710,71 @@ Hy3Node* Hy3Node::findNodeForTabGroup(Hy3TabGroup& tab_group) {
6 return nullptr;
7 }
8
9+Hy3Node* findTabBarAt(Hy3Node& node, Vector2D pos, Hy3Node** focused_node) {
10+ // clang-format off
11+ static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
12+ static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
13+ static const auto* tab_bar_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:height")->intValue;
14+ static const auto* tab_bar_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:padding")->intValue;
15+ // clang-format on
16+
17+ auto inset = *tab_bar_height + *tab_bar_padding;
18+
19+ if (node.parent == nullptr) {
20+ inset += *gaps_out;
21+ } else {
22+ inset += *gaps_in;
23+ }
24+
25+ if (node.data.type == Hy3NodeData::Group) {
26+ if (node.hidden) return nullptr;
27+ // note: tab bar clicks ignore animations
28+ if (node.position.x > pos.x || node.position.y > pos.y || node.position.x + node.size.x < pos.x
29+ || node.position.y + node.size.y < pos.y)
30+ return nullptr;
31+
32+ if (node.data.as_group.layout == Hy3GroupLayout::Tabbed
33+ && node.data.as_group.tab_bar != nullptr)
34+ {
35+ if (pos.y < node.position.y + inset) {
36+ auto& children = node.data.as_group.children;
37+ auto& tab_bar = *node.data.as_group.tab_bar;
38+
39+ auto size = tab_bar.size.vec();
40+ auto x = pos.x - tab_bar.pos.vec().x;
41+ auto child_iter = children.begin();
42+
43+ for (auto& tab: tab_bar.bar.entries) {
44+ if (child_iter == children.end()) break;
45+
46+ if (x > tab.offset.fl() * size.x && x < (tab.offset.fl() + tab.width.fl()) * size.x) {
47+ *focused_node = *child_iter;
48+ return &node;
49+ }
50+
51+ child_iter = std::next(child_iter);
52+ }
53+ }
54+
55+ if (node.data.as_group.focused_child != nullptr) {
56+ return findTabBarAt(*node.data.as_group.focused_child, pos, focused_node);
57+ }
58+ } else {
59+ for (auto child: node.data.as_group.children) {
60+ if (findTabBarAt(*child, pos, focused_node)) return child;
61+ }
62+ }
63+ }
64+
65+ return nullptr;
66+}
67+
68 void Hy3Layout::focusTab(
69 int workspace,
70 TabFocus target,
71 TabFocusMousePriority mouse,
72 bool wrap_scroll
73 ) {
74- static const auto* tab_bar_padding
75- = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:padding")->intValue;
76-
77 auto* node = this->getWorkspaceRootGroup(workspace);
78 if (node == nullptr) return;
79
80@@ -1726,37 +1782,10 @@ void Hy3Layout::focusTab(
81 Hy3Node* tab_focused_node;
82
83 if (target == TabFocus::MouseLocation || mouse != TabFocusMousePriority::Ignore) {
84- auto mouse_pos = g_pInputManager->getMouseCoordsInternal();
85-
86- for (auto& tab_group: this->tab_groups) {
87- auto pos = tab_group.pos.vec();
88- if (pos.x > mouse_pos.x || pos.y > mouse_pos.y) continue;
89- auto size = tab_group.size.vec();
90- if (pos.x + size.x < mouse_pos.x || pos.y + size.y + *tab_bar_padding < mouse_pos.y) continue;
91-
92- tab_node = node->findNodeForTabGroup(tab_group);
93- if (tab_node == nullptr) continue;
94- if (target != TabFocus::MouseLocation) goto hastab;
95-
96- auto delta = mouse_pos - pos;
97-
98- auto& node_list = tab_node->data.as_group.children;
99- auto node_iter = node_list.begin();
100-
101- for (auto& tab: tab_group.bar.entries) {
102- if (node_iter == node_list.end()) break;
103-
104- if (delta.x > tab.offset.fl() * size.x