aboutsummaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/sway/container.c b/sway/container.c
index c260e01a..a40c483c 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -323,9 +323,6 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
323 if (!ASSERT_NONNULL(workspace)) { 323 if (!ASSERT_NONNULL(workspace)) {
324 return NULL; 324 return NULL;
325 } 325 }
326 // NOTE: This is called from elsewhere without checking children length
327 // TODO move containers to other workspaces?
328 // for now just dont delete
329 326
330 // Do not destroy this if it's the last workspace on this output 327 // Do not destroy this if it's the last workspace on this output
331 swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT); 328 swayc_t *output = swayc_parent_by_type(workspace, C_OUTPUT);
@@ -333,14 +330,35 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
333 return NULL; 330 return NULL;
334 } 331 }
335 332
336 // Do not destroy if there are children 333 swayc_t *parent = workspace->parent;
334 // destroy the WS if there are no children
337 if (workspace->children->length == 0 && workspace->floating->length == 0) { 335 if (workspace->children->length == 0 && workspace->floating->length == 0) {
338 sway_log(L_DEBUG, "destroying workspace '%s'", workspace->name); 336 sway_log(L_DEBUG, "destroying workspace '%s'", workspace->name);
339 swayc_t *parent = workspace->parent; 337 } else {
340 free_swayc(workspace); 338 // Move children to a different workspace on this output
341 return parent; 339 swayc_t *new_workspace = NULL;
340 int i;
341 for(i = 0; i < output->children->length; i++) {
342 if(output->children->items[i] != workspace) {
343 break;
344 }
345 }
346 new_workspace = output->children->items[i];
347
348 sway_log(L_DEBUG, "moving children to different workspace '%s' -> '%s'",
349 workspace->name, new_workspace->name);
350
351 for(i = 0; i < workspace->children->length; i++) {
352 move_container_to(workspace->children->items[i], new_workspace);
353 }
354
355 for(i = 0; i < workspace->floating->length; i++) {
356 move_container_to(workspace->floating->items[i], new_workspace);
357 }
342 } 358 }
343 return NULL; 359
360 free_swayc(workspace);
361 return parent;
344} 362}
345 363
346swayc_t *destroy_container(swayc_t *container) { 364swayc_t *destroy_container(swayc_t *container) {