Commit ebdd6189 authored by Lukáš Tinkl's avatar Lukáš Tinkl
Browse files

listen to the systemd-login1 session's Lock signal

see http://www.freedesktop.org/wiki/Software/systemd/writing-desktop-environments
parent d88a57be
......@@ -34,6 +34,7 @@
#include <KDebug>
#include "powerdevilpolicyagent.h"
#include "screensaver_interface.h"
struct NamedDBusObjectPath
{
......@@ -161,6 +162,15 @@ QString PolicyAgent::getNamedPathProperty(const QString &path, const QString &if
return QString();
}
void PolicyAgent::forceLockAndWait()
{
OrgFreedesktopScreenSaverInterface screenSaveriface("org.freedesktop.ScreenSaver",
"/ScreenSaver",
QDBusConnection::sessionBus());
QDBusPendingReply< void > reply = screenSaveriface.Lock();
reply.waitForFinished();
}
void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
{
if (serviceName == SYSTEMD_LOGIN1_SERVICE) {
......@@ -193,6 +203,8 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
return;
}
// listen to the systemd-login1 session's Lock signal
connect(m_sdSessionInterface.data(), SIGNAL(Lock()), this, SLOT(forceLockAndWait()));
// now let's obtain the seat
QString seatPath = getNamedPathProperty(sessionPath, SYSTEMD_LOGIN1_SESSION_IFACE, "Seat");
......
......@@ -91,6 +91,7 @@ private Q_SLOTS:
void onSessionHandlerUnregistered(const QString & serviceName);
void onActiveSessionChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps);
void onActiveSessionChanged(const QString &activeSession);
void forceLockAndWait();
private:
explicit PolicyAgent(QObject* parent = 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment