diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/ios/qiosscreen.mm | 6 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 50 |
2 files changed, 43 insertions, 13 deletions
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 2389796e58..48be7fc906 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -208,12 +208,6 @@ QIOSScreen::QIOSScreen(UIScreen *screen) // Create a window and associated view-controller that we can use m_uiWindow = [[UIWindow alloc] initWithFrame:[m_uiScreen bounds]]; m_uiWindow.rootViewController = [[[QIOSViewController alloc] initWithQIOSScreen:this] autorelease]; - - // FIXME: Only do once windows are added to the screen, and for any screen - if (screen == [UIScreen mainScreen]) { - m_uiWindow.screen = m_uiScreen; - m_uiWindow.hidden = NO; - } } updateProperties(); 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 |