diff --git a/effects.cpp b/effects.cpp index 4d0ecc5e22..c76f0a3fac 100644 --- a/effects.cpp +++ b/effects.cpp @@ -102,7 +102,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) , next_window_quad_type(EFFECT_QUAD_TYPE_START) , m_compositor(compositor) , m_scene(scene) - , m_screenLockerWatcher(new ScreenLockerWatcher(this)) , m_desktopRendering(false) , m_currentRenderedDesktop(0) , m_effectLoader(new EffectLoader(this)) @@ -201,7 +200,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent); #endif connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching); - connect(m_screenLockerWatcher, &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged); + connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::locked, this, &EffectsHandler::screenLockingChanged); // connect all clients for (Client *c : ws->clientList()) { setupClientConnections(c); @@ -1482,7 +1481,7 @@ QString EffectsHandlerImpl::supportInformation(const QString &name) const bool EffectsHandlerImpl::isScreenLocked() const { - return m_screenLockerWatcher->isLocked(); + return ScreenLockerWatcher::self()->isLocked(); } QString EffectsHandlerImpl::debug(const QString& name, const QString& parameter) const diff --git a/effects.h b/effects.h index 4e8a5a9d82..2551e00f3d 100644 --- a/effects.h +++ b/effects.h @@ -59,7 +59,6 @@ class Compositor; class Deleted; class EffectLoader; class Unmanaged; -class ScreenLockerWatcher; class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler { @@ -289,7 +288,6 @@ private: QHash m_managedProperties; Compositor *m_compositor; Scene *m_scene; - ScreenLockerWatcher *m_screenLockerWatcher; bool m_desktopRendering; int m_currentRenderedDesktop; Xcb::Window m_mouseInterceptionWindow; diff --git a/main.cpp b/main.cpp index 67cfc8e62b..0fbee7e0db 100644 --- a/main.cpp +++ b/main.cpp @@ -30,6 +30,7 @@ along with this program. If not, see . #include "logind.h" #include "options.h" #include "screens.h" +#include "screenlockerwatcher.h" #include "sm.h" #include "workspace.h" #include "xcbutils.h" @@ -268,6 +269,7 @@ void Application::createWorkspace() void Application::createInput() { + ScreenLockerWatcher::create(this); LogindIntegration::create(this); auto input = InputRedirection::create(this); input->init(); diff --git a/screenlockerwatcher.cpp b/screenlockerwatcher.cpp index 5534c5ae9d..c3be0ae621 100644 --- a/screenlockerwatcher.cpp +++ b/screenlockerwatcher.cpp @@ -27,6 +27,8 @@ along with this program. If not, see . namespace KWin { +KWIN_SINGLETON_FACTORY(ScreenLockerWatcher) + static const QString SCREEN_LOCKER_SERVICE_NAME = QStringLiteral("org.freedesktop.ScreenSaver"); ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent) diff --git a/screenlockerwatcher.h b/screenlockerwatcher.h index ed6b79635e..90717535b4 100644 --- a/screenlockerwatcher.h +++ b/screenlockerwatcher.h @@ -22,6 +22,8 @@ along with this program. If not, see . #include +#include + class OrgFreedesktopScreenSaverInterface; class QDBusServiceWatcher; class QDBusPendingCallWatcher; @@ -33,7 +35,6 @@ class ScreenLockerWatcher : public QObject { Q_OBJECT public: - explicit ScreenLockerWatcher(QObject *parent = 0); virtual ~ScreenLockerWatcher(); bool isLocked() const { return m_locked; @@ -50,6 +51,8 @@ private: OrgFreedesktopScreenSaverInterface *m_interface; QDBusServiceWatcher *m_serviceWatcher; bool m_locked; + + KWIN_SINGLETON(ScreenLockerWatcher) }; }