diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-09-07 17:56:00 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-09-16 16:32:51 +0200 |
commit | a661f8c306c980b70ddf9716e89df28bb98721b9 (patch) | |
tree | a0d8984d3dbd89cb7cfccca7105ed1c210254bc6 /src/gui/kernel/qguiapplication.cpp | |
parent | 865b1721bd284fac6c68eadb335507ea6cffb676 (diff) |
Share logic for QScreen property update emitting in helper class
With high-DPI scaling in place QScreen properties like the geometry
can be affected both by screen resolution changes, as well as logical
DPI changes. We want to ensure similar behavior in both cases when it
comes to which change-signals we emit, so centralizing this code makes
sense.
As the update of the cached primary orientation is trivial we do it
unconditionally.
Change-Id: I712005075a4b758180906fb88b2ac187b3dbe1ff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index cc532401b4..7887db8534 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3065,25 +3065,16 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP if (!e->screen) return; - QScreen *s = e->screen.data(); - - bool geometryChanged = e->geometry != s->d_func()->geometry; - s->d_func()->geometry = e->geometry; + { + QScreen *s = e->screen.data(); + QScreenPrivate::UpdateEmitter updateEmitter(s); - bool availableGeometryChanged = e->availableGeometry != s->d_func()->availableGeometry; - s->d_func()->availableGeometry = e->availableGeometry; + // Note: The incoming geometries have already been scaled by QHighDpi + // in the QWSI layer, so we don't need to call updateGeometry() here. + s->d_func()->geometry = e->geometry; + s->d_func()->availableGeometry = e->availableGeometry; - const Qt::ScreenOrientation primaryOrientation = s->primaryOrientation(); - if (geometryChanged) s->d_func()->updatePrimaryOrientation(); - - s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged); - - if (geometryChanged) { - emit s->physicalSizeChanged(s->physicalSize()); - - if (s->primaryOrientation() != primaryOrientation) - emit s->primaryOrientationChanged(s->primaryOrientation()); } resetCachedDevicePixelRatio(); @@ -3100,11 +3091,12 @@ void QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange(QWindowSystem if (!e->screen) return; - QScreen *s = e->screen.data(); - s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); - - emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); - s->d_func()->updateGeometriesWithSignals(); + { + QScreen *s = e->screen.data(); + QScreenPrivate::UpdateEmitter updateEmitter(s); + s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); + s->d_func()->updateGeometry(); + } resetCachedDevicePixelRatio(); } |