From 1b209ccd6d21f1988d39134f1aa9b07d1af50259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 19 Jan 2015 14:49:04 +0100 Subject: iOS: Associate UIScreen and show UIWindow on initial QWindow mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We delay showing the UIWindow until the first QWindow is created and mapped to the screen. This allows external screens to stay in mirror mode until a QWindow has been explicitly created on that screen. We also remove the screen-association when the last QWindow on that screen has been removed, which will return the external screen to mirror mode. Change-Id: Iccecb297281d0c4f397f69f2494debff051ade01 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosviewcontroller.mm | 50 +++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms/ios/qiosviewcontroller.mm') diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index ea81033e43..84d6628a8a 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -56,11 +56,54 @@ // ------------------------------------------------------------------------- +@interface QIOSViewController () { + @public + QIOSScreen *m_screen; + BOOL m_updatingProperties; +} +@property (nonatomic, assign) BOOL changingOrientation; +@end + +// ------------------------------------------------------------------------- + @interface QIOSDesktopManagerView : UIView @end @implementation QIOSDesktopManagerView +- (void)didAddSubview:(UIView *)subview +{ + Q_UNUSED(subview); + + QIOSScreen *screen = self.qtViewController->m_screen; + + // The 'window' property of our view is not valid until the window + // has been shown, so we have to access it through the QIOSScreen. + UIWindow *uiWindow = screen->uiWindow(); + + if (uiWindow.hidden) { + // Associate UIWindow to screen and show it the first time a QWindow + // is mapped to the screen. For external screens this means disabling + // mirroring mode and presenting alternate content on the screen. + uiWindow.screen = screen->uiScreen(); + uiWindow.hidden = NO; + } +} + +- (void)willRemoveSubview:(UIView *)subview +{ + Q_UNUSED(subview); + + Q_ASSERT(self.window); + UIWindow *uiWindow = self.window; + + if (uiWindow.screen != [UIScreen mainScreen] && self.subviews.count == 1) { + // Removing the last view of an external screen, go back to mirror mode + uiWindow.screen = nil; + uiWindow.hidden = YES; + } +} + - (void)layoutSubviews { for (int i = int(self.subviews.count) - 1; i >= 0; --i) { @@ -125,13 +168,6 @@ // ------------------------------------------------------------------------- -@interface QIOSViewController () { - QIOSScreen *m_screen; - BOOL m_updatingProperties; -} -@property (nonatomic, assign) BOOL changingOrientation; -@end - @implementation QIOSViewController - (id)initWithQIOSScreen:(QIOSScreen *)screen -- cgit v1.2.3