Adapt to new KScreenLocker API

Summary:
KScreenLocker only anymore takes an FD when it tries to lock. The connection
is created and kept internally in KWin.

At the moment we do not do any further checks on the lock but directly hand
over an FD whenever KScreenLocker is about to lock.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28085
This commit is contained in:
Roman Gilg 2020-03-15 22:40:56 +01:00
parent 5e8038a1a1
commit f8bafef294
2 changed files with 43 additions and 7 deletions

View file

@ -505,20 +505,43 @@ void WaylandServer::initWorkspace()
void WaylandServer::initScreenLocker()
{
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
auto *screenLockerApp = ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment());
ScreenLocker::KSldApp::self()->initialize();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this,
[this] () {
m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection();
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::aboutToLock, this,
[this, screenLockerApp] () {
if (m_screenLockerClientConnection) {
// Already sent data to KScreenLocker.
return;
}
int clientFd = createScreenLockerConnection();
if (clientFd < 0) {
return;
}
ScreenLocker::KSldApp::self()->setWaylandFd(clientFd);
for (auto *seat : m_display->seats()) {
connect(seat, &KWayland::Server::SeatInterface::timestampChanged,
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
}
}
);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
[this, screenLockerApp] () {
if (m_screenLockerClientConnection) {
m_screenLockerClientConnection->destroy();
delete m_screenLockerClientConnection;
m_screenLockerClientConnection = nullptr;
}
for (auto *seat : m_display->seats()) {
disconnect(seat, &KWayland::Server::SeatInterface::timestampChanged,
screenLockerApp, &ScreenLocker::KSldApp::userActivity);
}
ScreenLocker::KSldApp::self()->setWaylandFd(-1);
}
);
@ -541,6 +564,18 @@ WaylandServer::SocketPairConnection WaylandServer::createConnection()
return ret;
}
int WaylandServer::createScreenLockerConnection()
{
const auto socket = createConnection();
if (!socket.connection) {
return -1;
}
m_screenLockerClientConnection = socket.connection;
connect(m_screenLockerClientConnection, &KWayland::Server::ClientConnection::disconnected,
this, [this] { m_screenLockerClientConnection = nullptr; });
return socket.fd;
}
int WaylandServer::createXWaylandConnection()
{
const auto socket = createConnection();

View file

@ -242,6 +242,7 @@ Q_SIGNALS:
void foreignTransientChanged(KWayland::Server::SurfaceInterface *child);
private:
int createScreenLockerConnection();
void shellClientShown(Toplevel *t);
quint16 createClientId(KWayland::Server::ClientConnection *c);
void destroyInternalConnection();