mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 10:52:51 +00:00
kscreensaver: implement locking and unlocking on session manager signals
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
907b24be0b
commit
bbd16d2bcf
2 changed files with 42 additions and 2 deletions
|
@ -22,13 +22,17 @@
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kidletime.h>
|
#include <kidletime.h>
|
||||||
|
|
||||||
static const uint ChangeScreenSettings = 4;
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// TODO: fallback to ConsoleKit
|
||||||
|
|
||||||
KScreenSaver::KScreenSaver(QObject *parent)
|
KScreenSaver::KScreenSaver(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_objectsregistered(false),
|
m_objectsregistered(false),
|
||||||
m_serviceregistered(false),
|
m_serviceregistered(false),
|
||||||
m_xscreensaver(nullptr)
|
m_xscreensaver(nullptr),
|
||||||
|
m_login1("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus())
|
||||||
{
|
{
|
||||||
(void)new ScreenSaverAdaptor(this);
|
(void)new ScreenSaverAdaptor(this);
|
||||||
|
|
||||||
|
@ -68,6 +72,25 @@ KScreenSaver::KScreenSaver(QObject *parent)
|
||||||
QString::fromLatin1("xscreensaver-command"),
|
QString::fromLatin1("xscreensaver-command"),
|
||||||
QStringList() << QString::fromLatin1("-watch")
|
QStringList() << QString::fromLatin1("-watch")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (m_login1.isValid()) {
|
||||||
|
QDBusReply<QDBusObjectPath> reply = m_login1.call("GetSessionByPID", uint(::getpid()));
|
||||||
|
if (reply.isValid()) {
|
||||||
|
connection = QDBusConnection::systemBus();
|
||||||
|
const QString login1sessionpath = reply.value().path();
|
||||||
|
// qDebug() << Q_FUNC_INFO << login1sessionpath;
|
||||||
|
connection.connect(
|
||||||
|
"org.freedesktop.login1", login1sessionpath, "org.freedesktop.login1.Session", "Lock",
|
||||||
|
this, SLOT(slotLock())
|
||||||
|
);
|
||||||
|
connection.connect(
|
||||||
|
"org.freedesktop.login1", login1sessionpath, "org.freedesktop.login1.Session", "Unlock",
|
||||||
|
this, SLOT(slotUnlock())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
kWarning() << "Invalid GetSessionByPID reply";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KScreenSaver::~KScreenSaver()
|
KScreenSaver::~KScreenSaver()
|
||||||
|
@ -211,4 +234,16 @@ void KScreenSaver::slotXScreenSaverError()
|
||||||
kWarning() << xscreensaverdata;
|
kWarning() << xscreensaverdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KScreenSaver::slotLock()
|
||||||
|
{
|
||||||
|
// qDebug() << Q_FUNC_INFO;
|
||||||
|
Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KScreenSaver::slotUnlock()
|
||||||
|
{
|
||||||
|
// qDebug() << Q_FUNC_INFO;
|
||||||
|
SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_kscreensaver.cpp"
|
#include "moc_kscreensaver.cpp"
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
|
||||||
class KScreenSaver : public QObject
|
class KScreenSaver : public QObject
|
||||||
{
|
{
|
||||||
|
@ -50,12 +51,16 @@ private Q_SLOTS:
|
||||||
void slotXScreenSaverOutput();
|
void slotXScreenSaverOutput();
|
||||||
void slotXScreenSaverError();
|
void slotXScreenSaverError();
|
||||||
|
|
||||||
|
void slotLock();
|
||||||
|
void slotUnlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_objectsregistered;
|
bool m_objectsregistered;
|
||||||
bool m_serviceregistered;
|
bool m_serviceregistered;
|
||||||
QProcess* m_xscreensaver;
|
QProcess* m_xscreensaver;
|
||||||
QElapsedTimer m_activetimer;
|
QElapsedTimer m_activetimer;
|
||||||
QList<uint> m_inhibitions;
|
QList<uint> m_inhibitions;
|
||||||
|
QDBusInterface m_login1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KSCREENSAVER_H
|
#endif // KSCREENSAVER_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue