From 19863922558987136c320a08f46e3c3239094b7c Mon Sep 17 00:00:00 2001 From: Nick D'Ademo Date: Sat, 3 Nov 2018 20:11:53 +0800 Subject: [PATCH] QMdiArea: Do not move active subwindow after tile rearrange Currently, a tile rearrange will move the active subwindow (if any) to position zero (top-left). This ignores any tiling order set via setActivationOrder(). This change removes this move so that the set tiling order is respected when a tile operation is performed. Fixes: QTBUG-43356 Change-Id: I2c481f0ffe45e42e811c6b6d476eb4cb65aa5d1f Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qmdiarea.cpp | 8 -------- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index cdc1291511..104cbdbcda 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -954,14 +954,6 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger) } } - if (active && rearranger->type() == Rearranger::RegularTiler && !tileCalledFromResizeEvent) { - // Move active window in front if necessary. That's the case if we - // have any windows with staysOnTopHint set. - int indexToActive = widgets.indexOf((QWidget *)active); - if (indexToActive > 0) - widgets.move(indexToActive, 0); - } - QRect domain = viewport->rect(); if (rearranger->type() == Rearranger::RegularTiler && !widgets.isEmpty()) domain = resizeToMinimumTileSize(minSubWindowSize, widgets.count()); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 8b470fb579..67b79e3faf 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -1689,14 +1689,16 @@ void tst_QMdiArea::tileSubWindows() workspace.setActiveSubWindow(0); QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect()); - // Make sure the active window is placed in top left corner regardless + // Make sure the active window does not move position after a tile regardless // of whether we have any windows with staysOnTopHint or not. + workspace.tileSubWindows(); windows.at(3)->setWindowFlags(windows.at(3)->windowFlags() | Qt::WindowStaysOnTopHint); QMdiSubWindow *activeSubWindow = windows.at(6); workspace.setActiveSubWindow(activeSubWindow); QCOMPARE(workspace.activeSubWindow(), activeSubWindow); + QPoint pos = activeSubWindow->geometry().topLeft(); workspace.tileSubWindows(); - QCOMPARE(activeSubWindow->geometry().topLeft(), QPoint(0, 0)); + QCOMPARE(activeSubWindow->geometry().topLeft(), pos); // Verify that we try to resize the area such that all sub-windows are visible. // It's important that tiled windows are NOT overlapping. @@ -2187,7 +2189,7 @@ void tst_QMdiArea::setActivationOrder_data() list << 2 << 1 << 0 << 1 << 2 << 3 << 4; list2 << 0 << 1 << 2 << 3 << 4; - list3 << 1 << 4 << 3 << 1 << 2 << 0; + list3 << 4 << 3 << 2 << 4 << 1 << 0; // Most recently created window is in top-left position QTest::newRow("CreationOrder") << QMdiArea::CreationOrder << 5 << 3 << 1 << list << list2 << list3; list = QList(); @@ -2195,7 +2197,7 @@ void tst_QMdiArea::setActivationOrder_data() list2 = QList(); list2 << 0 << 2 << 4 << 1 << 3; list3 = QList(); - list3 << 1 << 3 << 4 << 1 << 2 << 0; + list3 << 3 << 1 << 4 << 3 << 2 << 0; // Window with "stays-on-top" flag set will be in the top-left position QTest::newRow("StackingOrder") << QMdiArea::StackingOrder << 5 << 3 << 1 << list << list2 << list3; list = QList();