From ec2fd6e5c0217ae58a03eca1e83d85f02c739643 Mon Sep 17 00:00:00 2001
From: emersion <contact@emersion.fr>
Date: Wed, 13 Dec 2017 21:47:37 +0100
Subject: Handle output remove

---
 sway/desktop/output.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

(limited to 'sway/desktop')

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);
 }
-- 
cgit v1.2.3