summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindow.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2020-05-27 10:57:08 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2020-10-20 07:26:24 +0200
commit95bce5b185ddc736405a952b9132e5c8f51275aa (patch)
tree0f3c542dade9d5dbfa7aaec86591159d55221c41 /src/gui/kernel/qwindow.cpp
parent73a93981ca6bd641f2c75faf3cdce1fa0711fbb5 (diff)
QHighDpi: window geometry scaling functions
Add functions which scales window geometry: framNativeWindowGeometry() toNativeWindowGeometry() These correctly handles top-level and child windows, where top-level window positions scale around the screen origin while child window positions scale around (0, 0). Modify call cites to use the new functions. We no longer need the isTopLevel checks at the call site. Change-Id: I0158672d46a3f52dfc7d37d021fc5cebd7859200 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r--src/gui/kernel/qwindow.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index be1e3532fd..867e658be5 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1784,9 +1784,7 @@ QRect QWindow::geometry() const
Q_D(const QWindow);
if (d->platformWindow) {
const auto nativeGeometry = d->platformWindow->geometry();
- return isTopLevel()
- ? QHighDpi::fromNativePixels(nativeGeometry, this)
- : QHighDpi::fromNativeLocalPosition(nativeGeometry, this);
+ return QHighDpi::fromNativeWindowGeometry(nativeGeometry, this);
}
return d->geometry;
}
@@ -1816,7 +1814,7 @@ QRect QWindow::frameGeometry() const
Q_D(const QWindow);
if (d->platformWindow) {
QMargins m = frameMargins();
- return QHighDpi::fromNativePixels(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());
+ return QHighDpi::fromNativeWindowGeometry(d->platformWindow->geometry(), this).adjusted(-m.left(), -m.top(), m.right(), m.bottom());
}
return d->geometry;
}
@@ -1833,7 +1831,7 @@ QPoint QWindow::framePosition() const
Q_D(const QWindow);
if (d->platformWindow) {
QMargins margins = frameMargins();
- return QHighDpi::fromNativePixels(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());
+ return QHighDpi::fromNativeWindowGeometry(d->platformWindow->geometry().topLeft(), this) - QPoint(margins.left(), margins.top());
}
return d->geometry.topLeft();
}
@@ -1851,7 +1849,7 @@ void QWindow::setFramePosition(const QPoint &point)
d->positionPolicy = QWindowPrivate::WindowFrameInclusive;
d->positionAutomatic = false;
if (d->platformWindow) {
- d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(point, size()), this));
+ d->platformWindow->setGeometry(QHighDpi::toNativeWindowGeometry(QRect(point, size()), this));
} else {
d->geometry.moveTopLeft(point);
}