From db8dacf76e9a05c1f1172643f8203f7cc4db8c0b Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Sat, 7 May 2016 12:19:45 +0200 Subject: [PATCH] handlers: Tiny rework of output_destroyed logic Signed-off-by: Quentin Glidic --- sway/handlers.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sway/handlers.c b/sway/handlers.c index 67275575a..3ac3c494c 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -97,14 +97,17 @@ static void handle_output_destroyed(wlc_handle output) { break; } } - if (i < list->length) { - destroy_output(list->items[i]); - } else { + if (i == list->length) { + // No container for this output, we're done return; } + + destroy_output(list->items[i]); + if (list->length > 0) { + swayc_t *c = (swayc_t *)list->items[0]; // switch to other outputs active workspace - workspace_switch(((swayc_t *)root_container.children->items[0])->focused); + workspace_switch(c->focused); } }