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,6 +137,9 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
// If parent has only a singe child operate on its parent and
// flatten once, like i3
if (container && container->pending.children->length == 1) {
// Also check grandparent to avoid restricting layouts
struct sway_container *parent = container->pending.parent;
if (parent && parent->pending.children->length == 1) {
struct sway_container *child = container->pending.children->items[0];
struct sway_container *parent = container->pending.parent;
container_replace(container, child);
@ -144,6 +147,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
container = parent;
}
}
}
// We could be working with a container OR a workspace. These are different
// structures, so we set up pointers to they layouts so we can refer them in