summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qscreen.cpp
diff options
context:
space:
mode:
authorFushan Wen <[email protected]>2022-05-29 19:08:17 +0800
committerFushan Wen <[email protected]>2022-06-29 20:44:32 +0800
commit7b2ae3faab15913e006ece25d785e6a8453dd27a (patch)
tree2003744b64c3ce591c1a11d4a7679615c7369780 /src/gui/kernel/qscreen.cpp
parent9fcd5f0790fd01307cfece96d82df21c787fa5b3 (diff)
Drop call to setPlatformScreen in QHighDpiScaling::setScreenFactor
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ø <[email protected]>
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r--src/gui/kernel/qscreen.cpp40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index fd0e2ba2f77..ac33185900d 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -41,7 +41,26 @@ QScreen::QScreen(QPlatformScreen *screen)
: QObject(*new QScreenPrivate(), nullptr)
{
Q_D(QScreen);
- d->setPlatformScreen(screen);
+ d->platformScreen = screen;
+ d->platformScreen->d_func()->screen = this;
+ d->orientation = d->platformScreen->orientation();
+
+ d->logicalDpi = QPlatformScreen::overrideDpi(d->platformScreen->logicalDpi());
+
+ d->refreshRate = d->platformScreen->refreshRate();
+ // safeguard ourselves against buggy platform behavior...
+ if (d->refreshRate < 1.0)
+ d->refreshRate = 60.0;
+
+ d->updateHighDpi();
+ d->updatePrimaryOrientation(); // derived from the geometry
+}
+
+void QScreenPrivate::updateLogicalDpi()
+{
+ Q_Q(QScreen);
+ logicalDpi = QPlatformScreen::overrideDpi(q->handle()->logicalDpi());
+ updateGeometriesWithSignals(); // updates geometries based on scale factor
}
void QScreenPrivate::updateGeometriesWithSignals()
@@ -71,25 +90,6 @@ void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availa
emit q->physicalDotsPerInchChanged(q->physicalDotsPerInch());
}
-void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
-{
- Q_Q(QScreen);
- platformScreen = screen;
- platformScreen->d_func()->screen = q;
- orientation = platformScreen->orientation();
-
- logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
-
- refreshRate = platformScreen->refreshRate();
- // safeguard ourselves against buggy platform behavior...
- if (refreshRate < 1.0)
- refreshRate = 60.0;
-
- updateHighDpi();
- updatePrimaryOrientation(); // derived from the geometry
-}
-
-
/*!
Destroys the screen.
*/