From fb2e795c6e61b3c5fb699aefdb2662769c12f76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Nov 2017 16:06:02 +0100 Subject: iOS: Take UIWindow bounds into account when making window fullscreen When an app is in split-view mode, the app can't use the full bounds of the screen, but should limit its area to that of its UIWindow. Task-number: QTBUG-48225 Change-Id: Ia66ad6bba24d9d73a8263ad3f65b9dee9b8a1b37 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioswindow.mm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/ios/qioswindow.mm') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 8ff0dfbd5f..fb161febda 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -244,12 +244,25 @@ void QIOSWindow::setWindowState(Qt::WindowState state) applyGeometry(m_normalGeometry); break; case Qt::WindowMaximized: - applyGeometry(window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? - screen()->geometry() : screen()->availableGeometry()); - break; - case Qt::WindowFullScreen: - applyGeometry(screen()->geometry()); + case Qt::WindowFullScreen: { + // When an application is in split-view mode, the UIScreen still has the + // same geometry, but the UIWindow is resized to the area reserved for the + // application. We use this to constrain the geometry used when applying the + // fullscreen or maximized window states. Note that we do not do this + // in applyGeometry(), as we don't want to artificially limit window + // placement "outside" of the screen bounds if that's what the user wants. + + QRect uiWindowBounds = QRectF::fromCGRect(m_view.window.bounds).toRect(); + QRect fullscreenGeometry = screen()->geometry().intersected(uiWindowBounds); + QRect maximizedGeometry = window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? + fullscreenGeometry : screen()->availableGeometry().intersected(uiWindowBounds); + + if (state & Qt::WindowFullScreen) + applyGeometry(fullscreenGeometry); + else + applyGeometry(maximizedGeometry); break; + } case Qt::WindowMinimized: applyGeometry(QRect()); break; -- cgit v1.2.3