iOS: Allow raising and lowering child windows

If the view's superview is not our own QIOSDesktopManagerView
then it's either a child window, or the view of a view controller
that's not our own. In both cases we can skip the logic to include
the window level, as that only applies to Qt top level windows.

Pick-to: 6.5
Change-Id: If8bbf2a79f3be0cbaf6979455b0626b36da71068
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 09cca9539c0a22ee31f048269a274ba81fdbea8c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-12-06 13:14:09 +01:00 committed by Qt Cherry-pick Bot
parent 478ce004af
commit 4f979ec945

View File

@ -301,8 +301,6 @@ void QIOSWindow::requestActivateWindow()
void QIOSWindow::raiseOrLower(bool raise)
{
// Re-insert m_view at the correct index among its sibling views
// (QWindows) according to their current m_windowLevel:
if (!isQtApplication())
return;
@ -310,17 +308,27 @@ void QIOSWindow::raiseOrLower(bool raise)
if (subviews.count == 1)
return;
for (int i = int(subviews.count) - 1; i >= 0; --i) {
UIView *view = static_cast<UIView *>([subviews objectAtIndex:i]);
if (view.hidden || view == m_view || !view.qwindow)
continue;
int level = static_cast<QIOSWindow *>(view.qwindow->handle())->m_windowLevel;
if (m_windowLevel > level || (raise && m_windowLevel == level)) {
[m_view.superview insertSubview:m_view aboveSubview:view];
return;
if (m_view.superview == m_view.qtViewController.view) {
// We're a top level window, so we need to take window
// levels into account.
for (int i = int(subviews.count) - 1; i >= 0; --i) {
UIView *view = static_cast<UIView *>([subviews objectAtIndex:i]);
if (view.hidden || view == m_view || !view.qwindow)
continue;
int level = static_cast<QIOSWindow *>(view.qwindow->handle())->m_windowLevel;
if (m_windowLevel > level || (raise && m_windowLevel == level)) {
[m_view.superview insertSubview:m_view aboveSubview:view];
return;
}
}
[m_view.superview insertSubview:m_view atIndex:0];
} else {
// Child window, or embedded into a non-Qt view controller
if (raise)
[m_view.superview bringSubviewToFront:m_view];
else
[m_view.superview sendSubviewToBack:m_view];
}
[m_view.superview insertSubview:m_view atIndex:0];
}
void QIOSWindow::updateWindowLevel()