diff options
author | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-10-15 17:33:27 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@digia.com> | 2014-10-20 11:42:30 +0200 |
commit | 3ab4e869e205ecd9bbce46281d6c1cc74da94228 (patch) | |
tree | b414f42870a848861a95eaaa4be4ea24e1c74536 /src/plugins/platforms/ios | |
parent | 31e987f8f02d18717407235947ed60c5ee29d8d7 (diff) |
iOS: Don't auto-activate popup windows unless they are standalone
We try to emulate a traditional window manager by activating windows
on touch press (before delivering the event), and on showing/hiding
windows, but this logic should not apply to popup windows (including
tooltips and tool windows), as they are in most cases already active
through their parent or transient parent, and should not steal keyboard
focus and bring the virtual keyboard down.
Change-Id: If10082bd48cdf1a9e1c41d8809066e86dafd7ffc
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 35 | ||||
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 2 |
3 files changed, 28 insertions, 11 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index 6c52763610..65b4f6dd7d 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -66,6 +66,8 @@ public: void raise() { raiseOrLower(true); } void lower() { raiseOrLower(false); } + + bool shouldAutoActivateWindow() const; void requestActivateWindow(); qreal devicePixelRatio() const; diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index c6997019e2..b0c5f15306 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -117,24 +117,39 @@ void QIOSWindow::setVisible(bool visible) return; } - if (visible) { + if (visible && shouldAutoActivateWindow()) { requestActivateWindow(); - } else { - // Activate top-most visible QWindow: + } else if (!visible && qGuiApp->focusWindow() == window()) { + // 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; for (int i = int(subviews.count) - 1; i >= 0; --i) { UIView *view = [subviews objectAtIndex:i]; - if (!view.hidden) { - QWindow *w = view.qwindow; - if (w && w->isTopLevel()) { - static_cast<QIOSWindow *>(w->handle())->requestActivateWindow(); - break; - } - } + if (view.hidden) + continue; + + QWindow *w = view.qwindow; + if (!w || !w->isTopLevel()) + continue; + + QIOSWindow *iosWindow = static_cast<QIOSWindow *>(w->handle()); + if (!iosWindow->shouldAutoActivateWindow()) + continue; + + iosWindow->requestActivateWindow(); + break; } } } +bool QIOSWindow::shouldAutoActivateWindow() const +{ + // We don't want to do automatic window activation for popup windows + // (including Tool, ToolTip and SplashScreen windows), unless they + // are standalone (no parent/transient parent), and hence not active. + return !(window()->type() & Qt::Popup) || !window()->isActive(); +} + void QIOSWindow::setOpacity(qreal level) { m_view.alpha = qBound(0.0, level, 1.0); diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 81f82ba97d..c46ed4c0b1 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -271,7 +271,7 @@ m_activeTouches[touch].id = m_nextTouchId++; } - if (m_activeTouches.size() == 1) { + if (m_qioswindow->shouldAutoActivateWindow() && m_activeTouches.size() == 1) { QPlatformWindow *topLevel = m_qioswindow; while (QPlatformWindow *p = topLevel->parent()) topLevel = p; |