diff --git a/screenlockerwatcher.cpp b/screenlockerwatcher.cpp
index c3be0ae621..91c0fde841 100644
--- a/screenlockerwatcher.cpp
+++ b/screenlockerwatcher.cpp
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
#include "screenlockerwatcher.h"
+#include "wayland_server.h"
#include
#include
@@ -36,6 +37,19 @@ ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent)
, m_interface(NULL)
, m_serviceWatcher(new QDBusServiceWatcher(this))
, m_locked(false)
+{
+ if (waylandServer() && waylandServer()->hasScreenLockerIntegration()) {
+ connect(waylandServer(), &WaylandServer::initialized, this, &ScreenLockerWatcher::initialize);
+ } else {
+ initialize();
+ }
+}
+
+ScreenLockerWatcher::~ScreenLockerWatcher()
+{
+}
+
+void ScreenLockerWatcher::initialize()
{
connect(m_serviceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), SLOT(serviceOwnerChanged(QString,QString,QString)));
m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange);
@@ -49,10 +63,6 @@ ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent)
SCREEN_LOCKER_SERVICE_NAME));
}
-ScreenLockerWatcher::~ScreenLockerWatcher()
-{
-}
-
void ScreenLockerWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner)
{
Q_UNUSED(oldOwner)
diff --git a/screenlockerwatcher.h b/screenlockerwatcher.h
index 90717535b4..fa4d636a6a 100644
--- a/screenlockerwatcher.h
+++ b/screenlockerwatcher.h
@@ -48,6 +48,7 @@ private Q_SLOTS:
void serviceRegisteredQueried();
void serviceOwnerQueried();
private:
+ void initialize();
OrgFreedesktopScreenSaverInterface *m_interface;
QDBusServiceWatcher *m_serviceWatcher;
bool m_locked;
diff --git a/wayland_server.cpp b/wayland_server.cpp
index dc5ca47e12..83709d12a4 100644
--- a/wayland_server.cpp
+++ b/wayland_server.cpp
@@ -323,6 +323,7 @@ void WaylandServer::initWorkspace()
ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate);
}
}
+ emit initialized();
}
void WaylandServer::initOutputs()
diff --git a/wayland_server.h b/wayland_server.h
index c3c88f439b..f2d13ac7e7 100644
--- a/wayland_server.h
+++ b/wayland_server.h
@@ -167,6 +167,7 @@ Q_SIGNALS:
void shellClientAdded(KWin::ShellClient*);
void shellClientRemoved(KWin::ShellClient*);
void terminatingInternalClientConnection();
+ void initialized();
private:
void setupX11ClipboardSync();