diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2020-10-23 12:00:45 -0700 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2020-12-20 00:58:42 -0500 |
commit | 2478f2f010bea58d4a7533d82f155a10ed04dd66 (patch) | |
tree | 6b8e0c5ed967fd6581b853addfc032ff55370e9d | |
parent | 33b64667ae0bfe9af752cb8c850b4f52b34660d2 (diff) |
container: don't split single children
In i3 splits are ineffective on singleton H/V containers,
and the command is interpreted to affect the parent layout
instead.
-rw-r--r-- | sway/commands/split.c | 4 | ||||
-rw-r--r-- | sway/tree/container.c | 22 |
2 files changed, 22 insertions, 4 deletions
diff --git a/sway/commands/split.c b/sway/commands/split.c index ec56c2f0..782bab02 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c @@ -23,10 +23,6 @@ static struct cmd_results *do_split(int layout) { workspace_split(ws, layout); } - if (con && con->parent && con->parent->parent) { - container_flatten(con->parent->parent); - } - if (root->fullscreen_global) { arrange_root(); } else { diff --git a/sway/tree/container.c b/sway/tree/container.c index 10d621b4..3c8e2780 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1410,6 +1410,28 @@ void container_replace(struct sway_container *container, struct sway_container *container_split(struct sway_container *child, enum sway_container_layout layout) { + // i3 doesn't split singleton H/V containers + // https://github.com/i3/i3/blob/3cd1c45eba6de073bc4300eebb4e1cc1a0c4479a/src/tree.c#L354 + if (child->parent || child->workspace) { + list_t *siblings = container_get_siblings(child); + if (siblings->length == 1) { + enum sway_container_layout current = container_parent_layout(child); + if (container_is_floating(child)) { + current = L_NONE; + } + if (current == L_HORIZ || current == L_VERT) { + if (child->parent) { + child->parent->layout = layout; + container_update_representation(child->parent); + } else { + child->workspace->layout = layout; + workspace_update_representation(child->workspace); + } + return child; + } + } + } + struct sway_seat *seat = input_manager_get_default_seat(); bool set_focus = (seat_get_focus(seat) == &child->node); |