Fix high DPI position of foreign child windows on Windows

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 <morten.sorvig@qt.io>
bb10
Joerg Bornemann 2021-10-14 17:44:29 +02:00
parent aad4158959
commit dedb29cf23
1 changed files with 2 additions and 1 deletions

View File

@ -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);