visionOS: Report size of root view as screen size
Even though we've decoupled QIOSScreen from managing UIWindows, we still have one UIWindow per screen, so we can pull out the bounds of that root view to determine Qt's screen geometry. Change-Id: I05993ad6d629dd2158681dd17355b7e216bfbb49 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 16483487c4e37546cf296a72e137d49d28b55e05) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
63ad52d991
commit
ea1978c7f9
@ -39,7 +39,7 @@ int infoPlistValue(NSString* key, int defaultValue);
|
|||||||
class QWindow;
|
class QWindow;
|
||||||
class QScreen;
|
class QScreen;
|
||||||
UIWindow *presentationWindow(QWindow *);
|
UIWindow *presentationWindow(QWindow *);
|
||||||
UIView *rootViewForScreen(QScreen *);
|
UIView *rootViewForScreen(const QPlatformScreen *);
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
@ -108,9 +108,11 @@ UIWindow *presentationWindow(QWindow *window)
|
|||||||
return uiWindow;
|
return uiWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIView *rootViewForScreen(QScreen *screen)
|
UIView *rootViewForScreen(const QPlatformScreen *screen)
|
||||||
{
|
{
|
||||||
const auto *iosScreen = static_cast<QIOSScreen *>(screen->handle());
|
Q_ASSERT(screen);
|
||||||
|
|
||||||
|
const auto *iosScreen = static_cast<const QIOSScreen *>(screen);
|
||||||
for (UIScene *scene in [qt_apple_sharedApplication().connectedScenes allObjects]) {
|
for (UIScene *scene in [qt_apple_sharedApplication().connectedScenes allObjects]) {
|
||||||
if (![scene isKindOfClass:UIWindowScene.class])
|
if (![scene isKindOfClass:UIWindowScene.class])
|
||||||
continue;
|
continue;
|
||||||
|
@ -209,7 +209,7 @@ void QIOSScreen::updateProperties()
|
|||||||
|
|
||||||
#if defined(Q_OS_VISIONOS)
|
#if defined(Q_OS_VISIONOS)
|
||||||
// Based on what iPad app reports
|
// Based on what iPad app reports
|
||||||
m_geometry = QRect(0, 0, 1194, 834);
|
m_geometry = QRectF::fromCGRect(rootViewForScreen(this).bounds).toRect();
|
||||||
m_depth = 24;
|
m_depth = 24;
|
||||||
#else
|
#else
|
||||||
m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect();
|
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();
|
return QPixmap();
|
||||||
|
|
||||||
UIView *view = window ? reinterpret_cast<UIView *>(window)
|
UIView *view = window ? reinterpret_cast<UIView *>(window)
|
||||||
: rootViewForScreen(screen());
|
: rootViewForScreen(this);
|
||||||
|
|
||||||
if (width < 0)
|
if (width < 0)
|
||||||
width = qMax(view.bounds.size.width - x, CGFloat(0));
|
width = qMax(view.bounds.size.width - x, CGFloat(0));
|
||||||
|
@ -298,7 +298,7 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow)
|
|||||||
if (parentWindow)
|
if (parentWindow)
|
||||||
superview = reinterpret_cast<UIView *>(parentWindow->winId());
|
superview = reinterpret_cast<UIView *>(parentWindow->winId());
|
||||||
else if (isQtApplication() && !isForeignWindow())
|
else if (isQtApplication() && !isForeignWindow())
|
||||||
superview = rootViewForScreen(window()->screen());
|
superview = rootViewForScreen(window()->screen()->handle());
|
||||||
|
|
||||||
if (superview)
|
if (superview)
|
||||||
[superview addSubview:m_view];
|
[superview addSubview:m_view];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user