From 272d14f8eff460bc36017ea784fc22445a948619 Mon Sep 17 00:00:00 2001 From: Bonsaiiv Date: Wed, 7 Feb 2024 21:37:00 +0100 Subject: [PATCH] matches i3 behavior found the flatten function :) i just followed it; not used it, as that is, what i3 is doing too --- sway/commands/layout.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sway/commands/layout.c b/sway/commands/layout.c index fab7f3ecb..a32c908b8 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -134,8 +134,14 @@ struct cmd_results *cmd_layout(int argc, char **argv) { // Operate on parent container, like i3. if (container) { container = container->pending.parent; + // If parent has only a singe child operate on its parent and + // flatten once, like i3 if (container && container->pending.children->length == 1) { - container = container->pending.parent; + 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; } }