From d6b9d00cebaf2f57cf7e6c5d1730920f3b058822 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 24 Feb 2018 22:18:39 +0100 Subject: [PATCH] Wayland: Handle monitor removal --- src/wl_init.c | 12 ++++++++++++ src/wl_monitor.c | 1 + src/wl_platform.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index 0656fccd..3291fd5f 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -585,6 +585,18 @@ static void registryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name) { + int i; + _GLFWmonitor* monitor; + + for (i = 0; i < _glfw.monitorCount; ++i) + { + monitor = _glfw.monitors[i]; + if (monitor->wl.name == name) + { + _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0); + return; + } + } } diff --git a/src/wl_monitor.c b/src/wl_monitor.c index ed351e76..5598de34 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -136,6 +136,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) monitor->wl.scale = 1; monitor->wl.output = output; + monitor->wl.name = name; wl_output_add_listener(output, &outputListener, monitor); } diff --git a/src/wl_platform.h b/src/wl_platform.h index 6c82a936..5a130788 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -284,6 +284,7 @@ typedef struct _GLFWlibraryWayland typedef struct _GLFWmonitorWayland { struct wl_output* output; + int name; int currentMode; int x;