From 697ea3ae0057a58f68b50bf761971a472d08289a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 16 Aug 2016 09:26:17 +0200 Subject: [PATCH] Delay query whether screenlocker is registered till WaylandServer is initialized If we try to query before WaylandServer created the KSldApp the service owner change is never delivered. Thus a delay till we know that the service is there on Wayland. On X11 the initialization can be done directly. To know when the WaylandServer is fully initialized an additional signal is added to WaylandServer. --- screenlockerwatcher.cpp | 18 ++++++++++++++---- screenlockerwatcher.h | 1 + wayland_server.cpp | 1 + wayland_server.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/screenlockerwatcher.cpp b/screenlockerwatcher.cpp index c3be0ae62..91c0fde84 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 90717535b..fa4d636a6 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 dc5ca47e1..83709d12a 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 c3c88f439..f2d13ac7e 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();