From d038f3d6924c785aca4973c0b4ac93b831670996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 24 Feb 2025 17:11:20 +0100 Subject: [PATCH] Add note to QWindow::setGeometry of why we set the screen first Change-Id: I1c497bb240b23ef96c45c7942d5fd1b650006942 Reviewed-by: Assam Boudjelthia --- src/gui/kernel/qwindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f6a05a758f0..6f43ebc4a76 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1842,6 +1842,13 @@ void QWindow::setGeometry(const QRect &rect) d->positionPolicy = QWindowPrivate::WindowFrameExclusive; if (d->platformWindow) { + // Setting a new geometry may move the window to a new screen. + // The QHighDpi layer needs to know the new screen to be able + // to resolve the resulting geometry based on the screen's DPR, + // so we update the screen before passing the geometry on to + // the platform layer. FIXME: Find a way to tell QHighDpi about + // the new screen without actually changing the screen, so that + // the geometry change is the trigger for the screen change. QScreen *newScreen = d->screenForGeometry(rect); if (newScreen && isTopLevel()) d->setTopLevelScreen(newScreen, true);