diff options
author | Tor Arne Vestbø <[email protected]> | 2022-09-07 21:13:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <[email protected]> | 2023-03-28 17:31:17 +0200 |
commit | 2187936978c93e73c86119e8ef99625e9f2b4109 (patch) | |
tree | b83c4aa17daa90db09e31176c7534ff95ce4fbc0 | |
parent | c4debab927671de802d377f31e4fff4136da9104 (diff) |
Remove indirection via QScreenPrivate::setPlatformScreen()
The QHighDpiScaling code should call the explicit updateGeometry
function instead to re-evaluate the platform screen geometry in
light of the change to the scale factor.
Change-Id: Idac975c117c431356f4fb812c245348c4722a8b5
Reviewed-by: Morten Johan Sørvig <[email protected]>
Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 26 | ||||
-rw-r--r-- | src/gui/kernel/qscreen_p.h | 1 |
4 files changed, 12 insertions, 21 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index d0d2a5a1191..f20bd842637 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -574,9 +574,7 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor) else QHighDpiScaling::m_namedScreenScaleFactors.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()->updateGeometry(); } QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen) diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index 3ef5798aa16..de704f46357 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -132,7 +132,7 @@ protected: QScopedPointer<QPlatformScreenPrivate> d_ptr; private: - friend class QScreenPrivate; + friend class QScreen; }; // Qt doesn't currently support running with no platform screen diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 3932567eaea..d4e94a98a1e 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -37,29 +37,23 @@ QT_BEGIN_NAMESPACE \inmodule QtGui */ -QScreen::QScreen(QPlatformScreen *screen) +QScreen::QScreen(QPlatformScreen *platformScreen) : QObject(*new QScreenPrivate(), nullptr) { Q_D(QScreen); - d->setPlatformScreen(screen); -} - -void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen) -{ - Q_Q(QScreen); - platformScreen = screen; - platformScreen->d_func()->screen = q; - orientation = platformScreen->orientation(); - logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi()); + d->platformScreen = platformScreen; + platformScreen->d_func()->screen = this; - refreshRate = platformScreen->refreshRate(); + d->orientation = platformScreen->orientation(); + d->logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi()); + d->refreshRate = platformScreen->refreshRate(); // safeguard ourselves against buggy platform behavior... - if (refreshRate < 1.0) - refreshRate = 60.0; + if (d->refreshRate < 1.0) + d->refreshRate = 60.0; - updateGeometry(); - updatePrimaryOrientation(); // derived from the geometry + d->updateGeometry(); + d->updatePrimaryOrientation(); // derived from the geometry } void QScreenPrivate::updateGeometry() diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index b9e726a9dce..964bc1cc58d 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -40,7 +40,6 @@ class QScreenPrivate : public QObjectPrivate, public QScreenData { Q_DECLARE_PUBLIC(QScreen) public: - void setPlatformScreen(QPlatformScreen *screen); void updateGeometry(); void updatePrimaryOrientation(); |