From ce626a0708cf93c8bcb5c67230caf18d656b43de Mon Sep 17 00:00:00 2001 From: vilhalmer Date: Sun, 8 Jul 2018 22:55:50 -0400 Subject: [PATCH 1/3] Replace empty workspace with moved workspace --- sway/tree/layout.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 14631ad4..a4faaeb4 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -168,25 +168,36 @@ void container_move_to(struct sway_container *container, struct sway_container *old_parent = container_remove_child(container); container->width = container->height = 0; container->saved_width = container->saved_height = 0; - struct sway_container *new_parent; + + struct sway_container *new_parent, *new_parent_focus; + struct sway_seat *seat = input_manager_get_default_seat(input_manager); + + // Get the focus of the destination before we change it. + new_parent_focus = seat_get_focus_inactive(seat, destination); if (destination->type == C_VIEW) { new_parent = container_add_sibling(destination, container); } else { new_parent = destination; container_add_child(destination, container); } + wl_signal_emit(&container->events.reparent, old_parent); if (container->type == C_WORKSPACE) { // If moving a workspace to a new output, maybe create a new workspace // on the previous output - struct sway_seat *seat = input_manager_get_default_seat(input_manager); if (old_parent->children->length == 0) { char *ws_name = workspace_next_name(old_parent->name); - struct sway_container *ws = - workspace_create(old_parent, ws_name); + struct sway_container *ws = workspace_create(old_parent, ws_name); free(ws_name); seat_set_focus(seat, ws); } + + // Remove an empty workspace from the destination output. + if (new_parent_focus->type != C_WORKSPACE) { + new_parent_focus = container_parent(new_parent_focus, C_WORKSPACE); + } + container_reap_empty_recursive(new_parent_focus); + container_sort_workspaces(new_parent); seat_set_focus(seat, new_parent); workspace_output_raise_priority(container, old_parent, new_parent); From 47c20f8ea432a9648d69116a52d4e502c5c307f2 Mon Sep 17 00:00:00 2001 From: vilhalmer Date: Mon, 9 Jul 2018 08:25:32 -0400 Subject: [PATCH 2/3] Regroup signal --- sway/tree/layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index a4faaeb4..fce8ba42 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -180,8 +180,8 @@ void container_move_to(struct sway_container *container, new_parent = destination; container_add_child(destination, container); } - wl_signal_emit(&container->events.reparent, old_parent); + if (container->type == C_WORKSPACE) { // If moving a workspace to a new output, maybe create a new workspace // on the previous output From 4e7ef1dd39ae4ceadba0ffb1e8c6f9c60f43afda Mon Sep 17 00:00:00 2001 From: vilhalmer Date: Mon, 9 Jul 2018 08:26:39 -0400 Subject: [PATCH 3/3] No need to walk to workspace, recursive will --- sway/tree/layout.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index fce8ba42..0dba4aab 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -192,10 +192,7 @@ void container_move_to(struct sway_container *container, seat_set_focus(seat, ws); } - // Remove an empty workspace from the destination output. - if (new_parent_focus->type != C_WORKSPACE) { - new_parent_focus = container_parent(new_parent_focus, C_WORKSPACE); - } + // Try to remove an empty workspace from the destination output. container_reap_empty_recursive(new_parent_focus); container_sort_workspaces(new_parent);