mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 10:43:40 +01:00
Add node_collapse_policy
setting
The original behavior was to always collapse (`node_collapse_policy = 0`)
This commit is contained in:
parent
f08c7ff2e4
commit
87f664f1ea
3 changed files with 24 additions and 1 deletions
|
@ -44,6 +44,13 @@ plugin {
|
|||
# disable gaps when only one window is onscreen
|
||||
no_gaps_when_only = <bool>
|
||||
|
||||
# policy controlling what happens when a node is removed from a group,
|
||||
# leaving only a group
|
||||
# 0 = remove the nested group
|
||||
# 1 = keep the nested group
|
||||
# 2 = keep the nested group only if its parent is a tab group (default)
|
||||
node_collapse_policy = <int>
|
||||
|
||||
# offset from group split direction when only one window is in a group
|
||||
group_inset = <int>
|
||||
|
||||
|
|
|
@ -193,6 +193,9 @@ void Hy3Layout::onWindowCreatedTiling(CWindow* window) {
|
|||
}
|
||||
|
||||
void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
|
||||
static const auto* node_collapse_policy
|
||||
= &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:node_collapse_policy")->intValue;
|
||||
|
||||
auto* node = this->getNodeFromWindow(window);
|
||||
Debug::log(LOG, "remove tiling %p (window %p)", node, window);
|
||||
|
||||
|
@ -217,8 +220,16 @@ void Hy3Layout::onWindowRemovedTiling(CWindow* window) {
|
|||
if (parent != nullptr) {
|
||||
parent->recalcSizePosRecursive();
|
||||
|
||||
// returns if a given node is a group that can be collapsed given the current config
|
||||
auto node_is_collapsible = [](Hy3Node* node) {
|
||||
if (node->data.type != Hy3NodeType::Group) return false;
|
||||
if (*node_collapse_policy == 0) return true;
|
||||
else if (*node_collapse_policy == 1) return false;
|
||||
return node->parent->data.as_group.layout != Hy3GroupLayout::Tabbed;
|
||||
};
|
||||
|
||||
if (group.children.size() == 1
|
||||
&& (group.ephemeral || group.children.front()->data.type == Hy3NodeType::Group))
|
||||
&& (group.ephemeral || node_is_collapsible(group.children.front())))
|
||||
{
|
||||
auto* target_parent = parent;
|
||||
while (target_parent != nullptr && Hy3Node::swallowGroups(target_parent)) {
|
||||
|
|
|
@ -19,6 +19,11 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||
"plugin:hy3:no_gaps_when_only",
|
||||
SConfigValue {.intValue = 0}
|
||||
);
|
||||
HyprlandAPI::addConfigValue(
|
||||
PHANDLE,
|
||||
"plugin:hy3:node_collapse_policy",
|
||||
SConfigValue {.intValue = 2}
|
||||
);
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:group_inset", SConfigValue {.intValue = 10});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:height", SConfigValue {.intValue = 15});
|
||||
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hy3:tabs:padding", SConfigValue {.intValue = 5});
|
||||
|
|
Loading…
Add table
Reference in a new issue