From a8a53c651b198a9b8bac3dfe9a81e805ae0b1693 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 30 Jan 2024 00:04:57 +0200 Subject: [PATCH] Port away the remaining users of windowShown/windowHidden to hiddenChanged --- autotests/integration/inputmethod_test.cpp | 4 ++-- .../integration/layershellv1window_test.cpp | 19 +++++++++---------- .../integration/move_resize_window_test.cpp | 2 +- autotests/integration/screenedges_test.cpp | 19 +++++++++---------- src/effect/effectwindow.cpp | 11 ++++++----- src/idle_inhibition.cpp | 3 +-- src/inputmethod.cpp | 5 ++--- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/autotests/integration/inputmethod_test.cpp b/autotests/integration/inputmethod_test.cpp index 4e1e03e1bf..1a8fcfa30c 100644 --- a/autotests/integration/inputmethod_test.cpp +++ b/autotests/integration/inputmethod_test.cpp @@ -213,12 +213,12 @@ void InputMethodTest::testEnableDisableV3() kwinApp()->inputMethod()->hide(); QVERIFY(!keyboardClient->isShown()); - QSignalSpy windowShownSpy(keyboardClient, &Window::windowShown); + QSignalSpy hiddenChangedSpy(keyboardClient, &Window::hiddenChanged); // Force enable the text input object. This is what's done by Gtk. textInputV3->enable(); textInputV3->commit(); - windowShownSpy.wait(); + hiddenChangedSpy.wait(); QVERIFY(keyboardClient->isShown()); // disable text input and ensure that it is not hiding input panel without commit diff --git a/autotests/integration/layershellv1window_test.cpp b/autotests/integration/layershellv1window_test.cpp index 9a2bc4d278..2b91fc9a68 100644 --- a/autotests/integration/layershellv1window_test.cpp +++ b/autotests/integration/layershellv1window_test.cpp @@ -734,25 +734,24 @@ void LayerShellV1WindowTest::testScreenEdge() QVERIFY(window); QVERIFY(!window->isActive()); - QSignalSpy windowShowSpy(window, &Window::windowShown); - QSignalSpy windowHiddenSpy(window, &Window::windowHidden); + QSignalSpy hiddenChangedSpy(window, &Window::hiddenChanged); quint32 timestamp = 0; // The layer surface will be hidden and shown when the screen edge is activated or deactivated. { screenEdge->activate(); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); screenEdge->deactivate(); - QVERIFY(windowShowSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); } // The layer surface will be shown when the screen edge is triggered. { screenEdge->activate(); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); Test::pointerMotion(QPointF(640, 1023), timestamp); @@ -760,7 +759,7 @@ void LayerShellV1WindowTest::testScreenEdge() Test::pointerMotion(QPointF(640, 1023), timestamp); timestamp += 160; Test::pointerMotion(QPointF(640, 512), timestamp); - QVERIFY(windowShowSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); } @@ -768,7 +767,7 @@ void LayerShellV1WindowTest::testScreenEdge() { QSignalSpy approachingSpy(workspace()->screenEdges(), &ScreenEdges::approaching); screenEdge->activate(); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); Test::pointerMotion(QPointF(640, 1020), timestamp++); @@ -777,7 +776,7 @@ void LayerShellV1WindowTest::testScreenEdge() QVERIFY(approachingSpy.last().at(1).toReal() != 0.0); screenEdge->deactivate(); - QVERIFY(windowShowSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); QVERIFY(approachingSpy.last().at(1).toReal() == 0.0); @@ -787,11 +786,11 @@ void LayerShellV1WindowTest::testScreenEdge() // The layer surface will be shown when the screen edge is destroyed. { screenEdge->activate(); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); screenEdge.reset(); - QVERIFY(windowShowSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); } } diff --git a/autotests/integration/move_resize_window_test.cpp b/autotests/integration/move_resize_window_test.cpp index c2347f51f1..92baf93d5f 100644 --- a/autotests/integration/move_resize_window_test.cpp +++ b/autotests/integration/move_resize_window_test.cpp @@ -666,7 +666,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfHiddenX11Panel() QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false).toPoint(), "expectedAdjustedPoint"); // now let's hide the panel - QSignalSpy panelHiddenSpy(panel, &Window::windowHidden); + QSignalSpy panelHiddenSpy(panel, &Window::hiddenChanged); QFETCH(quint32, hideLocation); xcb_change_property(c.get(), XCB_PROP_MODE_REPLACE, windowId, atoms->kde_screen_edge_show, XCB_ATOM_CARDINAL, 32, 1, &hideLocation); xcb_flush(c.get()); diff --git a/autotests/integration/screenedges_test.cpp b/autotests/integration/screenedges_test.cpp index 9cf184602d..fba6118e1e 100644 --- a/autotests/integration/screenedges_test.cpp +++ b/autotests/integration/screenedges_test.cpp @@ -414,15 +414,14 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() ScreenEdgePropertyMonitor screenEdgeMonitor(c.get(), windowId); QSignalSpy withdrawnSpy(&screenEdgeMonitor, &ScreenEdgePropertyMonitor::withdrawn); - QSignalSpy windowShownSpy(window, &Window::windowShown); - QSignalSpy windowHiddenSpy(window, &Window::windowHidden); + QSignalSpy hiddenChangedSpy(window, &Window::hiddenChanged); quint32 timestamp = 0; // The window will be shown when the pointer approaches its reserved screen edge. { enableAutoHide(c.get(), windowId, ElectricBottom); xcb_flush(c.get()); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); Test::pointerMotion(QPointF(640, 1023), timestamp); @@ -439,7 +438,7 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() { enableAutoHide(c.get(), windowId, ElectricBottom); xcb_flush(c.get()); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); Test::touchDown(0, QPointF(640, 1023), timestamp++); @@ -453,7 +452,7 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() { enableAutoHide(c.get(), windowId, ElectricBottom); xcb_flush(c.get()); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); workspace()->screenEdges()->recreateEdges(); @@ -462,7 +461,7 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() enableAutoHide(c.get(), windowId, ElectricNone); xcb_flush(c.get()); - QVERIFY(windowShownSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); } @@ -470,12 +469,12 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() { enableAutoHide(c.get(), windowId, ElectricBottom); xcb_flush(c.get()); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); enableAutoHide(c.get(), windowId, ElectricNone); xcb_flush(c.get()); - QVERIFY(windowShownSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); } @@ -484,7 +483,7 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() QSignalSpy approachingSpy(workspace()->screenEdges(), &ScreenEdges::approaching); enableAutoHide(c.get(), windowId, ElectricBottom); xcb_flush(c.get()); - QVERIFY(windowHiddenSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(!window->isShown()); Test::pointerMotion(QPointF(640, 1020), timestamp++); @@ -494,7 +493,7 @@ void ScreenEdgesTest::testKdeNetWmScreenEdgeShow() enableAutoHide(c.get(), windowId, ElectricNone); xcb_flush(c.get()); - QVERIFY(windowShownSpy.wait()); + QVERIFY(hiddenChangedSpy.wait()); QVERIFY(window->isShown()); QVERIFY(approachingSpy.last().at(1).toReal() == 0.0); diff --git a/src/effect/effectwindow.cpp b/src/effect/effectwindow.cpp index 2d56012402..477f027f1f 100644 --- a/src/effect/effectwindow.cpp +++ b/src/effect/effectwindow.cpp @@ -56,11 +56,12 @@ EffectWindow::EffectWindow(WindowItem *windowItem) d->m_waylandWindow = qobject_cast(d->m_window) != nullptr; d->m_x11Window = qobject_cast(d->m_window) != nullptr; - connect(d->m_window, &Window::windowShown, this, [this]() { - Q_EMIT windowShown(this); - }); - connect(d->m_window, &Window::windowHidden, this, [this]() { - Q_EMIT windowHidden(this); + connect(d->m_window, &Window::hiddenChanged, this, [this]() { + if (d->m_window->isHidden()) { + Q_EMIT windowHidden(this); + } else { + Q_EMIT windowShown(this); + } }); connect(d->m_window, &Window::maximizedChanged, this, [this]() { const MaximizeMode mode = d->m_window->maximizeMode(); diff --git a/src/idle_inhibition.cpp b/src/idle_inhibition.cpp index d091a1f3cb..8923a5915d 100644 --- a/src/idle_inhibition.cpp +++ b/src/idle_inhibition.cpp @@ -42,8 +42,7 @@ void IdleInhibition::registerClient(Window *client) m_connections[client] = connect(client->surface(), &SurfaceInterface::inhibitsIdleChanged, this, updateInhibit); connect(client, &Window::desktopsChanged, this, updateInhibit); connect(client, &Window::minimizedChanged, this, updateInhibit); - connect(client, &Window::windowHidden, this, updateInhibit); - connect(client, &Window::windowShown, this, updateInhibit); + connect(client, &Window::hiddenChanged, this, updateInhibit); connect(client, &Window::closed, this, [this, client]() { uninhibit(client); auto it = m_connections.find(client); diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 8fdbbac031..a1e3cc010b 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -252,10 +252,9 @@ void InputMethod::setPanel(InputPanelV1Window *panel) } }); connect(m_panel, &Window::frameGeometryChanged, this, &InputMethod::updateInputPanelState); - connect(m_panel, &Window::windowHidden, this, &InputMethod::updateInputPanelState); + connect(m_panel, &Window::hiddenChanged, this, &InputMethod::updateInputPanelState); connect(m_panel, &Window::closed, this, &InputMethod::updateInputPanelState); - connect(m_panel, &Window::windowShown, this, &InputMethod::visibleChanged); - connect(m_panel, &Window::windowHidden, this, &InputMethod::visibleChanged); + connect(m_panel, &Window::hiddenChanged, this, &InputMethod::visibleChanged); connect(m_panel, &Window::closed, this, &InputMethod::visibleChanged); Q_EMIT visibleChanged(); updateInputPanelState();