diff --git a/sway/commands/layout.c b/sway/commands/layout.c index a32c908b8..22dfdf3d7 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -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 // flatten once, like i3 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; - container_replace(container, child); - container_begin_destroy(container); - container = 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); + container_begin_destroy(container); + container = parent; + } } }