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; }