summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-07-01 03:20:38 -0400
committerSimon Ser <contact@emersion.fr>2020-07-15 19:27:12 +0200
commit83382f0b4ebcfeb05da57b6432cb2c08e30dde5c (patch)
tree251c7e6cab7542d6f3527251dafb2ae4838e2a2b
parentc199c8d6ea3fb77697040f3d814af8d76c6e6d2d (diff)
commands/move: maintain workspace_layout when moving
Fixes #5157. (cherry picked from commit b4a75a1ab2a72842830aeea37733311f85e6f660)
-rw-r--r--sway/commands/move.c10
-rw-r--r--sway/tree/container.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 5851520e9..038390832 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -275,12 +275,11 @@ static void workspace_rejigger(struct sway_workspace *ws,
return;
}
container_detach(child);
- struct sway_container *new_parent = workspace_wrap_children(ws);
+ workspace_wrap_children(ws);
int index =
move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP ? 0 : 1;
workspace_insert_tiling(ws, child, index);
- container_flatten(new_parent);
ws->layout =
move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_RIGHT ?
L_HORIZ : L_VERT;
@@ -349,8 +348,11 @@ static bool container_move_in_direction(struct sway_container *container,
container_insert_child(current->parent, container,
index + (offs < 0 ? 0 : 1));
} else {
- workspace_insert_tiling(current->workspace, container,
- index + (offs < 0 ? 0 : 1));
+ struct sway_workspace *ws = current->workspace;
+ workspace_insert_tiling(ws,
+ container_split(container,
+ output_get_default_layout(ws->output)),
+ index + (offs < 0 ? 0 : 1));
}
return true;
}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 4cc42747d..fa1598ef9 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1329,6 +1329,14 @@ void container_detach(struct sway_container *child) {
container_update_representation(old_parent);
node_set_dirty(&old_parent->node);
} else if (old_workspace) {
+ // We may have removed the last tiling child from the workspace. If the
+ // workspace layout was e.g. tabbed, then at this point it may be just
+ // H[]. So, reset it to the default (e.g. T[]) for next time.
+ if (!old_workspace->tiling->length) {
+ old_workspace->layout =
+ output_get_default_layout(old_workspace->output);
+ }
+
workspace_update_representation(old_workspace);
node_set_dirty(&old_workspace->node);
}