summaryrefslogtreecommitdiffstats
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-30 11:58:17 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-30 13:49:34 -0400
commit49379dd0fc0758f89d7f4fa4fb5b08c7f4c26ae6 (patch)
treeb67a66382125811fde75e5c3dff37d7081860c78 /sway/tree/output.c
parentMerge pull request #1664 from swaywm/xwayland-add-to-focused (diff)
downloadsway-49379dd0fc0758f89d7f4fa4fb5b08c7f4c26ae6.tar.gz
sway-49379dd0fc0758f89d7f4fa4fb5b08c7f4c26ae6.tar.zst
sway-49379dd0fc0758f89d7f4fa4fb5b08c7f4c26ae6.zip
Fix workspace deletion edge cases
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
new file mode 100644
index 00000000..2246cb11
--- /dev/null
+++ b/sway/tree/output.c
@@ -0,0 +1,36 @@
1#include "sway/tree/container.h"
2#include "sway/tree/layout.h"
3#include "sway/output.h"
4#include "log.h"
5
6struct sway_container *container_output_destroy(struct sway_container *output) {
7 if (!sway_assert(output, "cannot destroy null output")) {
8 return NULL;
9 }
10
11 if (output->children->length > 0) {
12 // TODO save workspaces when there are no outputs.
13 // TODO also check if there will ever be no outputs except for exiting
14 // program
15 if (root_container.children->length > 1) {
16 int p = root_container.children->items[0] == output;
17 // Move workspace from this output to another output
18 while (output->children->length) {
19 struct sway_container *child = output->children->items[0];
20 container_remove_child(child);
21 container_add_child(root_container.children->items[p], child);
22 }
23 container_sort_workspaces(root_container.children->items[p]);
24 arrange_windows(root_container.children->items[p],
25 -1, -1);
26 }
27 }
28
29 wl_list_remove(&output->sway_output->frame.link);
30 wl_list_remove(&output->sway_output->destroy.link);
31 wl_list_remove(&output->sway_output->mode.link);
32
33 wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
34 container_destroy(output);
35 return &root_container;
36}