diff --git a/autotests/integration/idle_inhibition_test.cpp b/autotests/integration/idle_inhibition_test.cpp --- a/autotests/integration/idle_inhibition_test.cpp +++ b/autotests/integration/idle_inhibition_test.cpp @@ -79,6 +79,7 @@ QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; + QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; } void TestIdleInhibition::testInhibit() @@ -93,17 +94,16 @@ QScopedPointer surface(Test::createSurface()); QFETCH(Test::ShellSurfaceType, type); QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); - auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); - QVERIFY(c); - - // not yet inhibited - QVERIFY(!idle->isInhibited()); // now create inhibition on window QScopedPointer inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data())); QVERIFY(inhibitor->isValid()); + + // render the client + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + // this should inhibit our server object - QVERIFY(inhibitedSpy.wait()); QVERIFY(idle->isInhibited()); // deleting the object should uninhibit again diff --git a/idle_inhibition.cpp b/idle_inhibition.cpp --- a/idle_inhibition.cpp +++ b/idle_inhibition.cpp @@ -41,17 +41,15 @@ void IdleInhibition::registerShellClient(ShellClient *client) { - auto surface = client->surface(); - m_connections.insert(client, connect(surface, &SurfaceInterface::inhibitsIdleChanged, this, - [this, client] { - // TODO: only inhibit if the ShellClient is visible - if (client->surface()->inhibitsIdle()) { - inhibit(client); - } else { - uninhibit(client); - } + auto inhibitsIdleChanged = [this, client] { + // TODO: only inhibit if the ShellClient is visible + if (client->surface()->inhibitsIdle()) { + inhibit(client); + } else { + uninhibit(client); } - )); + }; + m_connections[client] = connect(client->surface(), &SurfaceInterface::inhibitsIdleChanged, this, inhibitsIdleChanged); connect(client, &ShellClient::windowClosed, this, [this, client] { uninhibit(client); @@ -62,6 +60,8 @@ } } ); + + inhibitsIdleChanged(); } void IdleInhibition::inhibit(ShellClient *client)