diff options
author | emersion <contact@emersion.fr> | 2018-07-09 19:04:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-09 19:04:25 +0100 |
commit | d97b4fa4ed63f6068e0d8d7a1c1bc3ba4c7631fe (patch) | |
tree | ba9c11ecf60135a23573e9e5790820c43da66e12 | |
parent | 6595d07ec7fe4422590fc8f40e35af82518a1c43 (diff) | |
parent | 4e7ef1dd39ae4ceadba0ffb1e8c6f9c60f43afda (diff) | |
download | sway-d97b4fa4ed63f6068e0d8d7a1c1bc3ba4c7631fe.tar.xz |
Merge pull request #2230 from vilhalmer/replace-empty-workspace
Replace empty workspace with moved workspace
-rw-r--r-- | sway/tree/layout.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 14631ad4..0dba4aab 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -168,7 +168,12 @@ 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 { @@ -176,17 +181,20 @@ void container_move_to(struct sway_container *container, 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); } + + // Try to remove an empty workspace from the destination output. + 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); |