aboutsummaryrefslogtreecommitdiff
path: root/sway/container.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-27 07:42:12 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-27 07:42:12 -0400
commit24f4b92ea214bd1755d92dc3a07efa2bce575112 (patch)
treeeb8890eb711a55a58e3855c6d9328e3b1dd09063 /sway/container.c
parentef31ee5cf6aabfdf4730ac64c8b004be238df1a8 (diff)
parentd11533595133685d15fd6cdbf9f1611be5e8e2f3 (diff)
Merge pull request #142 from taiyu-len/master
move workspace from dead output to other output
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sway/container.c b/sway/container.c
index 3558809a..a3bc9864 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -281,8 +281,21 @@ swayc_t *destroy_output(swayc_t *output) {
if (!ASSERT_NONNULL(output)) {
return NULL;
}
- if (output->children->length == 0) {
- // TODO move workspaces to other outputs
+ if (output->children->length > 0) {
+ int i, len = root_container.children->length;
+ // TODO save workspaces when there are no outputs.
+ // TODO also check if there will ever be no outputs except for exiting
+ // program
+ if (len > 1) {
+ len = output->children->length;
+ int p = root_container.children->items[0] == output;
+ // Move workspace from this output to another output
+ for (i = 0; i < len; ++i) {
+ swayc_t *child = output->children->items[i];
+ remove_child(child);
+ add_child(root_container.children->items[p], child);
+ }
+ }
}
sway_log(L_DEBUG, "OUTPUT: Destroying output '%lu'", output->handle);
free_swayc(output);