File highdpi-0008-fix-QHighDPiScaling-initialization-issues.patch of Package libqt5-qtbase.2170
From 45bb9c29e8b70cd15b01d8ab18d1df7f9707c215 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?=
<morten.sorvig@theqtcompany.com>
Date: Fri, 2 Oct 2015 15:56:04 +0200
Subject: [PATCH] Fix QHighDPiScaling initialization issues
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Call QHighDpiScaling::updateHighDpiScaling() in init_plaform(),
after the platform integration has been created and most platforms
have populated the screen list. Keep the existing udpate call for
the platforms that don't, but guard against calling it twice.
Task-number: QTBUG-47947
Change-Id: Ib73bea7c4ab42e7acf6532f3a3100e1fc29acc2c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
---
src/gui/kernel/qguiapplication.cpp | 16 +++++++++++++---
src/gui/kernel/qguiapplication_p.h | 1 +
2 files changed, 14 insertions(+), 3 deletions(-)
Index: b/src/gui/kernel/qguiapplication.cpp
===================================================================
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -126,6 +126,8 @@ QWindow *QGuiApplicationPrivate::current
Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
+bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
+
QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0;
@@ -1041,6 +1043,13 @@ static void init_platform(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.
@@ -1211,6 +1220,11 @@ void QGuiApplicationPrivate::eventDispat
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()
Index: b/src/gui/kernel/qguiapplication_p.h
===================================================================
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -202,6 +202,7 @@ public:
static QWindow *currentMouseWindow;
static QWindow *currentMousePressWindow;
static Qt::ApplicationState applicationState;
+ static bool highDpiScalingUpdated;
#ifndef QT_NO_CLIPBOARD
static QClipboard *qt_clipboard;