Skip to content

Commit

Permalink
Fix high DPI position of foreign child windows on Windows
Browse files Browse the repository at this point in the history
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 checking whether we have a child window and keep the local
position in that case.

(cherry-picked from commit dedb29c)
Fixes: QTBUG-96114
Change-Id: Ibb0f844b10aece8ede99cb34289c0430ac283fa0
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
jobor committed Oct 20, 2021
1 parent 7eefe94 commit a2dc796
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/kernel/qwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,12 @@ 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));
if (isTopLevel()) {
d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));
} else {
d->platformWindow->setGeometry(QRect(QHighDpi::toNativeLocalPosition(position(), this),
QHighDpi::toNativePixels(newSize, this)));
}
} else {
const QSize oldSize = d->geometry.size();
d->geometry.setSize(newSize);
Expand Down

0 comments on commit a2dc796

Please sign in to comment.