From dedb29cf23959741593b2fa1481f210cd663cafb Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 14 Oct 2021 17:44:29 +0200 Subject: [PATCH] Fix high DPI position of foreign child windows on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppose you have a child window that is a foreign window. In the bug report's example it's a QAxWidget that wraps the Windows Media Player. This means, we have a non-top-level QWindow with a platformWindow assigned. If windows:dpiawareness is set to 1 (system-DPI aware) and the window is displayed on a screen with origin != (0, 0), then we called QPlatformWindow::setGeometry with a position in native coordinates. This moved the child window outside of the visible area. Fix this by calling QHighDpi::toNativeWindowGeometry instead of QHighDpi::toNativePixels. The former function takes child windows properly into account. Pick-to: 6.2 Fixes: QTBUG-96114 Change-Id: Ibb0f844b10aece8ede99cb34289c0430ac283fa0 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 61756a3834..275d190a5a 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1940,7 +1940,8 @@ void QWindow::resize(const QSize &newSize) Q_D(QWindow); d->positionPolicy = QWindowPrivate::WindowFrameExclusive; if (d->platformWindow) { - d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this)); + d->platformWindow->setGeometry( + QHighDpi::toNativeWindowGeometry(QRect(position(), newSize), this)); } else { const QSize oldSize = d->geometry.size(); d->geometry.setSize(newSize);