aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h2
-rw-r--r--sway/config/output.c2
-rw-r--r--sway/desktop/output.c4
-rw-r--r--sway/tree/container.c37
-rw-r--r--sway/tree/output.c36
5 files changed, 40 insertions, 41 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index 278505ce..c6393dc0 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -133,8 +133,6 @@ struct sway_container *container_destroy(struct sway_container *container);
// TODO make me private
struct sway_container *container_finish(struct sway_container *cont);
-struct sway_container *container_output_destroy(struct sway_container *container);
-
struct sway_container *container_close(struct sway_container *container);
// TODO move to layout.c
diff --git a/sway/config/output.c b/sway/config/output.c
index b4e56efa..c4b74ce2 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -127,7 +127,7 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
if (oc && oc->enabled == 0) {
wlr_output_layout_remove(root_container.sway_root->output_layout,
wlr_output);
- container_output_destroy(output);
+ container_destroy(output);
return;
}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 10ed1f6d..a1f89cf9 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -338,12 +338,12 @@ void output_damage_whole_view(struct sway_output *output,
static void damage_handle_destroy(struct wl_listener *listener, void *data) {
struct sway_output *output =
wl_container_of(listener, output, damage_destroy);
- container_output_destroy(output->swayc);
+ container_destroy(output->swayc);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
struct sway_output *output = wl_container_of(listener, output, destroy);
- container_output_destroy(output->swayc);
+ container_destroy(output->swayc);
}
static void handle_mode(struct wl_listener *listener, void *data) {
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")) {
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 0509db23..af17b856 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -4,42 +4,6 @@
#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->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_destroy(output);
- return &root_container;
-}
-
struct sway_container *output_by_name(const char *name) {
for (int i = 0; i < root_container.children->length; ++i) {
struct sway_container *output = root_container.children->items[i];