From 3e529369eb16704aa0d601a7f4b8e490dc8b772c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Nov 2019 08:45:27 +0100 Subject: [PATCH] Support MaximizeUsingFullscreenGeometryHint in resizeMaximizedWindows() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In QPlatformScreen there is a convenience function which resizes windows when the screen changes. This did not have support for MaximizeUsingFullscreenGeometryHint and would mistakenly resize these windows to the available geometry. Since not all QPA plugins support this hint, we have to add a capability flag to avoid changing behavior on platforms where it works as intended. Task-number: QTBUG-74202 Change-Id: Ife88f597fbb3affa722f63ac18fb5719ffa8ed33 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qplatformscreen.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d9f349555a8..01406958e26 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -106,7 +106,8 @@ public: ApplicationIcon, SwitchableWidgetComposition, TopStackedNativeChildWindows, - OpenGLOnRasterSurface + OpenGLOnRasterSurface, + MaximizeUsingFullscreenGeometry }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index f3213bf5ea4..7daf48b1917 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -410,15 +410,22 @@ void QPlatformScreen::resizeMaximizedWindows() const QRect newGeometry = deviceIndependentGeometry(); const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); + const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry); + for (QWindow *w : windows()) { // Skip non-platform windows, e.g., offscreen windows. if (!w->handle()) continue; - if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) - w->setGeometry(newAvailableGeometry); - else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) + if (supportsMaximizeUsingFullscreen + && w->windowState() & Qt::WindowMaximized + && w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) { w->setGeometry(newGeometry); + } else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) { + w->setGeometry(newAvailableGeometry); + } else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) { + w->setGeometry(newGeometry); + } } }