/
0045-Drop-call-to-setPlatformScreen-in-QHighDpiScaling-se.patch
77 lines (67 loc) · 2.94 KB
/
0045-Drop-call-to-setPlatformScreen-in-QHighDpiScaling-se.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 1538258943cbaa34d68067507f7487df45cb07c8 Mon Sep 17 00:00:00 2001
From: Fushan Wen <qydwhotmail@gmail.com>
Date: Wed, 29 Jun 2022 19:39:40 +0800
Subject: [PATCH 045/144] Drop call to setPlatformScreen in
QHighDpiScaling::setScreenFactor
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Drop call to setPlatformScreen since the only affected variables are
logicalDpi and geometry. Replace setPlatformScreen with updateLogicalDpi
which handles global scale factor changes in QScreen.
Call updateGeometriesWithSignals() to check if there are any changes
in geometry or availableGeometry, since the geometry or availableGeometry
can also change when setting a scale factor.
Move setPlatformScreen to QScreen ctor as the function is not used
elsewhere.
Pick-to: 6.4 6.3 6.2
Change-Id: I7acf40bf0643e89a1d9177674d66dc503829f98f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 7b2ae3faab15913e006ece25d785e6a8453dd27a)
---
src/gui/kernel/qhighdpiscaling.cpp | 3 +--
src/gui/kernel/qscreen.cpp | 6 ++++++
src/gui/kernel/qscreen_p.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 85ff58c14c..a433e94c22 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
else
qNamedScreenScaleFactors()->insert(name, factor);
- // hack to force re-evaluation of screen geometry
if (screen->handle())
- screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
+ screen->d_func()->updateLogicalDpi();
}
QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 990272b0c2..d371dd60ab 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
d->setPlatformScreen(screen);
}
+void QScreenPrivate::updateLogicalDpi()
+{
+ logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
+ updateGeometriesWithSignals(); // updates geometries based on scale factor
+}
+
void QScreenPrivate::updateGeometriesWithSignals()
{
const QRect oldGeometry = geometry;
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 7da542c25e..e50fc3190b 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -70,6 +70,7 @@ public:
geometry = platformScreen->deviceIndependentGeometry();
availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
}
+ void updateLogicalDpi();
void updatePrimaryOrientation();
void updateGeometriesWithSignals();
--
2.43.0