diff options
author | emersion <contact@emersion.fr> | 2018-03-30 19:04:06 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-03-30 19:04:06 -0400 |
commit | 96656427656118f2e4d725359cc880270b0e51be (patch) | |
tree | e2596e9cfa113efa43f2a411176c31e6208a58b1 /sway/tree/output.c | |
parent | 6c9d67b1059409750de683aec3b8b9be2da987cc (diff) | |
parent | 1b88eaee6b14987c585fcf149cc26f665c584d77 (diff) | |
download | sway-96656427656118f2e4d725359cc880270b0e51be.tar.xz |
Merge branch 'wlroots' into client-cursors
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c new file mode 100644 index 00000000..7248fd00 --- /dev/null +++ b/sway/tree/output.c @@ -0,0 +1,39 @@ +#include "sway/tree/container.h" +#include "sway/tree/layout.h" +#include "sway/output.h" +#include "log.h" + +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->damage_destroy.link); + wl_list_remove(&output->sway_output->damage_frame.link); + + wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name); + container_destroy(output); + return &root_container; +} |