summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2021-04-14 21:46:30 +0200
committerMorten Sørvig <morten.sorvig@qt.io>2021-05-11 18:39:07 +0200
commit1e85dfacf3479ebbe5a4502895b8b8d93fbe1477 (patch)
tree94cd113dc99f3b0ba7d76316a19c66a5dc8bba98 /src
parent7c7fda3a7e61f2368f933a8c172533507156338c (diff)
Make resizeMaximizedWindows() preserve native geometry
Previously, resizeMaximizedWindows() would use the device independent screen size as the source of truth when setting window sizes. However this size may have been rounded, which means that e.g. a fullscreen window may fail to cover the entire screen. Instead, use the native screen size as the true screen size. Set QPlatformWindow geometry, and let the platform update QWindow geometry via geometry change events. Pick-to: 6.1 Fixes: QTBUG-87334 Change-Id: If6e4852dea46ab03c83e469808c0047bc933ee47 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qplatformscreen.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index f1fe942b9c..0649139455 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -47,6 +47,7 @@
#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
#include <private/qhighdpiscaling_p.h>
+#include <private/qwindow_p.h>
QT_BEGIN_NAMESPACE
@@ -353,11 +354,12 @@ QPlatformCursor *QPlatformScreen::cursor() const
*/
void QPlatformScreen::resizeMaximizedWindows()
{
- // 'screen()' still has the old geometry info while 'this' has the new geometry info
+ // 'screen()' still has the old geometry (in device independent pixels),
+ // while 'this' has the new geometry (in native pixels)
const QRect oldGeometry = screen()->geometry();
const QRect oldAvailableGeometry = screen()->availableGeometry();
- const QRect newGeometry = deviceIndependentGeometry();
- const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft());
+ const QRect newNativeGeometry = this->geometry();
+ const QRect newNativeAvailableGeometry = this->availableGeometry();
const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry);
@@ -366,14 +368,19 @@ void QPlatformScreen::resizeMaximizedWindows()
if (!w->handle())
continue;
+ // Set QPlatformWindow size in native pixels, and let the platform's geometry
+ // change signals update the QWindow geomeyry. This way we make sure that the
+ // platform window geometry covers the entire (available) platform screen geometry,
+ // also when fractional DPRs introduce rounding errors in the device independent
+ // QWindow and QScreen sizes.
if (supportsMaximizeUsingFullscreen
&& w->windowState() & Qt::WindowMaximized
&& w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) {
- w->setGeometry(newGeometry);
+ w->handle()->setGeometry(newNativeGeometry);
} else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) {
- w->setGeometry(newAvailableGeometry);
+ w->handle()->setGeometry(newNativeAvailableGeometry);
} else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) {
- w->setGeometry(newGeometry);
+ w->handle()->setGeometry(newNativeGeometry);
}
}
}