1222764a7c1d9e6d274992d8cc04b33e72d595be

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

Message

Add option to create a tab group for the first spawned window

Diff

 1diff --git a/README.md b/README.md
 2index 315b705e45f8a74bfbd06bd37a9bd29b9c0a85f7..08671328b643c8cfbe2943e2a19744fed923fc11 100644
 3--- a/README.md
 4+++ b/README.md
 5@@ -181,6 +181,9 @@ plugin {
 6     # offset from group split direction when only one window is in a group
 7     group_inset = <int> # default: 10
 8 
 9+    # if a tab group will automatically be created for the first window spawned in a workspace
10+    tab_first_window = <bool>
11+
12     # tab group settings
13     tabs {
14       # height of the tab bar
15diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
16index 04a982b0edcba14cff7a7d36061d393839e5f841..d34a0b29f44b4350e47d2eef9f4ab743f2fff22e 100644
17--- a/src/Hy3Layout.cpp
18+++ b/src/Hy3Layout.cpp
19@@ -130,6 +130,8 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
20 		opening_into = opening_after->parent;
21 	} else {
22 		if ((opening_into = this->getWorkspaceRootGroup(window->m_iWorkspaceID)) == nullptr) {
23+			static const auto* tab_first_window = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tab_first_window")->intValue;
24+
25 			this->nodes.push_back({
26 			    .data = Hy3GroupLayout::SplitH,
27 			    .position = monitor->vecPosition + monitor->vecReservedTopLeft,
28@@ -138,6 +140,21 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) {
29 			    .layout = this,
30 			});
31 
32+			if (*tab_first_window) {
33+				auto& parent = this->nodes.back();
34+
35+				this->nodes.push_back({
36+					.parent = &parent,
37+					.data = Hy3GroupLayout::Tabbed,
38+			    .position = parent.position,
39+			    .size = parent.size,
40+					.workspace_id = window->m_iWorkspaceID,
41+					.layout = this,
42+				});
43+
44+				parent.data.as_group.children.push_back(&this->nodes.back());
45+			}
46+
47 			opening_into = &this->nodes.back();
48 		}
49 	}
50diff --git a/src/main.cpp b/src/main.cpp
51index 138ec7f1ae429cb8a099ccf13259e67542abe32e..12944a2a8483271d75c82b8e24de61b02f6f329b 100644
52--- a/src/main.cpp
53+++ b/src/main.cpp
54@@ -21,6 +21,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
55 	CONF("no_gaps_when_only", int, 0);
56 	CONF("node_collapse_policy", int, 2);
57 	CONF("group_inset", int, 10);
58+	CONF("tab_first_window", int, 0);
59 
60 	// tabs
61 	CONF("tabs:height", int, 15);