summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosscreen.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-03-16 13:24:13 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-03-20 15:20:59 +0100
commitb7eb73b1f0b550c1697b70c3ab9ddb7480557faf (patch)
tree1681b757e65c8f3c8595426085e11a3d7de2524e /src/plugins/platforms/ios/qiosscreen.mm
parent17f6c62d97d4e1bfccfdd788c19e6b383cf98dac (diff)
iOS: Don't apply UIWindow safeAreInsets to available geometry on visionOS
There is no concept of a screen on visionOS, and hence no concept of screen-relative system UI that we should keep top level windows away from. As UIWindow and UIScreen on visionOS report the exact same bounds, we can't use the same code path we use for iOS/iPadOS to detect whether to apply the safe area insets, so skip the logic entirely. We still report the safe area insets on a QWindow level, so applications can avoid rendering content close to UI elements such as the window move and window close buttons. Task-number: QTBUG-121781 Change-Id: I20ad02390564972a3715c27f351689b79ad579d8 Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qiosscreen.mm')
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 6d38761d00..e48592aa24 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -296,6 +296,15 @@ QString QIOSScreen::name() const
return "External display"_L1;
}
+static bool isRunningOnVisionOS()
+{
+ static bool result = []{
+ // This class is documented to only be available on visionOS
+ return NSClassFromString(@"UIWindowSceneGeometryPreferencesVision");
+ }();
+ return result;
+}
+
void QIOSScreen::updateProperties()
{
QRect previousGeometry = m_geometry;
@@ -308,11 +317,17 @@ void QIOSScreen::updateProperties()
// For convenience, we reflect the safe area margins of the screen's UIWindow
// by reducing the available geometry of the screen. But we only do this if
// the UIWindow bounds is representative of the UIScreen.
- UIEdgeInsets safeAreaInsets = m_uiWindow.safeAreaInsets;
- if (m_uiWindow.bounds.size.width == m_uiScreen.bounds.size.width)
- m_availableGeometry.adjust(safeAreaInsets.left, 0, -safeAreaInsets.right, 0);
- if (m_uiWindow.bounds.size.height == m_uiScreen.bounds.size.height)
- m_availableGeometry.adjust(0, safeAreaInsets.top, 0, -safeAreaInsets.bottom);
+ if (isRunningOnVisionOS()) {
+ // On visionOS there is no concept of a screen, and hence no concept of
+ // screen-relative system UI that we should keep top level windows away
+ // from, so don't apply the UIWindow safe area insets to the screen.
+ } else {
+ UIEdgeInsets safeAreaInsets = m_uiWindow.safeAreaInsets;
+ if (m_uiWindow.bounds.size.width == m_uiScreen.bounds.size.width)
+ m_availableGeometry.adjust(safeAreaInsets.left, 0, -safeAreaInsets.right, 0);
+ if (m_uiWindow.bounds.size.height == m_uiScreen.bounds.size.height)
+ m_availableGeometry.adjust(0, safeAreaInsets.top, 0, -safeAreaInsets.bottom);
+ }
#ifndef Q_OS_TVOS
if (m_uiScreen == [UIScreen mainScreen]) {