From 65fa7da24a3a7e82ecab5175866ed667317abc0d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Nov 2019 10:00:41 +0530 Subject: [PATCH] Wayland: Use the primary monitor scale for windows on creation This is needed because on creation the window may not have been assigned to any monitors, so we fallback to using the scale of the primary monitor. Fixes #2133. Fixes #2135 --- glfw/wl_window.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 73261a9f9..05a09d1b6 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -55,13 +55,18 @@ static bool checkScaleChange(_GLFWwindow* window) if (_glfw.wl.compositorVersion < 3) return false; - // Get the scale factor from the highest scale monitor. + // Get the scale factor from the highest scale monitor that this window is on for (i = 0; i < window->wl.monitorsCount; ++i) { monitorScale = window->wl.monitors[i]->wl.scale; if (scale < monitorScale) scale = monitorScale; } + if (window->wl.monitorsCount < 1 && _glfw.monitorCount > 0) { + // The window has not yet been assigned to any monitors, use the primary monitor + _GLFWmonitor *m = _glfw.monitors[0]; + if (m && m->wl.scale > scale) scale = m->wl.scale; + } // Only change the framebuffer size if the scale changed. if (scale != window->wl.scale)