summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qioswindow.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-10-15 17:33:27 +0200
committerTor Arne Vestbø <tor.arne.vestbo@digia.com>2014-10-20 11:42:30 +0200
commit3ab4e869e205ecd9bbce46281d6c1cc74da94228 (patch)
treeb414f42870a848861a95eaaa4be4ea24e1c74536 /src/plugins/platforms/ios/qioswindow.mm
parent31e987f8f02d18717407235947ed60c5ee29d8d7 (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/qioswindow.mm')
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm35
1 files changed, 25 insertions, 10 deletions
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);