diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-02-07 12:41:13 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-14 00:34:25 +0100 |
commit | 1f3891d0fbbcb5eb0933a30b277eb2f5a3f2c6f6 (patch) | |
tree | 364731bbea4581f1accbba5795154b63e410fdce /src/plugins/platforms/ios | |
parent | 3475dba53c34f986776b3c8b2a11e322c3ad4d71 (diff) |
iOS: only activate top-level windows
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ø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 21 |
1 files changed, 12 insertions, 9 deletions
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<QIOSScreen *>(screen())->updateStatusBarVisibility(); - + static_cast<QIOSScreen *>(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<QIOSWindow *>(window->handle())->requestActivateWindow(); + QWindow *w = view.qwindow; + if (w && w->isTopLevel()) { + static_cast<QIOSWindow *>(w->handle())->requestActivateWindow(); break; } } |