Changeset View
Changeset View
Standalone View
Standalone View
3rdparty/ext_qt/0033-Move-QT_FONT_DPI-to-cross-platform-code.patch
- This file was added.
1 | From 3f00c3cddb35c4f17100b2becbb99dec4e48b351 Mon Sep 17 00:00:00 2001 | ||||
---|---|---|---|---|---|
2 | From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> | ||||
3 | Date: Thu, 2 Jun 2016 09:52:21 +0200 | ||||
4 | Subject: [PATCH 33/36] Move QT_FONT_DPI to cross-platform code | ||||
5 | | ||||
6 | This makes it possible to test the effects of setting | ||||
7 | Qt::AA_HighDpiScaling/QT_AUTO_SCREEN_SCALE_FACTOR, with different DPI | ||||
8 | values on all platforms. | ||||
9 | | ||||
10 | This also makes it possible to access the actual DPI values reported | ||||
11 | by the OS/WS via the QPlatformScreen API. | ||||
12 | | ||||
13 | A drawback is that there is no single place to check the environment | ||||
14 | variable; currently done in three places. This may be | ||||
15 | further simplified later on. | ||||
16 | | ||||
17 | Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> | ||||
18 | Task-number: QTBUG-53022 | ||||
19 | Change-Id: Idd6463219d3ae58fe0ab72c17686cce2eb9dbadd | ||||
20 | --- | ||||
21 | src/gui/kernel/qhighdpiscaling.cpp | 4 ++-- | ||||
22 | src/gui/kernel/qplatformscreen.cpp | 8 ++++++++ | ||||
23 | src/gui/kernel/qplatformscreen.h | 2 ++ | ||||
24 | src/gui/kernel/qscreen.cpp | 7 +++++-- | ||||
25 | src/gui/kernel/qwindowsysteminterface.cpp | 4 ++-- | ||||
26 | src/plugins/platforms/xcb/qxcbscreen.cpp | 4 ---- | ||||
27 | 6 files changed, 19 insertions(+), 10 deletions(-) | ||||
28 | | ||||
29 | diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp | ||||
30 | index ae531569ce..fc8084c45a 100644 | ||||
31 | --- a/src/gui/kernel/qhighdpiscaling.cpp | ||||
32 | +++ b/src/gui/kernel/qhighdpiscaling.cpp | ||||
33 | @@ -274,7 +274,7 @@ qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen) | ||||
34 | qreal platformPhysicalDpi = screen->screen()->physicalDotsPerInch(); | ||||
35 | factor = qreal(platformPhysicalDpi) / qreal(platformBaseDpi.first); | ||||
36 | } else { | ||||
37 | - QDpi platformLogicalDpi = screen->logicalDpi(); | ||||
38 | + const QDpi platformLogicalDpi = QPlatformScreen::overrideDpi(screen->logicalDpi()); | ||||
39 | factor = qreal(platformLogicalDpi.first) / qreal(platformBaseDpi.first); | ||||
40 | } | ||||
41 | | ||||
42 | @@ -587,7 +587,7 @@ QDpi QHighDpiScaling::logicalDpi(const QScreen *screen) | ||||
43 | return QDpi(96, 96); | ||||
44 | | ||||
45 | if (!m_usePixelDensity) | ||||
46 | - return screen->handle()->logicalDpi(); | ||||
47 | + return QPlatformScreen::overrideDpi(screen->handle()->logicalDpi()); | ||||
48 | | ||||
49 | const qreal scaleFactor = rawScaleFactor(screen->handle()); | ||||
50 | const qreal roundedScaleFactor = roundScaleFactor(scaleFactor); | ||||
51 | diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp | ||||
52 | index 07a2231228..54ec211f2c 100644 | ||||
53 | --- a/src/gui/kernel/qplatformscreen.cpp | ||||
54 | +++ b/src/gui/kernel/qplatformscreen.cpp | ||||
55 | @@ -194,6 +194,14 @@ QDpi QPlatformScreen::logicalDpi() const | ||||
56 | 25.4 * s.height() / ps.height()); | ||||
57 | } | ||||
58 | | ||||
59 | +// Helper function for accessing the platform screen logical dpi | ||||
60 | +// which accounts for QT_FONT_DPI. | ||||
61 | +QPair<qreal, qreal> QPlatformScreen::overrideDpi(const QPair<qreal, qreal> &in) | ||||
62 | +{ | ||||
63 | + static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI"); | ||||
64 | + return overrideDpi > 0 ? QDpi(overrideDpi, overrideDpi) : in; | ||||
65 | +} | ||||
66 | + | ||||
67 | /*! | ||||
68 | Reimplement to return the base logical DPI for the platform. This | ||||
69 | DPI value should correspond to a standard-DPI (1x) display. The | ||||
70 | diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h | ||||
71 | index 63b5d5a4a7..32e6bf7ec7 100644 | ||||
72 | --- a/src/gui/kernel/qplatformscreen.h | ||||
73 | +++ b/src/gui/kernel/qplatformscreen.h | ||||
74 | @@ -159,6 +159,8 @@ public: | ||||
75 | // The platform screen's geometry in device independent coordinates | ||||
76 | QRect deviceIndependentGeometry() const; | ||||
77 | | ||||
78 | + static QDpi overrideDpi(const QDpi &in); | ||||
79 | + | ||||
80 | protected: | ||||
81 | void resizeMaximizedWindows(); | ||||
82 | | ||||
83 | diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp | ||||
84 | index 82ee62e6b4..b856435f67 100644 | ||||
85 | --- a/src/gui/kernel/qscreen.cpp | ||||
86 | +++ b/src/gui/kernel/qscreen.cpp | ||||
87 | @@ -84,8 +84,11 @@ void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) | ||||
88 | platformScreen->d_func()->screen = q; | ||||
89 | orientation = platformScreen->orientation(); | ||||
90 | geometry = platformScreen->deviceIndependentGeometry(); | ||||
91 | - availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft()); | ||||
92 | - logicalDpi = platformScreen->logicalDpi(); | ||||
93 | + availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), | ||||
94 | + QHighDpiScaling::factor(platformScreen), geometry.topLeft()); | ||||
95 | + | ||||
96 | + logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi()); | ||||
97 | + | ||||
98 | refreshRate = platformScreen->refreshRate(); | ||||
99 | // safeguard ourselves against buggy platform behavior... | ||||
100 | if (refreshRate < 1.0) | ||||
101 | diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp | ||||
102 | index 5b32405f5e..0bedae1bb4 100644 | ||||
103 | --- a/src/gui/kernel/qwindowsysteminterface.cpp | ||||
104 | +++ b/src/gui/kernel/qwindowsysteminterface.cpp | ||||
105 | @@ -780,8 +780,8 @@ void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const Q | ||||
106 | | ||||
107 | void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal dpiX, qreal dpiY) | ||||
108 | { | ||||
109 | - QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e = | ||||
110 | - new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, dpiX, dpiY); // ### tja | ||||
111 | + const QDpi effectiveDpi = QPlatformScreen::overrideDpi(QDpi{dpiX, dpiY}); | ||||
112 | + auto e = new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, effectiveDpi.first, effectiveDpi.second); | ||||
113 | QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); | ||||
114 | } | ||||
115 | | ||||
116 | diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp | ||||
117 | index 9af0794d29..27ffcad902 100644 | ||||
118 | --- a/src/plugins/platforms/xcb/qxcbscreen.cpp | ||||
119 | +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp | ||||
120 | @@ -660,10 +660,6 @@ QImage::Format QXcbScreen::format() const | ||||
121 | | ||||
122 | QDpi QXcbScreen::logicalDpi() const | ||||
123 | { | ||||
124 | - static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI"); | ||||
125 | - if (overrideDpi) | ||||
126 | - return QDpi(overrideDpi, overrideDpi); | ||||
127 | - | ||||
128 | const int forcedDpi = m_virtualDesktop->forcedDpi(); | ||||
129 | if (forcedDpi > 0) { | ||||
130 | return QDpi(forcedDpi, forcedDpi); | ||||
131 | -- | ||||
132 | 2.18.0.windows.1 | ||||
133 | |