Skip to content

Commit b7eb617

Browse files
authored
sway/commands/layout: fix flatten parent once
Fixes: f50e307 ("sway/commands/layout: flatten parent once")
1 parent 90d3270 commit b7eb617

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sway/commands/layout.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
137137
// If parent has only a singe child operate on its parent and
138138
// flatten once, like i3
139139
if (container && container->pending.children->length == 1) {
140-
struct sway_container *child = container->pending.children->items[0];
140+
// Also check grandparent to avoid restricting layouts
141141
struct sway_container *parent = container->pending.parent;
142-
container_replace(container, child);
143-
container_begin_destroy(container);
144-
container = parent;
142+
if (parent && parent->pending.children->length == 1) {
143+
struct sway_container *child = container->pending.children->items[0];
144+
struct sway_container *parent = container->pending.parent;
145+
container_replace(container, child);
146+
container_begin_destroy(container);
147+
container = parent;
148+
}
145149
}
146150
}
147151

0 commit comments

Comments
 (0)