Always run screen change side effects
processWindowScreenChangedEvent() returns early if the screen for the (top-level) window has already been updated, for instance by a call to handleScreenRemoved(). This was preventing us from updating the DPR and window geometry. Move the code a slot connected to QWindow::screenChange, which gets emitted for all windows (also child windows), whenever the screen changes. Fixes: QTBUG-116232 Change-Id: I44701fd001ab1fd54efe9c8451c6a58cfc0b285f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 89ce65c2d01e77c1cf49bb8579f63b60480e0186) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d5b36aa609
commit
4b21b332ee
@ -2604,17 +2604,6 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf
|
||||
else // Fall back to default behavior, and try to find some appropriate screen
|
||||
topLevelWindow->setScreen(nullptr);
|
||||
}
|
||||
|
||||
// We may have changed scaling; trigger resize event if needed,
|
||||
// except on Windows, where we send resize events during WM_DPICHANGED
|
||||
// event handling. FIXME: unify DPI change handling across all platforms.
|
||||
#ifndef Q_OS_WIN
|
||||
if (window->handle()) {
|
||||
QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window));
|
||||
processGeometryChangeEvent(&gce);
|
||||
}
|
||||
#endif
|
||||
QWindowPrivate::get(window)->updateDevicePixelRatio();
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *wde)
|
||||
|
@ -227,6 +227,19 @@ void QWindowPrivate::init(QScreen *targetScreen)
|
||||
|
||||
requestedFormat = QSurfaceFormat::defaultFormat();
|
||||
devicePixelRatio = connectScreen->devicePixelRatio();
|
||||
|
||||
QObject::connect(q, &QWindow::screenChanged, q, [q, this](QScreen *){
|
||||
// We may have changed scaling; trigger resize event if needed,
|
||||
// except on Windows, where we send resize events during WM_DPICHANGED
|
||||
// event handling. FIXME: unify DPI change handling across all platforms.
|
||||
#ifndef Q_OS_WIN
|
||||
if (q->handle()) {
|
||||
QWindowSystemInterfacePrivate::GeometryChangeEvent gce(q, QHighDpi::fromNativePixels(q->handle()->geometry(), q));
|
||||
QGuiApplicationPrivate::processGeometryChangeEvent(&gce);
|
||||
}
|
||||
#endif
|
||||
updateDevicePixelRatio();
|
||||
});
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user