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

This commit is contained in:
outfoxxed 2023-10-23 02:47:55 -07:00
parent 0862855b87
commit 1222764a7c
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 21 additions and 0 deletions

View file

@ -181,6 +181,9 @@ plugin {
# offset from group split direction when only one window is in a group
group_inset = <int> # default: 10
# if a tab group will automatically be created for the first window spawned in a workspace
tab_first_window = <bool>
# tab group settings
tabs {
# height of the tab bar

View file

@ -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();
}
}

View file

@ -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);