sway/commands/layout: fix flatten parent once

Fixes: f50e307227 ("sway/commands/layout: flatten parent once")
This commit is contained in:
bonsaiiV 2025-10-18 16:55:46 +00:00 committed by GitHub
parent 90d3270970
commit b7eb6177e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,11 +137,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
// If parent has only a singe child operate on its parent and // If parent has only a singe child operate on its parent and
// flatten once, like i3 // flatten once, like i3
if (container && container->pending.children->length == 1) { if (container && container->pending.children->length == 1) {
struct sway_container *child = container->pending.children->items[0]; // Also check grandparent to avoid restricting layouts
struct sway_container *parent = container->pending.parent; struct sway_container *parent = container->pending.parent;
container_replace(container, child); if (parent && parent->pending.children->length == 1) {
container_begin_destroy(container); struct sway_container *child = container->pending.children->items[0];
container = parent; struct sway_container *parent = container->pending.parent;
container_replace(container, child);
container_begin_destroy(container);
container = parent;
}
} }
} }