From 93624599b3252c0c8378d8e788a500b4b597a135 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 23 Sep 2018 13:10:36 +1000 Subject: Remove move_out_of_tabs_stacks This fixes the following. Create these layouts and run move right: (Initial layout -> expected result -> actual result) * `H[S[unfocused focused] unfocused]` -> `H[S[unfocused] focused unfocused]` -> `H[H[S[unfocused] focused] unfocused]` * `H[S[unfocused focused] V[unfocused]]` -> `H[S[unfocused] V[unfocused focused]]` -> `H[H[S[unfocused] focused] V[unfocused]]` move_out_of_tabs_stacks was originally made to allow views to move out of the tabbed/stacked container in the parallel direction, but at some point this has started working using the regular logic. --- sway/commands/move.c | 49 ++----------------------------------------------- 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index 849a18ad..6e32c932 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -270,39 +270,6 @@ static void workspace_rejigger(struct sway_workspace *ws, child->width = child->height = 0; } -static void move_out_of_tabs_stacks(struct sway_container *container, - struct sway_container *current, enum movement_direction move_dir, - int offs) { - enum sway_container_layout layout = move_dir == - MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; - list_t *siblings = container_get_siblings(container); - if (container == current && siblings->length == 1) { - wlr_log(WLR_DEBUG, "Changing layout of parent"); - if (container->parent) { - container->parent->layout = layout; - container_update_representation(container); - } else { - container->workspace->layout = layout; - workspace_update_representation(container->workspace); - } - return; - } - - wlr_log(WLR_DEBUG, "Moving out of tab/stack into a split"); - if (current->parent) { - struct sway_container *new_parent = - container_split(current->parent, layout); - container_insert_child(new_parent, container, offs < 0 ? 0 : 1); - container_reap_empty(new_parent); - container_flatten(new_parent); - } else { - // Changing a workspace - struct sway_workspace *workspace = container->workspace; - workspace_split(workspace, layout); - workspace_insert_tiling(workspace, container, offs < 0 ? 0 : 1); - } -} - // Returns true if moved static bool container_move_in_direction(struct sway_container *container, enum movement_direction move_dir) { @@ -334,7 +301,6 @@ static bool container_move_in_direction(struct sway_container *container, int offs = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? -1 : 1; while (current) { - struct sway_container *parent = current->parent; list_t *siblings = container_get_siblings(current); enum sway_container_layout layout = container_parent_layout(current); int index = list_find(siblings, current); @@ -343,15 +309,8 @@ static bool container_move_in_direction(struct sway_container *container, if (is_parallel(layout, move_dir)) { if (desired == -1 || desired == siblings->length) { if (current->parent == container->parent) { - if (!(parent && parent->is_fullscreen) && - (layout == L_TABBED || layout == L_STACKED)) { - move_out_of_tabs_stacks(container, current, - move_dir, offs); - return true; - } else { - current = current->parent; - continue; - } + current = current->parent; + continue; } else { // Special case if (current->parent) { @@ -369,10 +328,6 @@ static bool container_move_in_direction(struct sway_container *container, siblings->items[desired], move_dir); return true; } - } else if (!(parent && parent->is_fullscreen) && - (layout == L_TABBED || layout == L_STACKED)) { - move_out_of_tabs_stacks(container, current, move_dir, offs); - return true; } current = current->parent; -- cgit v1.2.3 From 0b7fb6943ed7cc0be7f249c663966acf6c833299 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 23 Sep 2018 13:55:06 +1000 Subject: Fix some bugs as a result of removing move_out_of_tabs_stacks --- sway/commands/move.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index 6e32c932..8bf85f9b 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -259,6 +259,12 @@ static void container_move_to_container(struct sway_container *container, * In other words, rejigger it. */ static void workspace_rejigger(struct sway_workspace *ws, struct sway_container *child, enum movement_direction move_dir) { + if (!child->parent && ws->tiling->length == 1) { + ws->layout = + move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; + workspace_update_representation(ws); + return; + } container_detach(child); workspace_wrap_children(ws); @@ -343,10 +349,8 @@ static bool container_move_in_direction(struct sway_container *container, // Maybe rejigger the workspace struct sway_workspace *ws = container->workspace; if (!is_parallel(ws->layout, move_dir)) { - if (ws->tiling->length >= 2) { - workspace_rejigger(ws, container, move_dir); - return true; - } + workspace_rejigger(ws, container, move_dir); + return true; } else if (ws->layout == L_TABBED || ws->layout == L_STACKED) { workspace_rejigger(ws, container, move_dir); return true; -- cgit v1.2.3 From 9753e52d6b5e0d83e3473cfa9908ae3a0a459e73 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 23 Sep 2018 14:32:26 +1000 Subject: Flatten container in workspace_rejigger --- sway/commands/move.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index 8bf85f9b..fc2f1cc1 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -266,10 +266,11 @@ static void workspace_rejigger(struct sway_workspace *ws, return; } container_detach(child); - workspace_wrap_children(ws); + struct sway_container *new_parent = workspace_wrap_children(ws); int index = move_dir == MOVE_LEFT || move_dir == MOVE_UP ? 0 : 1; workspace_insert_tiling(ws, child, index); + container_flatten(new_parent); ws->layout = move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; workspace_update_representation(ws); -- cgit v1.2.3