diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-07-20 16:39:08 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-21 13:08:32 +0000 |
commit | 5fcbab898238bee1fb0b93f9bc5f9f2590792588 (patch) | |
tree | 848b1da890a28650a38a6a8c79d6d2574731c96f | |
parent | 4b8aee4bd17c2ed96482d00df7d410b18062b03f (diff) |
Handle QScreen::physicalDotsPerInchChanged changes for the initial screen
We connect to the signal when the screens change (in
QQuickWindow::handleScreenChanged), but never for the initial screen.
Not connecting means that changing the DPR of the initial screen doesn't
re-render QQuickItems with the new DPR, which was in particular visible
for QQuickImage when displaying SVGs.
Task-number: QTBUG-94622
Change-Id: I44ff3f8f3713d5a7bba8b6b8b4d5ca14530fe373
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 7e39a2204382a78ac6ff1e32dfe29dcbce65004c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index f143a689a6..d9ae003504 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -436,12 +436,13 @@ void QQuickWindow::physicalDpiChanged() void QQuickWindow::handleScreenChanged(QScreen *screen) { Q_D(QQuickWindow); + // we connected to the initial screen in QQuickWindowPrivate::init, but the screen changed disconnect(d->physicalDpiChangedConnection); if (screen) { physicalDpiChanged(); // When physical DPI changes on the same screen, either the resolution or the device pixel // ratio changed. We must check what it is. Device pixel ratio does not have its own - // ...Changed() signal. + // ...Changed() signal. Reconnect, same as in QQuickWindowPrivate::init. d->physicalDpiChangedConnection = connect(screen, &QScreen::physicalDotsPerInchChanged, this, &QQuickWindow::physicalDpiChanged); } @@ -764,8 +765,13 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) Q_ASSERT(windowManager || renderControl); - if (QScreen *screen = q->screen()) - devicePixelRatio = screen->devicePixelRatio(); + if (QScreen *screen = q->screen()) { + devicePixelRatio = screen->devicePixelRatio(); + // if the screen changes, then QQuickWindow::handleScreenChanged disconnects + // and connects to the new screen + physicalDpiChangedConnection = QObject::connect(screen, &QScreen::physicalDotsPerInchChanged, + q, &QQuickWindow::physicalDpiChanged); + } QSGContext *sg; if (renderControl) { |