Skip to content

Commit f50e307

Browse files
authored
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: #7945
1 parent 87fbcf0 commit f50e307

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sway/commands/layout.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
134134
// Operate on parent container, like i3.
135135
if (container) {
136136
container = container->pending.parent;
137+
// If parent has only a singe child operate on its parent and
138+
// flatten once, like i3
139+
if (container && container->pending.children->length == 1) {
140+
struct sway_container *child = container->pending.children->items[0];
141+
struct sway_container *parent = container->pending.parent;
142+
container_replace(container, child);
143+
container_begin_destroy(container);
144+
container = parent;
145+
}
137146
}
138147

139148
// We could be working with a container OR a workspace. These are different

0 commit comments

Comments
 (0)