aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 12:34:01 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-04-03 12:34:01 -0400
commit09d448ea2df60b7e4504b1ec4728e7f1df0244b7 (patch)
tree7555d93cbc9f701a173044dc3d4e437d1db95f67 /sway/tree/container.c
parentmove view and workspace destructors to container.c (diff)
downloadsway-09d448ea2df60b7e4504b1ec4728e7f1df0244b7.tar.gz
sway-09d448ea2df60b7e4504b1ec4728e7f1df0244b7.tar.zst
sway-09d448ea2df60b7e4504b1ec4728e7f1df0244b7.zip
unify container destroy functions
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index c1ebf4f1..1c41bf5d 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -109,6 +109,43 @@ struct sway_container *container_finish(struct sway_container *cont) {
109 free(cont); 109 free(cont);
110 return parent; 110 return parent;
111} 111}
112
113static struct sway_container *container_output_destroy(struct sway_container *output) {
114 if (!sway_assert(output, "cannot destroy null output")) {
115 return NULL;
116 }
117
118 if (output->children->length > 0) {
119 // TODO save workspaces when there are no outputs.
120 // TODO also check if there will ever be no outputs except for exiting
121 // program
122 if (root_container.children->length > 1) {
123 int p = root_container.children->items[0] == output;
124 // Move workspace from this output to another output
125 while (output->children->length) {
126 struct sway_container *child = output->children->items[0];
127 container_remove_child(child);
128 container_add_child(root_container.children->items[p], child);
129 }
130 container_sort_workspaces(root_container.children->items[p]);
131 arrange_windows(root_container.children->items[p],
132 -1, -1);
133 }
134 }
135
136 wl_list_remove(&output->sway_output->destroy.link);
137 wl_list_remove(&output->sway_output->mode.link);
138 wl_list_remove(&output->sway_output->transform.link);
139 wl_list_remove(&output->sway_output->scale.link);
140
141 wl_list_remove(&output->sway_output->damage_destroy.link);
142 wl_list_remove(&output->sway_output->damage_frame.link);
143
144 wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
145 container_finish(output);
146 return &root_container;
147}
148
112static struct sway_container *container_workspace_destroy( 149static struct sway_container *container_workspace_destroy(
113 struct sway_container *workspace) { 150 struct sway_container *workspace) {
114 if (!sway_assert(workspace, "cannot destroy null workspace")) { 151 if (!sway_assert(workspace, "cannot destroy null workspace")) {