From e846bc9308aa35c3ae2146acc5ee61bea42bbf8c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 Jun 2019 12:40:02 +0530 Subject: [PATCH] Wayland: Fix crash when enabling disabling monitors on sway When an output is unregistered, the corresponding monitor object should be removed from every windows' monitor list Proper fix for #1696 --- docs/changelog.rst | 2 ++ glfw/wl_init.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2e9ed45b8..048bba52e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -43,6 +43,8 @@ To update |kitty|, :doc:`follow the instructions `. server side window decorations, such a GNOME or Weston not working correctly (:iss:`1659`) +- Wayland: Fix crash when enabling disabling monitors on sway (:iss:`1696`) + 0.14.1 [2019-05-29] --------------------- diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 27ef32d75..34e5160a0 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -613,14 +613,20 @@ static void registryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) { - int i; _GLFWmonitor* monitor; - for (i = 0; i < _glfw.monitorCount; ++i) + for (int i = 0; i < _glfw.monitorCount; ++i) { monitor = _glfw.monitors[i]; if (monitor->wl.name == name) { + for (_GLFWwindow *window = _glfw.windowListHead; window; window = window->next) { + for (int m = window->wl.monitorsCount - 1; m >= 0; m--) { + if (window->wl.monitors[m] == monitor) { + remove_i_from_array(window->wl.monitors, m, window->wl.monitorsCount); + } + } + } _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0); return; }