diff options
-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, | |||
168 | struct sway_container *old_parent = container_remove_child(container); | 168 | struct sway_container *old_parent = container_remove_child(container); |
169 | container->width = container->height = 0; | 169 | container->width = container->height = 0; |
170 | container->saved_width = container->saved_height = 0; | 170 | container->saved_width = container->saved_height = 0; |
171 | struct sway_container *new_parent; | 171 | |
172 | struct sway_container *new_parent, *new_parent_focus; | ||
173 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | ||
174 | |||
175 | // Get the focus of the destination before we change it. | ||
176 | new_parent_focus = seat_get_focus_inactive(seat, destination); | ||
172 | if (destination->type == C_VIEW) { | 177 | if (destination->type == C_VIEW) { |
173 | new_parent = container_add_sibling(destination, container); | 178 | new_parent = container_add_sibling(destination, container); |
174 | } else { | 179 | } else { |
@@ -176,17 +181,20 @@ void container_move_to(struct sway_container *container, | |||
176 | container_add_child(destination, container); | 181 | container_add_child(destination, container); |
177 | } | 182 | } |
178 | wl_signal_emit(&container->events.reparent, old_parent); | 183 | wl_signal_emit(&container->events.reparent, old_parent); |
184 | |||
179 | if (container->type == C_WORKSPACE) { | 185 | if (container->type == C_WORKSPACE) { |
180 | // If moving a workspace to a new output, maybe create a new workspace | 186 | // If moving a workspace to a new output, maybe create a new workspace |
181 | // on the previous output | 187 | // on the previous output |
182 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | ||
183 | if (old_parent->children->length == 0) { | 188 | if (old_parent->children->length == 0) { |
184 | char *ws_name = workspace_next_name(old_parent->name); | 189 | char *ws_name = workspace_next_name(old_parent->name); |
185 | struct sway_container *ws = | 190 | struct sway_container *ws = workspace_create(old_parent, ws_name); |
186 | workspace_create(old_parent, ws_name); | ||
187 | free(ws_name); | 191 | free(ws_name); |
188 | seat_set_focus(seat, ws); | 192 | seat_set_focus(seat, ws); |
189 | } | 193 | } |
194 | |||
195 | // Try to remove an empty workspace from the destination output. | ||
196 | container_reap_empty_recursive(new_parent_focus); | ||
197 | |||
190 | container_sort_workspaces(new_parent); | 198 | container_sort_workspaces(new_parent); |
191 | seat_set_focus(seat, new_parent); | 199 | seat_set_focus(seat, new_parent); |
192 | workspace_output_raise_priority(container, old_parent, new_parent); | 200 | workspace_output_raise_priority(container, old_parent, new_parent); |