aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-04-03 12:34:01 -0400
committerTony Crisci <tony@dubstepdish.com>2018-04-03 12:34:01 -0400
commit09d448ea2df60b7e4504b1ec4728e7f1df0244b7 (patch)
tree7555d93cbc9f701a173044dc3d4e437d1db95f67 /sway/tree/container.c
parentb4c5f79725142c78a398a22981392d645bc9d2e9 (diff)
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) {
free(cont);
return parent;
}
+
+static struct sway_container *container_output_destroy(struct sway_container *output) {
+ if (!sway_assert(output, "cannot destroy null output")) {
+ return NULL;
+ }
+
+ if (output->children->length > 0) {
+ // TODO save workspaces when there are no outputs.
+ // TODO also check if there will ever be no outputs except for exiting
+ // program
+ if (root_container.children->length > 1) {
+ int p = root_container.children->items[0] == output;
+ // Move workspace from this output to another output
+ while (output->children->length) {
+ struct sway_container *child = output->children->items[0];
+ container_remove_child(child);
+ container_add_child(root_container.children->items[p], child);
+ }
+ container_sort_workspaces(root_container.children->items[p]);
+ arrange_windows(root_container.children->items[p],
+ -1, -1);
+ }
+ }
+
+ wl_list_remove(&output->sway_output->destroy.link);
+ wl_list_remove(&output->sway_output->mode.link);
+ wl_list_remove(&output->sway_output->transform.link);
+ wl_list_remove(&output->sway_output->scale.link);
+
+ wl_list_remove(&output->sway_output->damage_destroy.link);
+ wl_list_remove(&output->sway_output->damage_frame.link);
+
+ wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
+ container_finish(output);
+ return &root_container;
+}
+
static struct sway_container *container_workspace_destroy(
struct sway_container *workspace) {
if (!sway_assert(workspace, "cannot destroy null workspace")) {