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>
This commit is contained in:
parent
7c7fda3a7e
commit
1e85dfacf3
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user