Changeset View
Changeset View
Standalone View
Standalone View
screenlockerwatcher.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "screenlockerwatcher.h" | 20 | #include "screenlockerwatcher.h" | ||
21 | #include "wayland_server.h" | 21 | #include "wayland_server.h" | ||
22 | 22 | | |||
23 | #include <QFutureWatcher> | 23 | #include <QFutureWatcher> | ||
24 | #include <QtConcurrentRun> | 24 | #include <QtConcurrentRun> | ||
25 | // dbus generated | 25 | // dbus generated | ||
26 | #include "screenlocker_interface.h" | 26 | #include "screenlocker_interface.h" | ||
27 | #include "kscreenlocker_interface.h" | ||||
27 | 28 | | |||
28 | namespace KWin | 29 | namespace KWin | ||
29 | { | 30 | { | ||
30 | 31 | | |||
31 | KWIN_SINGLETON_FACTORY(ScreenLockerWatcher) | 32 | KWIN_SINGLETON_FACTORY(ScreenLockerWatcher) | ||
32 | 33 | | |||
33 | static const QString SCREEN_LOCKER_SERVICE_NAME = QStringLiteral("org.freedesktop.ScreenSaver"); | 34 | static const QString SCREEN_LOCKER_SERVICE_NAME = QStringLiteral("org.freedesktop.ScreenSaver"); | ||
34 | 35 | | |||
35 | ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent) | 36 | ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent) | ||
36 | : QObject(parent) | 37 | : QObject(parent) | ||
37 | , m_interface(NULL) | | |||
38 | , m_serviceWatcher(new QDBusServiceWatcher(this)) | 38 | , m_serviceWatcher(new QDBusServiceWatcher(this)) | ||
39 | , m_locked(false) | 39 | , m_locked(false) | ||
40 | { | 40 | { | ||
41 | if (waylandServer() && waylandServer()->hasScreenLockerIntegration()) { | 41 | if (waylandServer() && waylandServer()->hasScreenLockerIntegration()) { | ||
42 | connect(waylandServer(), &WaylandServer::initialized, this, &ScreenLockerWatcher::initialize); | 42 | connect(waylandServer(), &WaylandServer::initialized, this, &ScreenLockerWatcher::initialize); | ||
43 | } else { | 43 | } else { | ||
44 | initialize(); | 44 | initialize(); | ||
45 | } | 45 | } | ||
Show All 19 Lines | |||||
65 | 65 | | |||
66 | void ScreenLockerWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | 66 | void ScreenLockerWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | ||
67 | { | 67 | { | ||
68 | Q_UNUSED(oldOwner) | 68 | Q_UNUSED(oldOwner) | ||
69 | if (serviceName != SCREEN_LOCKER_SERVICE_NAME) { | 69 | if (serviceName != SCREEN_LOCKER_SERVICE_NAME) { | ||
70 | return; | 70 | return; | ||
71 | } | 71 | } | ||
72 | delete m_interface; | 72 | delete m_interface; | ||
73 | m_interface = NULL; | 73 | m_interface = nullptr; | ||
74 | delete m_kdeInterface; | ||||
75 | m_kdeInterface = nullptr; | ||||
76 | | ||||
74 | m_locked = false; | 77 | m_locked = false; | ||
75 | if (!newOwner.isEmpty()) { | 78 | if (!newOwner.isEmpty()) { | ||
76 | m_interface = new OrgFreedesktopScreenSaverInterface(newOwner, QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus(), this); | 79 | m_interface = new OrgFreedesktopScreenSaverInterface(newOwner, QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus(), this); | ||
80 | m_kdeInterface = new OrgKdeScreensaverInterface(newOwner, QStringLiteral("/ScreenSaver"), QDBusConnection::sessionBus(), this); | ||||
77 | connect(m_interface, SIGNAL(ActiveChanged(bool)), SLOT(setLocked(bool))); | 81 | connect(m_interface, SIGNAL(ActiveChanged(bool)), SLOT(setLocked(bool))); | ||
78 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(m_interface->GetActive(), this); | 82 | QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(m_interface->GetActive(), this); | ||
79 | connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(activeQueried(QDBusPendingCallWatcher*))); | 83 | connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(activeQueried(QDBusPendingCallWatcher*))); | ||
84 | connect(m_kdeInterface, &OrgKdeScreensaverInterface::AboutToLock, this, &ScreenLockerWatcher::aboutToLock); | ||||
80 | } | 85 | } | ||
81 | } | 86 | } | ||
82 | 87 | | |||
83 | void ScreenLockerWatcher::serviceRegisteredQueried() | 88 | void ScreenLockerWatcher::serviceRegisteredQueried() | ||
84 | { | 89 | { | ||
85 | QFutureWatcher<QDBusReply<bool> > *watcher = dynamic_cast<QFutureWatcher<QDBusReply<bool> > *>(sender()); | 90 | QFutureWatcher<QDBusReply<bool> > *watcher = dynamic_cast<QFutureWatcher<QDBusReply<bool> > *>(sender()); | ||
86 | if (!watcher) { | 91 | if (!watcher) { | ||
87 | return; | 92 | return; | ||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |