From b4dd1ac6750b2e3a749f815f19132c00313a0a08 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. Fixes: QTBUG-112758 Change-Id: Iff123d1e95f728f51b786106d83a429c111aa6a8 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit e6e210c2406e8d4cfe67543871af5fe14a2bda82) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 34167f6622196afeb3137df9139d0fe7849691d6) --- 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 865efa01917..49079c9866a 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -774,6 +774,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) }