From b65159a5ea8db05165b2eaab8e180a12f30063e4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 11 Jun 2021 14:17:35 +0200 Subject: Deliver WindowActivate/Deactivate events to QWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need those events to trigger palette color group changes in QQuickItem without having to connect every item to yet another QWindow signal. Task-number: QTBUG-93752 Pick-to: 6.2 Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index d4644c05ac..10e0d450b9 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -109,6 +109,7 @@ private slots: void testBlockingWindowShownAfterModalDialog(); void generatedMouseMove(); void keepPendingUpdateRequests(); + void activateDeactivateEvent(); private: QPoint m_availableTopLeft; @@ -2604,6 +2605,48 @@ void tst_QWindow::keepPendingUpdateRequests() QTRY_VERIFY(!platformWindow->hasPendingUpdateRequest()); } +void tst_QWindow::activateDeactivateEvent() +{ + class Window : public QWindow + { + public: + using QWindow::QWindow; + + int activateCount = 0; + int deactivateCount = 0; + protected: + bool event(QEvent *e) + { + switch (e->type()) { + case QEvent::WindowActivate: + ++activateCount; + break; + case QEvent::WindowDeactivate: + ++deactivateCount; + break; + default: + break; + } + return QWindow::event(e); + } + }; + + Window w1; + Window w2; + + w1.show(); + w1.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&w1)); + QCOMPARE(w1.activateCount, 1); + QCOMPARE(w1.deactivateCount, 0); + + w2.show(); + w2.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&w2)); + QCOMPARE(w1.deactivateCount, 1); + QCOMPARE(w2.activateCount, 1); +} + #include QTEST_MAIN(tst_QWindow) -- cgit v1.2.3