From 0c22ebac36d08e47629c92e13c1824cb726ad84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Feb 2021 21:33:23 +0100 Subject: [PATCH] Wayland: Move DPI fallback work to output done This removes the dependency on the (unspecified) ordering of geometry and mode events in wl_output. Based on feedback from @linkmauve and @caramelli. Related to #1792. (cherry picked from commit b925a54ef11adab250e4e9592afe918c1f8caebb) --- src/wl_monitor.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 48b25b9f..a7b05c60 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -88,6 +88,14 @@ static void outputHandleDone(void* data, struct wl_output* output) { struct _GLFWmonitor *monitor = data; + if (monitor->widthMM <= 0 || monitor->heightMM <= 0) + { + // If Wayland does not provide a physical size, assume the default 96 DPI + const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode]; + monitor->widthMM = (int) (mode->width * 25.4f / 96.f); + monitor->heightMM = (int) (mode->height * 25.4f / 96.f); + } + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); }