diff --git a/README.md b/README.md index 315b705..0867132 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,9 @@ plugin { # offset from group split direction when only one window is in a group group_inset = # default: 10 + # if a tab group will automatically be created for the first window spawned in a workspace + tab_first_window = + # tab group settings tabs { # height of the tab bar diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 04a982b..d34a0b2 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -130,6 +130,8 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { opening_into = opening_after->parent; } else { if ((opening_into = this->getWorkspaceRootGroup(window->m_iWorkspaceID)) == nullptr) { + static const auto* tab_first_window = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tab_first_window")->intValue; + this->nodes.push_back({ .data = Hy3GroupLayout::SplitH, .position = monitor->vecPosition + monitor->vecReservedTopLeft, @@ -138,6 +140,21 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window, eDirection) { .layout = this, }); + if (*tab_first_window) { + auto& parent = this->nodes.back(); + + this->nodes.push_back({ + .parent = &parent, + .data = Hy3GroupLayout::Tabbed, + .position = parent.position, + .size = parent.size, + .workspace_id = window->m_iWorkspaceID, + .layout = this, + }); + + parent.data.as_group.children.push_back(&this->nodes.back()); + } + opening_into = &this->nodes.back(); } } diff --git a/src/main.cpp b/src/main.cpp index 138ec7f..12944a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { CONF("no_gaps_when_only", int, 0); CONF("node_collapse_policy", int, 2); CONF("group_inset", int, 10); + CONF("tab_first_window", int, 0); // tabs CONF("tabs:height", int, 15);