From 437d35eee2421565f505ebe16909349891f31cc6 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Thu, 29 Nov 2018 00:55:44 +0200 Subject: [PATCH] [wayland] Check presence of the inhibitor object when a client is registered in IdleInhibition Summary: Some applications are not able to inhibit the idle behavior because each of them creates an inhibitor object before the corresponding ShellClient object becomes ready for painting. BUG: 401499 FIXED-IN: 5.15.0 Test Plan: idle-inhibit client (from wlroots/examples) works. Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D17227 --- .../integration/idle_inhibition_test.cpp | 12 +++++------ idle_inhibition.cpp | 20 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/autotests/integration/idle_inhibition_test.cpp b/autotests/integration/idle_inhibition_test.cpp index bf3d653a49..66a283039a 100644 --- a/autotests/integration/idle_inhibition_test.cpp +++ b/autotests/integration/idle_inhibition_test.cpp @@ -79,6 +79,7 @@ void TestIdleInhibition::testInhibit_data() 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 @@ void TestIdleInhibition::testInhibit() 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 index 6e78b40122..8606dad21f 100644 --- a/idle_inhibition.cpp +++ b/idle_inhibition.cpp @@ -41,17 +41,15 @@ IdleInhibition::~IdleInhibition() = default; 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 @@ void IdleInhibition::registerShellClient(ShellClient *client) } } ); + + inhibitsIdleChanged(); } void IdleInhibition::inhibit(ShellClient *client)