From 776734576c2ba7bd4bdba6e09bc5dad5e093670a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 16 Mar 2021 17:17:53 +0100 Subject: Call updateHighDpiScaling() on screenAdded() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QHighDpiScaling has two init/update functions: - initHighDpiScaling(): called once during QGuiApplication construction - updateHighDpiScaling(): called whenever (relevant) screen configuration changes Currently the calls to updateHighDpiScaling() are made from multiple places including platform code. Simplify by calling it from two locations: - QWindowSystemInterface::handleScreenAdded() - QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange() Replace comment about early calls to qt_defaultDpi with a test which calls qt_defaultDpiX/Y with no screens attached. (Looking at the qt_defaultDpiX() implementation, it is unlikely that there will be a problem as long as updateHighDpiScaling() is called before QGuiApplication::primaryScreen() starts returning a non-null value.) Change-Id: I447db42894617495843a5cb531a1322b000fed62 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/gui/kernel/qguiapplication.cpp') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 247d9a8d1b..114beb6dde 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -153,8 +153,6 @@ Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationI Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; -bool QGuiApplicationPrivate::highDpiScalingUpdated = false; - QPointer QGuiApplicationPrivate::currentDragWindow; QList QGuiApplicationPrivate::tabletDevicePoints; // TODO remove @@ -709,7 +707,6 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::lastCursorPosition = {qreal(qInf()), qreal(qInf())}; QGuiApplicationPrivate::currentMousePressWindow = QGuiApplicationPrivate::currentMouseWindow = nullptr; QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; - QGuiApplicationPrivate::highDpiScalingUpdated = false; QGuiApplicationPrivate::currentDragWindow = nullptr; QGuiApplicationPrivate::tabletDevicePoints.clear(); } @@ -1245,13 +1242,6 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString return; } - // Many platforms have created QScreens at this point. Finish initializing - // QHighDpiScaling to be prepared for early calls to qt_defaultDpi(). - if (QGuiApplication::primaryScreen()) { - QGuiApplicationPrivate::highDpiScalingUpdated = true; - QHighDpiScaling::updateHighDpiScaling(); - } - // Create the platform theme: // 1) Fetch the platform name from the environment if present. @@ -1526,11 +1516,6 @@ void QGuiApplicationPrivate::eventDispatcherReady() createPlatformIntegration(); platform_integration->initialize(); - - // All platforms should have added screens at this point. Finish - // QHighDpiScaling initialization if it has not been done so already. - if (!QGuiApplicationPrivate::highDpiScalingUpdated) - QHighDpiScaling::updateHighDpiScaling(); } void QGuiApplicationPrivate::init() -- cgit v1.2.3