Commit 31b5b7f9 authored by Martin Flöser's avatar Martin Flöser

Ensure internal Wayland connection is properly setup before creating LockScreen integration

With the new Wayland only mode we start too fast and it can happen that
the initWithWorkspace is called before the client connection is fully
setup. This would result in a crash in the idletime plugin once it tries
to create a seat.

To prevent this problem the code is split out into a dedicated method
and only invoked if all interfaces have been announced on the internal
connection.

BUG: 385397
FIXED-IN: 5.11.1
parent c27f6dcd
......@@ -330,26 +330,37 @@ void WaylandServer::initWorkspace()
}
if (hasScreenLockerIntegration()) {
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
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();
}
);
if (m_internalConnection.interfacesAnnounced) {
initScreenLocker();
} else {
connect(m_internalConnection.registry, &KWayland::Client::Registry::interfacesAnnounced, this, &WaylandServer::initScreenLocker);
}
} else {
emit initialized();
}
}
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
void WaylandServer::initScreenLocker()
{
ScreenLocker::KSldApp::self();
ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display);
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();
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this,
[this] () {
m_screenLockerClientConnection = nullptr;
}
);
if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) {
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
}
emit initialized();
}
......@@ -521,6 +532,11 @@ void WaylandServer::createInternalConnection()
m_internalConnection.shm = m_internalConnection.registry->createShmPool(name, version, this);
}
);
connect(registry, &Registry::interfacesAnnounced, this,
[this] {
m_internalConnection.interfacesAnnounced = true;
}
);
registry->setup();
}
);
......
......@@ -200,6 +200,7 @@ private:
void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config);
template <class T>
void createSurface(T *surface);
void initScreenLocker();
KWayland::Server::Display *m_display = nullptr;
KWayland::Server::CompositorInterface *m_compositor = nullptr;
KWayland::Server::SeatInterface *m_seat = nullptr;
......@@ -222,6 +223,7 @@ private:
QThread *clientThread = nullptr;
KWayland::Client::Registry *registry = nullptr;
KWayland::Client::ShmPool *shm = nullptr;
bool interfacesAnnounced = false;
} m_internalConnection;
struct {
......
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