From 1d3b06a1abb715efc38f88ecd369f96d6e8cadd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Keller?= Date: Mon, 15 May 2023 19:55:50 +0200 Subject: [PATCH] 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 Pick-to: 6.6 6.5 Change-Id: Ic30dc1b16bbaf9306a086c8d3042f5341d3848c1 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index b2b8e4bd05..bc04718a32 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2242,10 +2242,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() << '"';