diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index 2ab63149dd..677799afff 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -581,12 +581,6 @@ void WaylandServer::initScreenLocker() ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment()); - connect(this, &WaylandServer::shellClientAdded, this, [](AbstractClient *client) { - if (client->isLockScreen()) { - ScreenLocker::KSldApp::self()->lockScreenShown(); - } - }); - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::aboutToLock, this, [this, screenLockerApp]() { if (m_screenLockerClientConnection) { // Already sent data to KScreenLocker. @@ -598,6 +592,8 @@ void WaylandServer::initScreenLocker() } ScreenLocker::KSldApp::self()->setWaylandFd(clientFd); + new LockScreenPresentationWatcher(this); + const QVector seatIfaces = m_display->seats(); for (auto *seat : seatIfaces) { connect(seat, &KWaylandServer::SeatInterface::timestampChanged, @@ -794,4 +790,25 @@ QString WaylandServer::socketName() const return QString(); } +#if KWIN_BUILD_SCREENLOCKER +WaylandServer::LockScreenPresentationWatcher::LockScreenPresentationWatcher(WaylandServer *server) +{ + connect(server, &WaylandServer::shellClientAdded, this, [this](AbstractClient *client) { + if (client->isLockScreen()) { + connect(client->output()->renderLoop(), &RenderLoop::framePresented, this, [this, client]() { + // only signal lockScreenShown once all outputs have been presented at least once + m_signaledOutputs << client->output(); + if (m_signaledOutputs.size() == kwinApp()->platform()->enabledOutputs().size()) { + ScreenLocker::KSldApp::self()->lockScreenShown(); + delete this; + } + }); + } + }); + QTimer::singleShot(1000, this, [this]() { + ScreenLocker::KSldApp::self()->lockScreenShown(); + delete this; + }); +} +#endif } diff --git a/src/wayland_server.h b/src/wayland_server.h index e1d740549d..a20ba65e27 100644 --- a/src/wayland_server.h +++ b/src/wayland_server.h @@ -252,6 +252,16 @@ private: void handleOutputRemoved(AbstractOutput *output); void handleOutputEnabled(AbstractOutput *output); void handleOutputDisabled(AbstractOutput *output); + + class LockScreenPresentationWatcher : public QObject + { + public: + LockScreenPresentationWatcher(WaylandServer *server); + + private: + QSet m_signaledOutputs; + }; + KWaylandServer::Display *m_display = nullptr; KWaylandServer::CompositorInterface *m_compositor = nullptr; KWaylandServer::SeatInterface *m_seat = nullptr;