summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qmdisubwindow.cpp8
-rw-r--r--tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp34
2 files changed, 41 insertions, 1 deletions
diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp
index 6516fba..61ea385 100644
--- a/src/gui/widgets/qmdisubwindow.cpp
+++ b/src/gui/widgets/qmdisubwindow.cpp
@@ -160,6 +160,7 @@
#include <QMainWindow>
#include <QScrollBar>
#include <QDebug>
+#include <QScopedValueRollback>
#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
#include <QMacStyle>
#endif
@@ -2795,6 +2796,10 @@ bool QMdiSubWindow::event(QEvent *event)
bool wasShaded = isShaded();
bool wasMinimized = isMinimized();
bool wasMaximized = isMaximized();
+ // Don't emit subWindowActivated, the app doesn't have to know about our hacks
+ const QScopedValueRollback<bool> activationEnabledSaver(d->activationEnabled);
+ d->activationEnabled = false;
+
ensurePolished();
setContentsMargins(0, 0, 0, 0);
if (wasMinimized || wasMaximized || wasShaded)
@@ -3014,7 +3019,8 @@ void QMdiSubWindow::changeEvent(QEvent *changeEvent)
if (d->isActive)
d->ensureWindowState(Qt::WindowActive);
- emit windowStateChanged(oldState, windowState());
+ if (d->activationEnabled)
+ emit windowStateChanged(oldState, windowState());
}
/*!
diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
index 928e2c6..e672ce9 100644
--- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -163,6 +163,7 @@ Q_DECLARE_METATYPE(Qt::WindowState);
Q_DECLARE_METATYPE(Qt::WindowStates);
Q_DECLARE_METATYPE(Qt::WindowType);
Q_DECLARE_METATYPE(Qt::WindowFlags);
+Q_DECLARE_METATYPE(QMdiSubWindow*);
//TESTED_CLASS=
//TESTED_FILES=
@@ -214,6 +215,7 @@ private slots:
void task_182852();
void task_233197();
void task_226929();
+ void styleChange();
};
void tst_QMdiSubWindow::initTestCase()
@@ -2039,6 +2041,38 @@ void tst_QMdiSubWindow::task_226929()
QVERIFY(sub1->isMaximized());
}
+void tst_QMdiSubWindow::styleChange()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QMdiSubWindow *sub1 = mdiArea.addSubWindow(new QTextEdit);
+ sub1->showMaximized();
+
+ QMdiSubWindow *sub2 = mdiArea.addSubWindow(new QTextEdit);
+ sub2->showMinimized();
+
+ mdiArea.setActiveSubWindow(sub1);
+
+ QTest::qWait(100);
+
+ qRegisterMetaType<QMdiSubWindow *>();
+ QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)));
+ QVERIFY(spy.isValid());
+
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(sub1, &event);
+ QApplication::sendEvent(sub2, &event);
+
+ // subWindowActivated should NOT be activated by a style change,
+ // even if internally QMdiSubWindow un-minimizes subwindows temporarily.
+ QCOMPARE(spy.count(), 0);
+}
+
QTEST_MAIN(tst_QMdiSubWindow)
#include "tst_qmdisubwindow.moc"