mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-15 18:53:40 +01:00
Fix single group nested in a group bug
This commit is contained in:
parent
1121d0aa66
commit
d5828c5878
2 changed files with 24 additions and 1 deletions
|
@ -197,6 +197,18 @@ void Hy3Node::recalcSizePosRecursive(bool force) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool swallowGroup(Hy3Node* into) {
|
||||||
|
if (into == nullptr || into->data.type != Hy3NodeData::Group) return false;
|
||||||
|
if (into->data.as_group.children.size() != 1) return false;
|
||||||
|
auto* child = into->data.as_group.children.front();
|
||||||
|
|
||||||
|
Debug::log(LOG, "Swallowing %p into %p", child, into);
|
||||||
|
swapNodeData(*into, *child);
|
||||||
|
into->layout->nodes.remove(*child);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Hy3GroupData::hasChild(Hy3Node* node) {
|
bool Hy3GroupData::hasChild(Hy3Node* node) {
|
||||||
Debug::log(LOG, "Searching for child %p of %p", this, node);
|
Debug::log(LOG, "Searching for child %p of %p", this, node);
|
||||||
for (auto child: this->children) {
|
for (auto child: this->children) {
|
||||||
|
@ -1093,7 +1105,6 @@ Hy3Node* shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift) {
|
||||||
// must happen AFTER `insert` is used
|
// must happen AFTER `insert` is used
|
||||||
old_group->children.remove(&node);
|
old_group->children.remove(&node);
|
||||||
|
|
||||||
|
|
||||||
auto splitmod = old_group->children.empty() ? 0.0 : (1.0 - node.size_ratio) / old_group->children.size();
|
auto splitmod = old_group->children.empty() ? 0.0 : (1.0 - node.size_ratio) / old_group->children.size();
|
||||||
for (auto child: old_group->children) {
|
for (auto child: old_group->children) {
|
||||||
child->size_ratio -= splitmod;
|
child->size_ratio -= splitmod;
|
||||||
|
@ -1135,6 +1146,14 @@ Hy3Node* shiftOrGetFocus(Hy3Node& node, ShiftDirection direction, bool shift) {
|
||||||
|
|
||||||
old_parent->recalcSizePosRecursive();
|
old_parent->recalcSizePosRecursive();
|
||||||
target_group->recalcSizePosRecursive();
|
target_group->recalcSizePosRecursive();
|
||||||
|
|
||||||
|
auto* target_parent = target_group->parent;
|
||||||
|
while (target_parent != nullptr && swallowGroup(target_parent)) {
|
||||||
|
target_parent = target_parent->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target_parent != target_group && target_parent != nullptr)
|
||||||
|
target_parent->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -79,6 +79,10 @@ struct Hy3Node {
|
||||||
bool operator==(const Hy3Node&) const;
|
bool operator==(const Hy3Node&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Attempt to swallow a group. returns true if swallowed
|
||||||
|
Hy3Node* swallowGroups(Hy3Node*);
|
||||||
|
|
||||||
|
|
||||||
class Hy3Layout: public IHyprLayout {
|
class Hy3Layout: public IHyprLayout {
|
||||||
public:
|
public:
|
||||||
virtual void onWindowCreatedTiling(CWindow*);
|
virtual void onWindowCreatedTiling(CWindow*);
|
||||||
|
|
Loading…
Add table
Reference in a new issue