Use QHighDpi::toNativeWindowGeometry()

This function implements the isTopLevel() logic, which
we now don’t have to duplicate at each call site.

Change-Id: Ic8b857aa7cd3c3c23d5e950d9f50b66c81ba3ccf
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Sørvig 2021-04-14 19:59:22 +02:00 committed by Morten Johan Sørvig
parent 1afd562b0b
commit 46039092bd

View File

@ -1753,13 +1753,7 @@ void QWindow::setGeometry(const QRect &rect)
QScreen *newScreen = d->screenForGeometry(rect);
if (newScreen && isTopLevel())
d->setTopLevelScreen(newScreen, true);
QRect nativeRect;
if (newScreen && isTopLevel())
nativeRect = QHighDpi::toNativePixels(rect, newScreen);
else
nativeRect = QHighDpi::toNativeLocalPosition(rect, newScreen);
d->platformWindow->setGeometry(nativeRect);
d->platformWindow->setGeometry(QHighDpi::toNativeWindowGeometry(rect, this));
} else {
d->geometry = rect;