aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2025-08-03 13:25:40 +0000
committerFurkan Sahin <furkan-dev@proton.me>2025-08-03 13:25:40 +0000
commitc63e5f6c3b82e8bb6492cf0adb6b9711604a964e (patch)
tree20376b21ad775049f84ed322faa23669fb5c175d
parentf9d3a616e73594db3f6d8bef333cadfe478d2bdd (diff)
sway/commands/layout: flatten parent once
Applying layout changes to the parent of the parent, in case the parent only has a single child, stops the creation of a chain of single child containers. Closes: https://github.com/swaywm/sway/issues/7945
-rw-r--r--sway/commands/layout.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index 12ce4839..a32c908b 100644
--- a/sway/commands/layout.c
+++ b/sway/commands/layout.c
@@ -134,6 +134,15 @@ 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) {
+ 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;
+ }
}
// We could be working with a container OR a workspace. These are different