From 942de89562f363afcd4a399dcd55c64792fd5b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 11 Mar 2022 12:00:12 +0100 Subject: [PATCH] Fix high-dpi and QScreen state initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix bug where QScreen::geometry() returns incorrect (unscaled) geometry. We maintain state: - QHighDpiScaling::m_active, which is set to true if any screen in QGuiApplication::screens() has a scale factor > 1, in updateHighDpiScaling() - QScreen::m_geometry, which is assigned the scaled screen size in QScreenPrivate::updateHighDpi() Now the problem is that updateHighDpiScaling() requires an up-to date screens list, and that updateHighDpi() requires an up-to date m_active, and that currently updateHighDpi() is called when constructing the QScreen only. This is all a bit unsatisfactory, but for now fix this in the simplest way by adding a second call to updateHighDpi() in handleScreenAdded(), after the call to updateHighDpiScaling(). Pick-to: 6.2 6.3 Fixes-number: QTBUG-101601 Change-Id: I5f442ceb966c77d6746ee885203b67da96612587 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindowsysteminterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d66cefb2a97..9410b2fb9df 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -43,6 +43,7 @@ #include "private/qevent_p.h" #include "private/qeventpoint_p.h" #include "private/qpointingdevice_p.h" +#include "private/qscreen_p.h" #include #include #include @@ -785,6 +786,7 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima QGuiApplicationPrivate::resetCachedDevicePixelRatio(); QHighDpiScaling::updateHighDpiScaling(); + screen->d_func()->updateHighDpi(); emit qGuiApp->screenAdded(screen);