Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 437d35ee authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[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
parent 3d57324e
......@@ -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> surface(Test::createSurface());
QFETCH(Test::ShellSurfaceType, type);
QScopedPointer<QObject> 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<IdleInhibitor> 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
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment