summaryrefslogtreecommitdiff
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authorTony Crisci <[email protected]>2018-03-30 16:16:12 -0400
committerGitHub <[email protected]>2018-03-30 16:16:12 -0400
commit7e0d430a0cee8c24fd4461711f264829b0f67e2e (patch)
treed55cdd62bd7470ff67953613c25a3a9b85182f50 /sway/tree/output.c
parentcf09ea184b891594331240eb860f28975dcb8b8c (diff)
parent7eca02301ba309fa909ba9b12cb335f8f944f1ee (diff)
Merge branch 'wlroots' into wlroots-xwayland-map
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 @@
+#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->frame.link);
+ wl_list_remove(&output->sway_output->destroy.link);
+ wl_list_remove(&output->sway_output->mode.link);
+
+ wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
+ container_destroy(output);
+ return &root_container;
+}