From d6072f6218cbe15f6a79d6d2c458794e91bb8890 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 21 Nov 2019 18:37:08 +0100 Subject: [PATCH] X11: Assume 96 DPI if RandR monitor size is zero From upstream: https://github.com/glfw/glfw/commit/e96dc5d2199032d565b55c4177820ab28b1d67c9. --- glfw/x11_monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/glfw/x11_monitor.c b/glfw/x11_monitor.c index 0b5574dd3..85c08fb5d 100644 --- a/glfw/x11_monitor.c +++ b/glfw/x11_monitor.c @@ -166,6 +166,16 @@ void _glfwPollMonitorsX11(void) heightMM = oi->mm_height; } + if (widthMM <= 0 || heightMM <= 0) + { + // HACK: If RandR does not provide a physical size, assume the + // X11 default 96 DPI and calcuate from the CRTC viewport + // NOTE: These members are affected by rotation, unlike the mode + // info and output info members + widthMM = (int) (ci->width * 25.4f / 96.f); + heightMM = (int) (ci->height * 25.4f / 96.f); + } + _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); monitor->x11.output = sr->outputs[i]; monitor->x11.crtc = oi->crtc;