[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
This commit is contained in:
parent
3d57324ed2
commit
437d35eee2
2 changed files with 16 additions and 16 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue