diff options
Diffstat (limited to 'src/plugins/platforms/ios/qioswindow.mm')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index fd04ecf474..95a4c28246 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -120,7 +120,7 @@ void QIOSWindow::setVisible(bool visible) if (visible && shouldAutoActivateWindow()) { requestActivateWindow(); - } else if (!visible && qGuiApp->focusWindow() == window()) { + } else if (!visible && [m_view isActiveWindow]) { // Our window was active/focus window but now hidden, so relinquish // focus to the next possible window in the stack. NSArray *subviews = m_view.viewController.view.subviews; @@ -206,6 +206,25 @@ void QIOSWindow::applyGeometry(const QRect &rect) bool QIOSWindow::isExposed() const { + // Note: At startup of an iOS app it will enter UIApplicationStateInactive + // while showing the launch screen, and once the application returns from + // applicationDidFinishLaunching it will hide the launch screen and enter + // UIApplicationStateActive. Technically, a window is not exposed until + // it's actually visible on screen, and Apple also documents that "Apps + // that use OpenGL ES for drawing must not use didFinishLaunching to + // prepare their drawing environment. Instead, defer any OpenGL ES + // drawing calls to applicationDidBecomeActive". Unfortunately, if we + // wait until the applicationState reaches ApplicationActive to signal + // that the window is exposed, we get a lag between hiding the launch + // screen and blitting the first pixels of the application, as Qt + // spends some time drawing those pixels in response to the expose. + // In practice there doesn't seem to be any issues starting GL setup + // and drawing from within applicationDidFinishLaunching, and this is + // also the recommended approach for other 3rd party GL toolkits on iOS, + // so we 'cheat', and report that a window is exposed even if the app + // is in UIApplicationStateInactive, so that the startup transition + // between the launch screen and the application content is smooth. + return qApp->applicationState() > Qt::ApplicationHidden && window()->isVisible() && !window()->geometry().isEmpty(); } |