From e6e210c2406e8d4cfe67543871af5fe14a2bda82 Mon Sep 17 00:00:00 2001 From: Morteza Jamshidi Date: Tue, 29 Oct 2024 10:18:00 +0100 Subject: [PATCH] Change window activation order if active window is moved Active window should always be in front of the stack so bring it to the front of the stack if it's not. Pick-to: 6.8 6.9 Fixes: QTBUG-112758 Change-Id: Iff123d1e95f728f51b786106d83a429c111aa6a8 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qmdiarea.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 94a52c7c867..21c2b7474cf 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -772,6 +772,17 @@ void QMdiAreaPrivate::_q_moveTab(int from, int to) Q_UNUSED(to); #else childWindows.move(from, to); + + // Put the active window in front to update activation order. + const int indexToActiveWindow = childWindows.indexOf(active); + if (indexToActiveWindow != -1) { + const int index = indicesToActivatedChildren.indexOf(indexToActiveWindow); + Q_ASSERT(index != -1); + if (index != 0) { // if it's not in front + indicesToActivatedChildren.move(index, 0); + internalRaise(active); + } + } #endif // QT_CONFIG(tabbar) }