summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-12-03 09:21:43 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-05 22:01:36 +0200
commit5290027e3bab75f14fc0a2b7c206594d9cb91e76 (patch)
tree02dca4b645613a68ebc7bff01df65021d251507d
parent0ef6b3d138d5d3e7199d65cb7c6b0042f9437884 (diff)
Emit QScreen::(availableG|g)eometryChanged() on logical DPI change
When a change in logical DPI occurs due to the user changing the scaling factor, the screen size in device independent pixels may change due to High DPI choosing a different scale factor. Factor out the commonly used code into QScreenPrivate methods and use them from QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange(). Pick-to: 5.15 Task-number: QTBUG-76902 Task-number: QTBUG-79248 Change-Id: I241a0f52d8236a65084d501fb4d8f9faeea89c0f Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/gui/kernel/qguiapplication.cpp10
-rw-r--r--src/gui/kernel/qscreen.cpp24
-rw-r--r--src/gui/kernel/qscreen_p.h2
3 files changed, 25 insertions, 11 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 8e50cbc469..356f9fb11a 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -3131,14 +3131,7 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP
updateFilteredScreenOrientation(s);
}
- if (availableGeometryChanged)
- emit s->availableGeometryChanged(s->availableGeometry());
-
- if (geometryChanged || availableGeometryChanged) {
- const auto siblings = s->virtualSiblings();
- for (QScreen* sibling : siblings)
- emit sibling->virtualGeometryChanged(sibling->virtualGeometry());
- }
+ s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged);
resetCachedDevicePixelRatio();
}
@@ -3156,6 +3149,7 @@ void QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange(QWindowSystem
s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY);
emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
+ s->d_func()->updateGeometriesWithSignals();
resetCachedDevicePixelRatio();
}
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index d5a4b7c027..df628fcc73 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -77,15 +77,33 @@ QScreen::QScreen(QPlatformScreen *screen)
d->setPlatformScreen(screen);
}
+void QScreenPrivate::updateGeometriesWithSignals()
+{
+ const QRect oldGeometry = geometry;
+ const QRect oldAvailableGeometry = availableGeometry;
+ updateHighDpi();
+ emitGeometryChangeSignals(oldGeometry != geometry, oldAvailableGeometry != availableGeometry);
+}
+
+void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availableGeometryChanged)
+{
+ Q_Q(QScreen);
+ if (availableGeometryChanged)
+ emit q->availableGeometryChanged(availableGeometry);
+
+ if (geometryChanged || availableGeometryChanged) {
+ const auto siblings = q->virtualSiblings();
+ for (QScreen* sibling : siblings)
+ emit sibling->virtualGeometryChanged(sibling->virtualGeometry());
+ }
+}
+
void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
{
Q_Q(QScreen);
platformScreen = screen;
platformScreen->d_func()->screen = q;
orientation = platformScreen->orientation();
- geometry = platformScreen->deviceIndependentGeometry();
- availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(),
- QHighDpiScaling::factor(platformScreen), geometry.topLeft());
logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index e5988ff829..7da542c25e 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -72,6 +72,8 @@ public:
}
void updatePrimaryOrientation();
+ void updateGeometriesWithSignals();
+ void emitGeometryChangeSignals(bool geometryChanged, bool availableGeometryChanged);
QPlatformScreen *platformScreen = nullptr;