From 1f3891d0fbbcb5eb0933a30b277eb2f5a3f2c6f6 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 7 Feb 2014 12:41:13 +0100 Subject: iOS: only activate top-level windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From before we would activate all QWindows that the user tapped on, or setVisible were called on. This is wrong since a QWindow does not have to be a top-level window. For a non-alien widget application this would mean that we would send activation events for all widgets that the user tapped on all the time. With this patch we do some extra checking before we tell a QWindow to activate. Change-Id: I1afe97e5384c36c67fee0bbd070d880bba7528a1 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/ios/qioswindow.mm') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index f0f436f405..7d5c507972 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -247,8 +247,13 @@ m_activeTouches[touch].id = m_nextTouchId++; } - if (m_activeTouches.size() == 1 && m_qioswindow->window() != QGuiApplication::focusWindow()) - m_qioswindow->requestActivateWindow(); + if (m_activeTouches.size() == 1) { + QPlatformWindow *topLevel = m_qioswindow; + while (QPlatformWindow *p = topLevel->parent()) + topLevel = p; + if (topLevel->window() != QGuiApplication::focusWindow()) + topLevel->requestActivateWindow(); + } [self updateTouchList:touches withState:Qt::TouchPointPressed]; [self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)]; @@ -367,7 +372,7 @@ void QIOSWindow::setVisible(bool visible) m_view.hidden = !visible; [m_view setNeedsDisplay]; - if (!isQtApplication()) + if (!isQtApplication() || !window()->isTopLevel()) return; // Since iOS doesn't do window management the way a Qt application @@ -383,18 +388,16 @@ void QIOSWindow::setVisible(bool visible) if (visible) { requestActivateWindow(); - - if (window()->isTopLevel()) - static_cast(screen())->updateStatusBarVisibility(); - + static_cast(screen())->updateStatusBarVisibility(); } else { // Activate top-most visible QWindow: NSArray *subviews = m_view.viewController.view.subviews; for (int i = int(subviews.count) - 1; i >= 0; --i) { UIView *view = [subviews objectAtIndex:i]; if (!view.hidden) { - if (QWindow *window = view.qwindow) { - static_cast(window->handle())->requestActivateWindow(); + QWindow *w = view.qwindow; + if (w && w->isTopLevel()) { + static_cast(w->handle())->requestActivateWindow(); break; } } -- cgit v1.2.3