aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar vilhalmer <vil@vil.lv>2018-07-08 22:55:50 -0400
committerLibravatar vilhalmer <vil@vil.lv>2018-07-08 22:55:50 -0400
commitce626a0708cf93c8bcb5c67230caf18d656b43de (patch)
tree01df0eed13a10ff18a968a845e09d0de0f014ea8 /sway/tree/layout.c
parentMerge pull request #2226 from emersion/swaylock-daemonize-after-lock (diff)
downloadsway-ce626a0708cf93c8bcb5c67230caf18d656b43de.tar.gz
sway-ce626a0708cf93c8bcb5c67230caf18d656b43de.tar.zst
sway-ce626a0708cf93c8bcb5c67230caf18d656b43de.zip
Replace empty workspace with moved workspace
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c19
1 files 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,
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 {
175 new_parent = destination; 180 new_parent = destination;
176 container_add_child(destination, container); 181 container_add_child(destination, container);
177 } 182 }
183
178 wl_signal_emit(&container->events.reparent, old_parent); 184 wl_signal_emit(&container->events.reparent, old_parent);
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 // Remove an empty workspace from the destination output.
196 if (new_parent_focus->type != C_WORKSPACE) {
197 new_parent_focus = container_parent(new_parent_focus, C_WORKSPACE);
198 }
199 container_reap_empty_recursive(new_parent_focus);
200
190 container_sort_workspaces(new_parent); 201 container_sort_workspaces(new_parent);
191 seat_set_focus(seat, new_parent); 202 seat_set_focus(seat, new_parent);
192 workspace_output_raise_priority(container, old_parent, new_parent); 203 workspace_output_raise_priority(container, old_parent, new_parent);