diff --git a/wayland_server.cpp b/wayland_server.cpp index e305253750..dd4727727f 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -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(); - } - ); - - 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); + if (m_internalConnection.interfacesAnnounced) { + initScreenLocker(); + } else { + connect(m_internalConnection.registry, &KWayland::Client::Registry::interfacesAnnounced, this, &WaylandServer::initScreenLocker); } + } else { + emit initialized(); + } +} + +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(); + } + ); + + 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(); } ); diff --git a/wayland_server.h b/wayland_server.h index 1c6cab3732..9cd70cc248 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -200,6 +200,7 @@ private: void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config); template 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 {