aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-13 21:47:37 +0100
committeremersion <contact@emersion.fr>2017-12-13 21:47:37 +0100
commitec2fd6e5c0217ae58a03eca1e83d85f02c739643 (patch)
treeff2a84f28a9ea88f698d5099e430e665f801d1f7 /sway
parenta4619e98c462690f14baf5c0c72c25553e3c6d51 (diff)
Handle output remove
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/output.c16
-rw-r--r--sway/tree/layout.c6
2 files changed, 21 insertions, 1 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 2177ad74..ad843b31 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -123,5 +123,19 @@ void output_remove_notify(struct wl_listener *listener, void *data) {
struct sway_server *server = wl_container_of(listener, server, output_remove);
struct wlr_output *wlr_output = data;
sway_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
- // TODO
+
+ swayc_t *output_container = NULL;
+ for (int i = 0 ; i < root_container.children->length; ++i) {
+ swayc_t *child = root_container.children->items[i];
+ if (child->type == C_OUTPUT &&
+ child->sway_output->wlr_output == wlr_output) {
+ output_container = child;
+ break;
+ }
+ }
+ if (!output_container) {
+ return;
+ }
+
+ destroy_output(output_container);
}
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 65382231..4bcf0e2f 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -23,10 +23,16 @@ static void output_layout_change_notify(struct wl_listener *listener, void *data
for (int i = 0 ; i < root_container.children->length; ++i) {
swayc_t *output_container = root_container.children->items[i];
+ if (output_container->type != C_OUTPUT) {
+ continue;
+ }
struct sway_output *output = output_container->sway_output;
struct wlr_box *output_box = wlr_output_layout_get_box(
root_container.sway_root->output_layout, output->wlr_output);
+ if (!output_box) {
+ continue;
+ }
output_container->x = output_box->x;
output_container->y = output_box->y;
output_container->width = output_box->width;