diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index 9428487a00d..32b735c4bca 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -39,7 +39,7 @@ int infoPlistValue(NSString* key, int defaultValue); class QWindow; class QScreen; UIWindow *presentationWindow(QWindow *); -UIView *rootViewForScreen(QScreen *); +UIView *rootViewForScreen(const QPlatformScreen *); QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 1722e09aaab..9ab490b2970 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -108,9 +108,11 @@ UIWindow *presentationWindow(QWindow *window) return uiWindow; } -UIView *rootViewForScreen(QScreen *screen) +UIView *rootViewForScreen(const QPlatformScreen *screen) { - const auto *iosScreen = static_cast(screen->handle()); + Q_ASSERT(screen); + + const auto *iosScreen = static_cast(screen); for (UIScene *scene in [qt_apple_sharedApplication().connectedScenes allObjects]) { if (![scene isKindOfClass:UIWindowScene.class]) continue; diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 8f3081e276c..c5944ba1a7e 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -209,7 +209,7 @@ void QIOSScreen::updateProperties() #if defined(Q_OS_VISIONOS) // Based on what iPad app reports - m_geometry = QRect(0, 0, 1194, 834); + m_geometry = QRectF::fromCGRect(rootViewForScreen(this).bounds).toRect(); m_depth = 24; #else m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect(); @@ -377,7 +377,7 @@ QPixmap QIOSScreen::grabWindow(WId window, int x, int y, int width, int height) return QPixmap(); UIView *view = window ? reinterpret_cast(window) - : rootViewForScreen(screen()); + : rootViewForScreen(this); if (width < 0) width = qMax(view.bounds.size.width - x, CGFloat(0)); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 7cd3d5f0b08..b2f2ea920ee 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -298,7 +298,7 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow) if (parentWindow) superview = reinterpret_cast(parentWindow->winId()); else if (isQtApplication() && !isForeignWindow()) - superview = rootViewForScreen(window()->screen()); + superview = rootViewForScreen(window()->screen()->handle()); if (superview) [superview addSubview:m_view];