From 2fd5a9ee8de1ab33d1504821b582b96d6dfd2d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 28 Apr 2020 19:05:10 +0200 Subject: [PATCH] wayland: monitor unplug: call surface_leave() to handle terminal unmapping --- wayland.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/wayland.c b/wayland.c index e9969882..594e78cd 100644 --- a/wayland.c +++ b/wayland.c @@ -676,33 +676,26 @@ monitor_destroy(struct monitor *mon) static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) { - LOG_DBG("global removed: %u", name); + LOG_DBG("global removed: 0x%08x", name); struct wayland *wayl = data; /* For now, we only support removal of outputs */ tll_foreach(wayl->monitors, it) { - if (it->item.wl_name != name) + struct monitor *mon = &it->item; + + if (mon->wl_name != name) continue; - LOG_INFO("monitor unplugged: %s", it->item.name); + LOG_INFO("monitor unplugged: %s", mon->name); /* * Update all terminals that are mapped here. On Sway 1.4, * surfaces are *not* unmapped before the output is removed */ - tll_foreach(wayl->terms, t) { - tll_foreach(t->item->window->on_outputs, o) { - if (o->item != &it->item) - continue; - - /* Remove terminal from this output */ - tll_remove(t->item->window->on_outputs, o); - update_term_for_output_change(t->item); - break; - } - } + tll_foreach(wayl->terms, t) + surface_leave(t->item->window, NULL /* wl_surface - unused */, mon->output); monitor_destroy(&it->item); tll_remove(wayl->monitors, it);