From 2832a73285d48492e3e1516338e660d9c1f42f96 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Wed, 14 Oct 2020 14:43:40 +0200 Subject: [PATCH] GLFW: Wayland: Assume 96 DPI if physical size is <= 0 From upstream: https://github.com/glfw/glfw/commit/0ef149c8f2451fbc8e866834675a075cfc295b6c. --- glfw/wl_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 12d41af0f..c14934a2f 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -717,6 +717,9 @@ glfwWaylandCheckForServerSideDecorations(void) { int _glfwPlatformInit(void) { + int i; + _GLFWmonitor* monitor; + _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) { @@ -768,6 +771,17 @@ int _glfwPlatformInit(void) // Sync so we got all initial output events wl_display_roundtrip(_glfw.wl.display); + for (i = 0; i < _glfw.monitorCount; ++i) + { + monitor = _glfw.monitors[i]; + if (monitor->widthMM <= 0 || monitor->heightMM <= 0) + { + // If Wayland does not provide a physical size, assume the default 96 DPI + monitor->widthMM = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f); + monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f); + } + } + if (!_glfw.wl.wmBase) { _glfwInputError(GLFW_PLATFORM_ERROR,