Turn ScreenLockerWatcher into a KWIN_SINGLETON

It's created together with input, so that the input mechanismn already
has a way to check whether screen is locked.

Effects doesn't hold a member variable any more and instead uses the
singleton instance.
This commit is contained in:
Martin Gräßlin 2016-08-15 08:37:24 +02:00
parent d2a3a10802
commit 490eaadb83
5 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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<QByteArray, qulonglong> m_managedProperties;
Compositor *m_compositor;
Scene *m_scene;
ScreenLockerWatcher *m_screenLockerWatcher;
bool m_desktopRendering;
int m_currentRenderedDesktop;
Xcb::Window m_mouseInterceptionWindow;

View file

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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();

View file

@ -27,6 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
KWIN_SINGLETON_FACTORY(ScreenLockerWatcher)
static const QString SCREEN_LOCKER_SERVICE_NAME = QStringLiteral("org.freedesktop.ScreenSaver");
ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent)

View file

@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
#include <kwinglobals.h>
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)
};
}