summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qioswindow.mm
diff options
context:
space:
mode:
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);