summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/ios/qioswindow.h5
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm32
2 files changed, 36 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index 1f36c525ce..e7b04c53eb 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -67,6 +67,9 @@ public:
void handleContentOrientationChange(Qt::ScreenOrientation orientation);
void setVisible(bool visible);
+ void raise() { raiseOrLower(true); }
+ void lower() { raiseOrLower(false); }
+
qreal devicePixelRatio() const;
int effectiveWidth() const;
int effectiveHeight() const;
@@ -78,6 +81,8 @@ private:
QRect m_requestedGeometry;
qreal m_devicePixelRatio;
+
+ void raiseOrLower(bool raise);
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index c7c27c08ce..5bb5048b0a 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -153,8 +153,10 @@
{
// Transfer focus to the touched window:
QWindow *window = m_qioswindow->window();
- if (window != QGuiApplication::focusWindow())
+ if (window != QGuiApplication::focusWindow()) {
+ m_qioswindow->raise();
QWindowSystemInterface::handleWindowActivated(window);
+ }
[self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton];
}
@@ -314,6 +316,34 @@ void QIOSWindow::setWindowState(Qt::WindowState state)
}
}
+void QIOSWindow::raiseOrLower(bool raise)
+{
+ // Re-insert m_view at the correct index among its sibling views (QWindows), and ensure
+ // that window flags (staysOnTop, popup) are respected. This function assumes that all
+ // sibling views are sorted correctly. Note: We sort popup and staysOnTop windows at
+ // the same level:
+ if (!isQtApplication())
+ return;
+
+ NSArray *subviews = m_view.superview.subviews;
+ if (subviews.count == 1)
+ return;
+
+ const Qt::WindowFlags topFlag = (Qt::Popup | Qt::WindowStaysOnTopHint) & ~Qt::Dialog;
+ bool thisWindowIsTop = topFlag & window()->flags();
+
+ for (int i = int(subviews.count) - 1; i >= 0; --i) {
+ UIView *view = static_cast<UIView *>([subviews objectAtIndex:i]);
+ bool otherWindowIsTop = topFlag & view.qwindow->flags();
+ if ((raise && (thisWindowIsTop || !otherWindowIsTop))
+ || (!raise && (thisWindowIsTop && !otherWindowIsTop))) {
+ [m_view.superview insertSubview:m_view aboveSubview:view];
+ return;
+ }
+ }
+ [m_view.superview insertSubview:m_view atIndex:0];
+}
+
void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientation)
{
// Keep the status bar in sync with content orientation. This will ensure