diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-10-24 02:00:46 -0400 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2020-12-20 00:58:42 -0500 |
commit | 971aa90ccca33084238cf6025e51fe3205c714b5 (patch) | |
tree | 663cff9b1faf16402b2399c0ebddb67e273cb2a9 /sway | |
parent | commands/layout: don't change the layout of workspaces with children (diff) | |
download | sway-971aa90ccca33084238cf6025e51fe3205c714b5.tar.gz sway-971aa90ccca33084238cf6025e51fe3205c714b5.tar.zst sway-971aa90ccca33084238cf6025e51fe3205c714b5.zip |
commands/move: don't flatten on move; reap empty former parent instead
Some comparisons of current Sway versus i3 behavior:
1) T[T[T[app]]] + move left
* Sway: T[app]
* i3: T[T[app]]
2) H[V[H[V[app]]]] + move left
* Sway: H[app]
* i3: H[V[app]]
After this commit, Sway behavior matches i3. The intermediate states
are now:
T[T[T[app]]] -> T[T[app T[]]] -> T[T[app]]
H[V[H[V[app]]]] -> H[V[app H[V[]]]] -> H[V[app]]
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/move.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 204596c0..247c45fe 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -309,16 +309,6 @@ static bool container_move_in_direction(struct sway_container *container, | |||
309 | return false; | 309 | return false; |
310 | } | 310 | } |
311 | 311 | ||
312 | // If container is in a split container by itself, move out of the split | ||
313 | if (container->parent) { | ||
314 | struct sway_container *old_parent = container->parent; | ||
315 | struct sway_container *new_parent = | ||
316 | container_flatten(container->parent); | ||
317 | if (new_parent != old_parent) { | ||
318 | return true; | ||
319 | } | ||
320 | } | ||
321 | |||
322 | // Look for a suitable *container* sibling or parent. | 312 | // Look for a suitable *container* sibling or parent. |
323 | // The below loop stops once we hit the workspace because current->parent | 313 | // The below loop stops once we hit the workspace because current->parent |
324 | // is NULL for the topmost containers in a workspace. | 314 | // is NULL for the topmost containers in a workspace. |
@@ -721,12 +711,20 @@ static struct cmd_results *cmd_move_in_direction( | |||
721 | return cmd_results_new(CMD_SUCCESS, NULL); | 711 | return cmd_results_new(CMD_SUCCESS, NULL); |
722 | } | 712 | } |
723 | struct sway_workspace *old_ws = container->workspace; | 713 | struct sway_workspace *old_ws = container->workspace; |
714 | struct sway_container *old_parent = container->parent; | ||
724 | 715 | ||
725 | if (!container_move_in_direction(container, direction)) { | 716 | if (!container_move_in_direction(container, direction)) { |
726 | // Container didn't move | 717 | // Container didn't move |
727 | return cmd_results_new(CMD_SUCCESS, NULL); | 718 | return cmd_results_new(CMD_SUCCESS, NULL); |
728 | } | 719 | } |
729 | 720 | ||
721 | // clean-up, destroying parents if the container was the last child | ||
722 | if (old_parent) { | ||
723 | container_reap_empty(old_parent); | ||
724 | } else if (old_ws) { | ||
725 | workspace_consider_destroy(old_ws); | ||
726 | } | ||
727 | |||
730 | struct sway_workspace *new_ws = container->workspace; | 728 | struct sway_workspace *new_ws = container->workspace; |
731 | 729 | ||
732 | if (root->fullscreen_global) { | 730 | if (root->fullscreen_global) { |