Windows QPA: Fix dpi change when changing screens with keyboard

If moving a window from a screen to another using keyboard shortcuts,
the screen change detection happens after the handleDpiChange() call
which essentially makes Qt think the window stayed on the old monitor.
Instead of checking against currentScreen DPI, check against savedDpi
which should not have this problem.

Task-number: QTBUG-106483
Change-Id: Ic30dc1b16bbaf9306a086c8d3042f5341d3848c1
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 1d3b06a1abb715efc38f88ecd369f96d6e8cadd6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Timothée Keller 2023-05-15 19:55:50 +02:00 committed by Qt Cherry-pick Bot
parent 03b1ade31c
commit 04bc5fa4be

View File

@ -2238,10 +2238,10 @@ void QWindowsWindow::checkForScreenChanged(ScreenChangeMode mode)
return;
// For screens with different DPI: postpone until WM_DPICHANGE
// Check on currentScreen as it can be 0 when resuming a session (QTBUG-80436).
if (mode == FromGeometryChange && currentScreen != nullptr
&& !equalDpi(currentScreen->logicalDpi(), newScreen->logicalDpi())) {
const bool changingDpi = !equalDpi(QDpi(savedDpi(), savedDpi()), newScreen->logicalDpi());
if (mode == FromGeometryChange && currentScreen != nullptr && changingDpi)
return;
}
qCDebug(lcQpaWindow).noquote().nospace() << __FUNCTION__
<< ' ' << window() << " \"" << (currentScreen ? currentScreen->name() : QString())
<< "\"->\"" << newScreen->name() << '"';