From 0ef149c8f2451fbc8e866834675a075cfc295b6c Mon Sep 17 00:00:00 2001 From: Nicolas Caramelli Date: Wed, 14 Oct 2020 10:25:46 +0200 Subject: [PATCH] Wayland: Assume 96 DPI if physical size is <= 0 --- src/wl_init.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index 21a808aa..d3e777d4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1038,6 +1038,8 @@ int _glfwPlatformInit(void) char *cursorSizeEnd; long cursorSizeLong; int cursorSize; + int i; + _GLFWmonitor* monitor; _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) @@ -1146,6 +1148,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); + } + } + _glfwInitTimerPOSIX(); _glfw.wl.timerfd = -1;