mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
generic: drop support for locking
first thing first - that feature was not in the spec and still is not, people fucked up at some level and now things like gnome-screensaver are just deprecated, that is the bottom line Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ca07409ebc
commit
accd8f09c3
32 changed files with 71 additions and 558 deletions
|
@ -34,15 +34,16 @@
|
|||
# include <X11/extensions/dpms.h>
|
||||
#endif
|
||||
|
||||
// for reference:
|
||||
// https://specifications.freedesktop.org/idle-inhibit-spec/latest/re01.html
|
||||
|
||||
KScreenSaver::KScreenSaver(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_objectsregistered(false),
|
||||
m_serviceregistered(false),
|
||||
m_havedpms(false),
|
||||
m_dpmsactive(false),
|
||||
m_statetimer(this),
|
||||
m_login1("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()),
|
||||
m_consolekit("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus())
|
||||
m_statetimer(this)
|
||||
{
|
||||
(void)new ScreenSaverAdaptor(this);
|
||||
|
||||
|
@ -72,35 +73,6 @@ KScreenSaver::KScreenSaver(QObject *parent)
|
|||
}
|
||||
m_serviceregistered = true;
|
||||
|
||||
if (m_login1.isValid()) {
|
||||
connection = QDBusConnection::systemBus();
|
||||
connection.connect(
|
||||
"org.freedesktop.login1", "/org/freedesktop/login1/seat/auto", "org.freedesktop.login1.Session", "Lock",
|
||||
this, SLOT(slotLock())
|
||||
);
|
||||
connection.connect(
|
||||
"org.freedesktop.login1", "/org/freedesktop/login1/seat/auto", "org.freedesktop.login1.Session", "Unlock",
|
||||
this, SLOT(slotUnlock())
|
||||
);
|
||||
} else if (m_consolekit.isValid()) {
|
||||
QDBusReply<QDBusObjectPath> reply = m_consolekit.call("GetSessionByPID", uint(::getpid()));
|
||||
if (reply.isValid()) {
|
||||
connection = QDBusConnection::systemBus();
|
||||
const QString consolekitsessionpath = reply.value().path();
|
||||
// qDebug() << Q_FUNC_INFO << consolekitsessionpath;
|
||||
connection.connect(
|
||||
"org.freedesktop.ConsoleKit", consolekitsessionpath, "org.freedesktop.ConsoleKit.Session", "Lock",
|
||||
this, SLOT(slotLock())
|
||||
);
|
||||
connection.connect(
|
||||
"org.freedesktop.ConsoleKit", consolekitsessionpath, "org.freedesktop.ConsoleKit.Session", "Unlock",
|
||||
this, SLOT(slotUnlock())
|
||||
);
|
||||
} else {
|
||||
kWarning() << "Invalid GetSessionByPID reply";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_DPMS
|
||||
int dpmsevent = 0;
|
||||
int dpmserror = 0;
|
||||
|
@ -158,45 +130,6 @@ uint KScreenSaver::GetSessionIdleTime()
|
|||
return KIdleTime::instance()->idleTime();
|
||||
}
|
||||
|
||||
void KScreenSaver::Lock()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
// NOTE: this is known to work only with LightDM
|
||||
QDBusInterface dmiface(
|
||||
QString::fromLatin1("org.freedesktop.DisplayManager"),
|
||||
QString::fromLatin1("/org/freedesktop/DisplayManager"),
|
||||
QString::fromLatin1("org.freedesktop.DisplayManager"),
|
||||
QDBusConnection::systemBus()
|
||||
);
|
||||
if (!dmiface.isValid()) {
|
||||
kWarning() << "Display manager interface is not valid";
|
||||
return;
|
||||
}
|
||||
|
||||
const QString username = KUser().loginName();
|
||||
const QList<QDBusObjectPath> dmsessions = qvariant_cast<QList<QDBusObjectPath>>(dmiface.property("Sessions"));
|
||||
// qDebug() << Q_FUNC_INFO << dmiface.property("Sessions");
|
||||
foreach (const QDBusObjectPath &dmsessionobj, dmsessions) {
|
||||
QDBusInterface dmsessioniface(
|
||||
QString::fromLatin1("org.freedesktop.DisplayManager"),
|
||||
dmsessionobj.path(),
|
||||
QString::fromLatin1("org.freedesktop.DisplayManager.Session"),
|
||||
QDBusConnection::systemBus()
|
||||
);
|
||||
if (!dmsessioniface.isValid()) {
|
||||
kWarning() << "Display manager session interface is not valid";
|
||||
continue;
|
||||
}
|
||||
const QString dmusername = dmsessioniface.property("UserName").toString();
|
||||
// qDebug() << Q_FUNC_INFO << dmusername << username;
|
||||
if (dmusername == username) {
|
||||
dmsessioniface.asyncCall("Lock");
|
||||
return;
|
||||
}
|
||||
}
|
||||
kWarning() << "Could not find session for" << username;
|
||||
}
|
||||
|
||||
bool KScreenSaver::SetActive(bool active)
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << active;
|
||||
|
@ -308,16 +241,4 @@ void KScreenSaver::slotCheckState()
|
|||
#endif // HAVE_DPMS
|
||||
}
|
||||
|
||||
void KScreenSaver::slotLock()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
Lock();
|
||||
}
|
||||
|
||||
void KScreenSaver::slotUnlock()
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO;
|
||||
SetActive(false);
|
||||
}
|
||||
|
||||
#include "moc_kscreensaver.cpp"
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <QObject>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
#include <QDBusInterface>
|
||||
|
||||
class KScreenSaver : public QObject
|
||||
{
|
||||
|
@ -35,8 +34,6 @@ public Q_SLOTS:
|
|||
bool GetActive();
|
||||
uint GetActiveTime();
|
||||
uint GetSessionIdleTime();
|
||||
|
||||
void Lock();
|
||||
bool SetActive(bool active);
|
||||
|
||||
void SimulateUserActivity();
|
||||
|
@ -50,9 +47,6 @@ Q_SIGNALS:
|
|||
private Q_SLOTS:
|
||||
void slotCheckState();
|
||||
|
||||
void slotLock();
|
||||
void slotUnlock();
|
||||
|
||||
private:
|
||||
bool m_objectsregistered;
|
||||
bool m_serviceregistered;
|
||||
|
@ -61,8 +55,6 @@ private:
|
|||
QElapsedTimer m_activetimer;
|
||||
QTimer m_statetimer;
|
||||
QList<uint> m_cookies;
|
||||
QDBusInterface m_login1;
|
||||
QDBusInterface m_consolekit;
|
||||
};
|
||||
|
||||
#endif // KSCREENSAVER_H
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
<signal name="ActiveChanged">
|
||||
<arg type="b"/>
|
||||
</signal>
|
||||
<method name="Lock">
|
||||
</method>
|
||||
<method name="SimulateUserActivity">
|
||||
</method>
|
||||
<method name="GetActive">
|
||||
|
|
|
@ -195,7 +195,6 @@ int main( int argc, char* argv[] )
|
|||
options.add("w");
|
||||
options.add("windowmanager <wm>", ki18n("Starts 'wm' in case no other window manager is \nparticipating in the session. Default is 'kwin'"));
|
||||
options.add("nolocal", ki18n("Also allow remote connections"));
|
||||
options.add("lockscreen", ki18n("Starts the session in locked mode"));
|
||||
KCmdLineArgs::addCmdLineOptions( options );
|
||||
|
||||
::unsetenv("SESSION_MANAGER");
|
||||
|
@ -226,7 +225,7 @@ int main( int argc, char* argv[] )
|
|||
only_local = false;
|
||||
#endif
|
||||
|
||||
KSMServer *server = new KSMServer( wm, only_local, args->isSet("lockscreen") );
|
||||
KSMServer *server = new KSMServer( wm, only_local );
|
||||
|
||||
KCrash::setFlags(KCrash::Log);
|
||||
|
||||
|
|
|
@ -551,17 +551,12 @@ static Status KSMNewClientProc ( SmsConn conn, SmPointer manager_data,
|
|||
extern "C" int _IceTransNoListen(const char * protocol);
|
||||
#endif
|
||||
|
||||
KSMServer::KSMServer( const QString& windowManager, bool _only_local, bool lockscreen )
|
||||
KSMServer::KSMServer( const QString& windowManager, bool _only_local )
|
||||
: wmProcess( new QProcess( this ) )
|
||||
, sessionGroup( "" )
|
||||
, logoutEffectWidget( NULL )
|
||||
, inhibitCookie(0)
|
||||
{
|
||||
if (lockscreen) {
|
||||
QDBusInterface screensaver("org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver");
|
||||
screensaver.asyncCall("Lock");
|
||||
}
|
||||
|
||||
new KSMServerInterfaceAdaptor( this );
|
||||
QDBusConnection::sessionBus().registerObject("/KSMServer", this);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class KSMServer : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KSMServer( const QString& windowManager, bool only_local, bool lockscreen = false );
|
||||
KSMServer( const QString& windowManager, bool only_local );
|
||||
~KSMServer();
|
||||
|
||||
static KSMServer* self();
|
||||
|
|
|
@ -134,10 +134,6 @@ qt4_add_dbus_interface(kwin_SRCS
|
|||
${CMAKE_SOURCE_DIR}/ksmserver/org.kde.KSMServerInterface.xml
|
||||
ksmserver_interface
|
||||
)
|
||||
qt4_add_dbus_interface(kwin_SRCS
|
||||
${CMAKE_SOURCE_DIR}/kscreensaver/org.freedesktop.ScreenSaver.xml
|
||||
screenlocker_interface
|
||||
)
|
||||
|
||||
########### target link libraries ###############
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "workspace.h"
|
||||
#include "composite.h"
|
||||
#include "xcbutils.h"
|
||||
// dbus generated
|
||||
#include "screenlocker_interface.h"
|
||||
|
||||
#include "effects/diminactive/diminactive.h"
|
||||
#include "effects/dimscreen/dimscreen.h"
|
||||
|
@ -82,67 +80,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
static const QString SCREEN_LOCKER_SERVICE_NAME = QString("org.freedesktop.ScreenSaver");
|
||||
|
||||
ScreenLockerWatcher::ScreenLockerWatcher(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_interface(NULL)
|
||||
, m_serviceWatcher(new QDBusServiceWatcher(this))
|
||||
, m_locked(false)
|
||||
{
|
||||
connect(m_serviceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), SLOT(serviceOwnerChanged(QString,QString,QString)));
|
||||
m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange);
|
||||
m_serviceWatcher->addWatchedService(SCREEN_LOCKER_SERVICE_NAME);
|
||||
// check whether service is registered
|
||||
QDBusConnectionInterface* dbusConnection = QDBusConnection::sessionBus().interface();
|
||||
QDBusReply<bool> reply = dbusConnection->isServiceRegistered(SCREEN_LOCKER_SERVICE_NAME);
|
||||
if (reply.isValid() && reply.value()) {
|
||||
QDBusReply<QString> reply2 = dbusConnection->serviceOwner(SCREEN_LOCKER_SERVICE_NAME);
|
||||
if (reply2.isValid()) {
|
||||
serviceOwnerChanged(SCREEN_LOCKER_SERVICE_NAME, QString(), reply2.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScreenLockerWatcher::~ScreenLockerWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
void ScreenLockerWatcher::serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner)
|
||||
{
|
||||
Q_UNUSED(oldOwner)
|
||||
if (serviceName != SCREEN_LOCKER_SERVICE_NAME) {
|
||||
return;
|
||||
}
|
||||
delete m_interface;
|
||||
m_interface = NULL;
|
||||
m_locked = false;
|
||||
if (!newOwner.isEmpty()) {
|
||||
m_interface = new OrgFreedesktopScreenSaverInterface(newOwner, QString(), QDBusConnection::sessionBus(), this);
|
||||
connect(m_interface, SIGNAL(ActiveChanged(bool)), SLOT(setLocked(bool)));
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(m_interface->GetActive(), this);
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(activeQueried(QDBusPendingCallWatcher*)));
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenLockerWatcher::activeQueried(QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
QDBusPendingReply<bool> reply = *watcher;
|
||||
if (!reply.isError()) {
|
||||
setLocked(reply.value());
|
||||
}
|
||||
watcher->deleteLater();
|
||||
}
|
||||
|
||||
void ScreenLockerWatcher::setLocked(bool activated)
|
||||
{
|
||||
if (m_locked == activated) {
|
||||
return;
|
||||
}
|
||||
m_locked = activated;
|
||||
emit locked(m_locked);
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Static
|
||||
|
||||
|
@ -190,7 +127,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)
|
||||
{
|
||||
|
@ -217,7 +153,6 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
|
|||
#ifdef KWIN_BUILD_SCREENEDGES
|
||||
connect(ScreenEdges::self(), SIGNAL(approaching(ElectricBorder,qreal,QRect)), SIGNAL(screenEdgeApproaching(ElectricBorder,qreal,QRect)));
|
||||
#endif
|
||||
connect(m_screenLockerWatcher, SIGNAL(locked(bool)), SIGNAL(screenLockingChanged(bool)));
|
||||
// connect all clients
|
||||
foreach (const Client *c, ws->clientList()) {
|
||||
setupClientConnections(c);
|
||||
|
@ -1384,12 +1319,6 @@ QString EffectsHandlerImpl::supportInformation(const QString &name) const
|
|||
return QString();
|
||||
}
|
||||
|
||||
|
||||
bool EffectsHandlerImpl::isScreenLocked() const
|
||||
{
|
||||
return m_screenLockerWatcher->isLocked();
|
||||
}
|
||||
|
||||
QString EffectsHandlerImpl::debug(const QString& name, const QString& parameter) const
|
||||
{
|
||||
QString internalName = name.startsWith("kwin4_effect_") ? name : "kwin4_effect_" + name;
|
||||
|
|
|
@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QDBusServiceWatcher>
|
||||
|
||||
class KService;
|
||||
class OrgFreedesktopScreenSaverInterface;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -41,7 +40,6 @@ class Client;
|
|||
class Compositor;
|
||||
class Deleted;
|
||||
class Unmanaged;
|
||||
class ScreenLockerWatcher;
|
||||
|
||||
class EffectsHandlerImpl : public EffectsHandler
|
||||
{
|
||||
|
@ -148,7 +146,6 @@ public:
|
|||
virtual EffectFrame* effectFrame(bool staticSize, const QPoint& position, Qt::Alignment alignment) const;
|
||||
|
||||
virtual QVariant kwinOption(KWinOption kwopt);
|
||||
virtual bool isScreenLocked() const;
|
||||
|
||||
// internal (used by kwin core or compositing code)
|
||||
void startPaint();
|
||||
|
@ -235,7 +232,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;
|
||||
|
@ -348,27 +344,6 @@ private:
|
|||
Scene::EffectFrame* m_sceneFrame;
|
||||
};
|
||||
|
||||
class ScreenLockerWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScreenLockerWatcher(QObject *parent = 0);
|
||||
virtual ~ScreenLockerWatcher();
|
||||
bool isLocked() const {
|
||||
return m_locked;
|
||||
}
|
||||
Q_SIGNALS:
|
||||
void locked(bool locked);
|
||||
private Q_SLOTS:
|
||||
void setLocked(bool activated);
|
||||
void activeQueried(QDBusPendingCallWatcher *watcher);
|
||||
void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
|
||||
private:
|
||||
OrgFreedesktopScreenSaverInterface *m_interface;
|
||||
QDBusServiceWatcher *m_serviceWatcher;
|
||||
bool m_locked;
|
||||
};
|
||||
|
||||
inline
|
||||
QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
|
||||
{
|
||||
|
|
|
@ -260,7 +260,7 @@ void HighlightWindowEffect::finishHighlighting()
|
|||
|
||||
bool HighlightWindowEffect::isActive() const
|
||||
{
|
||||
return !(m_windowOpacity.isEmpty() || effects->isScreenLocked());
|
||||
return !m_windowOpacity.isEmpty();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -56,7 +56,6 @@ MouseMarkEffect::MouseMarkEffect()
|
|||
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearLast()));
|
||||
connect(effects, SIGNAL(mouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)),
|
||||
this, SLOT(slotMouseChanged(QPoint,QPoint,Qt::MouseButtons,Qt::MouseButtons,Qt::KeyboardModifiers,Qt::KeyboardModifiers)));
|
||||
connect(effects, SIGNAL(screenLockingChanged(bool)), SLOT(screenLockingChanged(bool)));
|
||||
reconfigure(ReconfigureAll);
|
||||
arrow_start = NULL_POINT;
|
||||
effects->startMousePolling(); // We require it to detect activation as well
|
||||
|
@ -202,22 +201,9 @@ MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPoint arrow_start, QPoint ar
|
|||
return ret;
|
||||
}
|
||||
|
||||
void MouseMarkEffect::screenLockingChanged(bool locked)
|
||||
{
|
||||
if (!marks.isEmpty() || !drawing.isEmpty()) {
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
// disable mouse polling while screen is locked.
|
||||
if (locked) {
|
||||
effects->stopMousePolling();
|
||||
} else {
|
||||
effects->startMousePolling();
|
||||
}
|
||||
}
|
||||
|
||||
bool MouseMarkEffect::isActive() const
|
||||
{
|
||||
return (!marks.isEmpty() || !drawing.isEmpty()) && !effects->isScreenLocked();
|
||||
return (!marks.isEmpty() || !drawing.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ private slots:
|
|||
void slotMouseChanged(const QPoint& pos, const QPoint& old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void screenLockingChanged(bool locked);
|
||||
private:
|
||||
typedef QVector< QPoint > Mark;
|
||||
static Mark createArrow(QPoint arrow_start, QPoint arrow_end);
|
||||
|
|
|
@ -37,7 +37,6 @@ TaskbarThumbnailEffect::TaskbarThumbnailEffect()
|
|||
connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
|
||||
connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(KWin::EffectWindow*,QRect)));
|
||||
connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long)));
|
||||
connect(effects, SIGNAL(screenLockingChanged(bool)), SLOT(screenLockingChanged()));
|
||||
}
|
||||
|
||||
TaskbarThumbnailEffect::~TaskbarThumbnailEffect()
|
||||
|
@ -140,16 +139,9 @@ void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a)
|
|||
}
|
||||
}
|
||||
|
||||
void TaskbarThumbnailEffect::screenLockingChanged()
|
||||
{
|
||||
foreach (EffectWindow *window, thumbnails.uniqueKeys()) {
|
||||
window->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskbarThumbnailEffect::isActive() const
|
||||
{
|
||||
return !thumbnails.isEmpty() && !effects->isScreenLocked();
|
||||
return !thumbnails.isEmpty();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -45,7 +45,6 @@ public Q_SLOTS:
|
|||
void slotWindowDeleted(KWin::EffectWindow *w);
|
||||
void slotWindowDamaged(KWin::EffectWindow* w, const QRect& damage);
|
||||
void slotPropertyNotify(KWin::EffectWindow *w, long atom);
|
||||
void screenLockingChanged();
|
||||
private:
|
||||
struct Data {
|
||||
Window window; // thumbnail of this window
|
||||
|
|
|
@ -40,7 +40,6 @@ ThumbnailAsideEffect::ThumbnailAsideEffect()
|
|||
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
||||
connect(effects, SIGNAL(windowGeometryShapeChanged(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowGeometryShapeChanged(KWin::EffectWindow*,QRect)));
|
||||
connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(KWin::EffectWindow*,QRect)));
|
||||
connect(effects, SIGNAL(screenLockingChanged(bool)), SLOT(repaintAll()));
|
||||
reconfigure(ReconfigureAll);
|
||||
}
|
||||
|
||||
|
@ -182,7 +181,7 @@ void ThumbnailAsideEffect::repaintAll()
|
|||
|
||||
bool ThumbnailAsideEffect::isActive() const
|
||||
{
|
||||
return !windows.isEmpty() && !effects->isScreenLocked();
|
||||
return !windows.isEmpty();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -208,7 +208,6 @@ void KWinScreenEdgesConfig::monitorLoadAction(ElectricBorder edge, const QString
|
|||
KConfigGroup config(m_config, "ElectricBorders");
|
||||
QString lowerName = config.readEntry(configName, "None").toLower();
|
||||
if (lowerName == "showdesktop") monitorChangeEdge(edge, ElectricActionShowDesktop);
|
||||
else if (lowerName == "lockscreen") monitorChangeEdge(edge, ElectricActionLockScreen);
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfig::monitorLoad()
|
||||
|
|
|
@ -802,18 +802,6 @@ public:
|
|||
**/
|
||||
virtual void reloadEffect(Effect *effect) = 0;
|
||||
|
||||
/**
|
||||
* Whether the screen is currently considered as locked.
|
||||
* Note for technical reasons this is not always possible to detect. The screen will only
|
||||
* be considered as locked if the screen locking process implements the
|
||||
* org.freedesktop.ScreenSaver interface.
|
||||
*
|
||||
* @returns @c true if the screen is currently locked, @c false otherwise
|
||||
* @see screenLockingChanged
|
||||
* @since 4.11
|
||||
**/
|
||||
virtual bool isScreenLocked() const = 0;
|
||||
|
||||
/**
|
||||
* Sends message over DCOP to reload given effect.
|
||||
* @param effectname effect's name without "kwin4_effect_" prefix.
|
||||
|
@ -1031,13 +1019,6 @@ Q_SIGNALS:
|
|||
**/
|
||||
void screenGeometryChanged(const QSize &size);
|
||||
|
||||
/**
|
||||
* This signal is emitted when the screen got locked or unlocked.
|
||||
* @param locked @c true if the screen is now locked, @c false if it is now unlocked
|
||||
* @since 4.11
|
||||
**/
|
||||
void screenLockingChanged(bool locked);
|
||||
|
||||
/**
|
||||
* This signels is emitted when ever the stacking order is change, ie. a window is risen
|
||||
* or lowered
|
||||
|
|
|
@ -73,7 +73,6 @@ enum ElectricBorder {
|
|||
enum ElectricBorderAction {
|
||||
ElectricActionNone = 0, // No special action, not set, desktop switch or an effect
|
||||
ElectricActionShowDesktop = 1, // Show desktop or restore
|
||||
ElectricActionLockScreen = 2, // Lock screen
|
||||
ELECTRIC_ACTION_COUNT = 3
|
||||
};
|
||||
|
||||
|
|
|
@ -195,11 +195,6 @@ bool Edge::handleAction()
|
|||
Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop());
|
||||
return true;
|
||||
}
|
||||
case ElectricActionLockScreen: { // Lock the screen
|
||||
QDBusInterface screenSaver("org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver");
|
||||
screenSaver.asyncCall("Lock");
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -574,8 +569,6 @@ static ElectricBorderAction electricBorderAction(const QString& name)
|
|||
QString lowerName = name.toLower();
|
||||
if (lowerName == "showdesktop") {
|
||||
return ElectricActionShowDesktop;
|
||||
} else if (lowerName == "lockscreen") {
|
||||
return ElectricActionLockScreen;
|
||||
}
|
||||
return ElectricActionNone;
|
||||
}
|
||||
|
|
|
@ -432,14 +432,3 @@ bool KDisplayManager::switchVT(int vt)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
void KDisplayManager::lockSwitchVT(int vt)
|
||||
{
|
||||
// Lock first, otherwise the lock won't be able to kick in until the session is re-activated.
|
||||
QDBusInterface saveriface(
|
||||
"org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver"
|
||||
);
|
||||
saveriface.call("Lock");
|
||||
|
||||
switchVT(vt);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
void newSession();
|
||||
bool localSessions(SessList &list);
|
||||
bool switchVT(int vt);
|
||||
void lockSwitchVT(int vt);
|
||||
|
||||
static QString sess2Str(const SessEnt &se);
|
||||
|
||||
|
|
|
@ -140,15 +140,6 @@ static KIcon kRecentIcon(const QString &name)
|
|||
return KIcon(s_recenticon);
|
||||
}
|
||||
|
||||
static void kLockScreen()
|
||||
{
|
||||
QDBusInterface screensaver(
|
||||
"org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver",
|
||||
QDBusConnection::sessionBus()
|
||||
);
|
||||
screensaver.call("Lock");
|
||||
}
|
||||
|
||||
static QStringList kAllowedRunners(KConfigGroup configgroup)
|
||||
{
|
||||
QStringList result;
|
||||
|
@ -1293,7 +1284,6 @@ private Q_SLOTS:
|
|||
void slotUpdateLayout();
|
||||
void slotActivated();
|
||||
void slotTimeout();
|
||||
void slotDelayedLock();
|
||||
void slotDelayedSwitch();
|
||||
|
||||
private:
|
||||
|
@ -1303,7 +1293,6 @@ private:
|
|||
QList<LauncherWidget*> m_launcherwidgets;
|
||||
Plasma::Separator* m_systemseparator;
|
||||
QTimer* m_timer;
|
||||
bool m_canlock;
|
||||
bool m_canswitch;
|
||||
bool m_canreboot;
|
||||
bool m_canshutdown;
|
||||
|
@ -1315,7 +1304,6 @@ LauncherLeave::LauncherLeave(QGraphicsWidget *parent, LauncherApplet *launcherap
|
|||
m_launcherapplet(launcherapplet),
|
||||
m_systemseparator(nullptr),
|
||||
m_timer(nullptr),
|
||||
m_canlock(false),
|
||||
m_canswitch(false),
|
||||
m_canreboot(false),
|
||||
m_canshutdown(false)
|
||||
|
@ -1359,21 +1347,6 @@ void LauncherLeave::slotUpdateLayout()
|
|||
|
||||
const QSizeF iconsize = kIconSize();
|
||||
bool hassessionicon = false;
|
||||
if (m_canlock) {
|
||||
LauncherWidget* launcherwidget = new LauncherWidget(this);
|
||||
launcherwidget->setup(
|
||||
iconsize, KIcon("system-lock-screen"), i18n("Lock"), i18n("Lock screen")
|
||||
);
|
||||
launcherwidget->setData("lock");
|
||||
launcherwidget->disableAnimations();
|
||||
m_launcherwidgets.append(launcherwidget);
|
||||
m_layout->addItem(launcherwidget);
|
||||
connect(
|
||||
launcherwidget, SIGNAL(activated()),
|
||||
this, SLOT(slotActivated())
|
||||
);
|
||||
hassessionicon = true;
|
||||
}
|
||||
if (m_canswitch) {
|
||||
LauncherWidget* launcherwidget = new LauncherWidget(this);
|
||||
launcherwidget->setup(
|
||||
|
@ -1486,9 +1459,7 @@ void LauncherLeave::slotActivated()
|
|||
LauncherWidget* launcherwidget = qobject_cast<LauncherWidget*>(sender());
|
||||
const QString launcherwidgetdata = launcherwidget->data();
|
||||
m_launcherapplet->resetState();
|
||||
if (launcherwidgetdata == QLatin1String("lock")) {
|
||||
QTimer::singleShot(s_leavedelay, this, SLOT(slotDelayedLock()));
|
||||
} else if (launcherwidgetdata == QLatin1String("switch")) {
|
||||
if (launcherwidgetdata == QLatin1String("switch")) {
|
||||
QTimer::singleShot(s_leavedelay, this, SLOT(slotDelayedSwitch()));
|
||||
} else if (launcherwidgetdata == QLatin1String("suspendram")) {
|
||||
Solid::PowerManagement::requestSleep(Solid::PowerManagement::SuspendState);
|
||||
|
@ -1510,28 +1481,19 @@ void LauncherLeave::slotActivated()
|
|||
|
||||
void LauncherLeave::slotTimeout()
|
||||
{
|
||||
const bool oldcanlock = m_canlock;
|
||||
const bool oldcanswitch = m_canswitch;
|
||||
const bool oldcanreboot = m_canreboot;
|
||||
const bool oldcanshutdown = m_canshutdown;
|
||||
m_canlock = KDBusConnectionPool::isServiceRegistered("org.freedesktop.ScreenSaver", QDBusConnection::sessionBus());
|
||||
m_canswitch = m_displaymanager.isSwitchable();
|
||||
m_canreboot = KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot);
|
||||
m_canshutdown = KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt);
|
||||
if (oldcanlock != m_canlock || oldcanswitch != m_canswitch ||
|
||||
oldcanreboot != m_canreboot || oldcanshutdown != m_canshutdown) {
|
||||
if (oldcanswitch != m_canswitch || oldcanreboot != m_canreboot || oldcanshutdown != m_canshutdown) {
|
||||
slotUpdateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherLeave::slotDelayedLock()
|
||||
{
|
||||
kLockScreen();
|
||||
}
|
||||
|
||||
void LauncherLeave::slotDelayedSwitch()
|
||||
{
|
||||
kLockScreen();
|
||||
m_displaymanager.newSession();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,19 +38,16 @@
|
|||
static const int s_spacing = 4;
|
||||
// even panels do not get bellow that
|
||||
static const QSizeF s_basesize = QSizeF(10, 10);
|
||||
static const bool s_showlock = true;
|
||||
static const bool s_showswitch = true;
|
||||
static const bool s_showshutdown = true;
|
||||
static const bool s_showtoram = true;
|
||||
static const bool s_showtodisk = true;
|
||||
static const bool s_showhybrid = true;
|
||||
static const bool s_confirmlock = true;
|
||||
static const bool s_confirmswitch = true;
|
||||
static const bool s_confirmshutdown = true;
|
||||
static const bool s_confirmtoram = true;
|
||||
static const bool s_confirmtodisk = true;
|
||||
static const bool s_confirmhybrid = true;
|
||||
static const QString s_screensaver = QString::fromLatin1("org.freedesktop.ScreenSaver");
|
||||
// delay for the dialog animation to complete. the animation duration is 250ms but the delay here
|
||||
// is intentionally 500ms, see:
|
||||
// kwin/effects/slide/slide.cpp
|
||||
|
@ -216,33 +213,28 @@ void LockoutDialog::slotNo()
|
|||
LockoutApplet::LockoutApplet(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Applet(parent, args),
|
||||
m_layout(nullptr),
|
||||
m_lockwidget(nullptr),
|
||||
m_switchwidget(nullptr),
|
||||
m_shutdownwidget(nullptr),
|
||||
m_toramwidget(nullptr),
|
||||
m_todiskwidget(nullptr),
|
||||
m_hybridwidget(nullptr),
|
||||
m_showlock(s_showlock),
|
||||
m_showswitch(s_showswitch),
|
||||
m_showshutdown(s_showshutdown),
|
||||
m_showtoram(s_showtoram),
|
||||
m_showtodisk(s_showtodisk),
|
||||
m_showhybrid(s_showhybrid),
|
||||
m_confirmlock(s_confirmlock),
|
||||
m_confirmswitch(s_confirmswitch),
|
||||
m_confirmshutdown(s_confirmshutdown),
|
||||
m_confirmtoram(s_confirmtoram),
|
||||
m_confirmtodisk(s_confirmtodisk),
|
||||
m_confirmhybrid(s_confirmhybrid),
|
||||
m_buttonsmessage(nullptr),
|
||||
m_lockbox(nullptr),
|
||||
m_switchbox(nullptr),
|
||||
m_shutdownbox(nullptr),
|
||||
m_torambox(nullptr),
|
||||
m_todiskbox(nullptr),
|
||||
m_hybridbox(nullptr),
|
||||
m_spacer(nullptr),
|
||||
m_screensaverwatcher(nullptr),
|
||||
m_dialog(nullptr),
|
||||
m_dowhat(LockoutApplet::DoNothing)
|
||||
{
|
||||
|
@ -266,15 +258,6 @@ void LockoutApplet::init()
|
|||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(s_spacing);
|
||||
|
||||
m_lockwidget = new Plasma::IconWidget(this);
|
||||
m_lockwidget->setIcon("system-lock-screen");
|
||||
m_lockwidget->setToolTip(i18n("Lock the screen"));
|
||||
connect(
|
||||
m_lockwidget, SIGNAL(activated()),
|
||||
this, SLOT(slotLock())
|
||||
);
|
||||
m_layout->addItem(m_lockwidget);
|
||||
|
||||
m_switchwidget = new Plasma::IconWidget(this);
|
||||
m_switchwidget->setIcon("system-switch-user");
|
||||
m_switchwidget->setToolTip(i18n("Start a parallel session as a different user"));
|
||||
|
@ -322,13 +305,11 @@ void LockoutApplet::init()
|
|||
setLayout(m_layout);
|
||||
|
||||
KConfigGroup configgroup = config();
|
||||
m_showlock = configgroup.readEntry("showLockButton", s_showlock);
|
||||
m_showswitch = configgroup.readEntry("showSwitchButton", s_showswitch);
|
||||
m_showshutdown = configgroup.readEntry("showShutdownButton", s_showshutdown);
|
||||
m_showtoram = configgroup.readEntry("showToRamButton", s_showtoram);
|
||||
m_showtodisk = configgroup.readEntry("showToDiskButton", s_showtodisk);
|
||||
m_showhybrid = configgroup.readEntry("showHybridButton", s_showhybrid);
|
||||
m_confirmlock = configgroup.readEntry("confirmLockButton", s_confirmlock);
|
||||
m_confirmswitch = configgroup.readEntry("confirmSwitchButton", s_confirmswitch);
|
||||
m_confirmshutdown = configgroup.readEntry("confirmShutdownButton", s_confirmshutdown);
|
||||
m_confirmtoram = configgroup.readEntry("confirmToRamButton", s_confirmtoram);
|
||||
|
@ -337,19 +318,6 @@ void LockoutApplet::init()
|
|||
|
||||
slotUpdateButtons();
|
||||
|
||||
m_screensaverwatcher = new QDBusServiceWatcher(
|
||||
s_screensaver,
|
||||
QDBusConnection::sessionBus(),
|
||||
QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration
|
||||
);
|
||||
connect(
|
||||
m_screensaverwatcher, SIGNAL(serviceRegistered(QString)),
|
||||
this, SLOT(slotScreensaverRegistered(QString))
|
||||
);
|
||||
connect(
|
||||
m_screensaverwatcher, SIGNAL(serviceUnregistered(QString)),
|
||||
this, SLOT(slotScreensaverUnregistered(QString))
|
||||
);
|
||||
connect(
|
||||
Solid::PowerManagement::notifier(), SIGNAL(supportedSleepStatesChanged()),
|
||||
this, SLOT(slotUpdateButtons())
|
||||
|
@ -370,10 +338,6 @@ void LockoutApplet::createConfigurationInterface(KConfigDialog *parent)
|
|||
)
|
||||
);
|
||||
widgetlayout->addWidget(m_buttonsmessage);
|
||||
m_lockbox = new QCheckBox(widget);
|
||||
m_lockbox->setText(i18n("Show the “Lock” button"));
|
||||
m_lockbox->setChecked(m_showlock);
|
||||
widgetlayout->addWidget(m_lockbox);
|
||||
m_switchbox = new QCheckBox(widget);
|
||||
m_switchbox->setText(i18n("Show the “Switch” button"));
|
||||
m_switchbox->setChecked(m_showswitch);
|
||||
|
@ -402,8 +366,6 @@ void LockoutApplet::createConfigurationInterface(KConfigDialog *parent)
|
|||
|
||||
slotCheckButtons();
|
||||
|
||||
connect(m_lockbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(m_lockbox, SIGNAL(stateChanged(int)), this, SLOT(slotCheckButtons()));
|
||||
connect(m_switchbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(m_switchbox, SIGNAL(stateChanged(int)), this, SLOT(slotCheckButtons()));
|
||||
connect(m_shutdownbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
|
@ -417,10 +379,6 @@ void LockoutApplet::createConfigurationInterface(KConfigDialog *parent)
|
|||
|
||||
widget = new QWidget();
|
||||
widgetlayout = new QVBoxLayout(widget);
|
||||
m_lockconfirmbox = new QCheckBox(widget);
|
||||
m_lockconfirmbox->setText(i18n("Confirm the “Lock” action"));
|
||||
m_lockconfirmbox->setChecked(m_confirmlock);
|
||||
widgetlayout->addWidget(m_lockconfirmbox);
|
||||
m_switchconfirmbox = new QCheckBox(widget);
|
||||
m_switchconfirmbox->setText(i18n("Confirm the “Switch” action"));
|
||||
m_switchconfirmbox->setChecked(m_confirmswitch);
|
||||
|
@ -446,7 +404,6 @@ void LockoutApplet::createConfigurationInterface(KConfigDialog *parent)
|
|||
widget->setLayout(widgetlayout);
|
||||
parent->addPage(widget, i18n("Confirmation"), "task-accepted");
|
||||
|
||||
connect(m_lockconfirmbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(m_switchconfirmbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(m_shutdownconfirmbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
connect(m_toramconfirmbox, SIGNAL(stateChanged(int)), parent, SLOT(settingsModified()));
|
||||
|
@ -508,12 +465,6 @@ void LockoutApplet::constraintsEvent(Plasma::Constraints constraints)
|
|||
|
||||
void LockoutApplet::slotUpdateButtons()
|
||||
{
|
||||
QDBusInterface screensaver(
|
||||
s_screensaver, "/ScreenSaver", s_screensaver,
|
||||
QDBusConnection::sessionBus()
|
||||
);
|
||||
m_lockwidget->setVisible(m_showlock);
|
||||
m_lockwidget->setEnabled(screensaver.isValid());
|
||||
// no signals for these
|
||||
KDisplayManager kdisplaymanager;
|
||||
m_switchwidget->setVisible(m_showswitch);
|
||||
|
@ -530,52 +481,10 @@ void LockoutApplet::slotUpdateButtons()
|
|||
m_hybridwidget->setEnabled(sleepstates.contains(Solid::PowerManagement::HybridSuspendState));
|
||||
}
|
||||
|
||||
void LockoutApplet::slotScreensaverRegistered(const QString &service)
|
||||
{
|
||||
if (service == s_screensaver) {
|
||||
slotUpdateButtons();
|
||||
updateSizes();
|
||||
}
|
||||
}
|
||||
|
||||
void LockoutApplet::slotScreensaverUnregistered(const QString &service)
|
||||
{
|
||||
if (service == s_screensaver) {
|
||||
slotUpdateButtons();
|
||||
updateSizes();
|
||||
}
|
||||
}
|
||||
|
||||
void LockoutApplet::slotLock()
|
||||
{
|
||||
if (m_dowhat != LockoutApplet::DoNothing) {
|
||||
// disallow another action while there is one queued
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_confirmlock) {
|
||||
if (!m_dialog) {
|
||||
m_dialog = new LockoutDialog();
|
||||
} else {
|
||||
m_dialog->interrupt();
|
||||
}
|
||||
m_dialog->setup(
|
||||
QString::fromLatin1("system-lock-screen"),
|
||||
i18n("Lock"),
|
||||
i18n("Do you want to lock?")
|
||||
);
|
||||
if (!m_dialog->exec()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_dowhat = LockoutApplet::DoLock;
|
||||
QTimer::singleShot(s_dodelay, this, SLOT(slotDoIt()));
|
||||
}
|
||||
|
||||
void LockoutApplet::slotSwitch()
|
||||
{
|
||||
if (m_dowhat != LockoutApplet::DoNothing) {
|
||||
// disallow another action while there is one queued
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -690,17 +599,6 @@ void LockoutApplet::slotHybrid()
|
|||
void LockoutApplet::slotDoIt()
|
||||
{
|
||||
switch (m_dowhat) {
|
||||
case LockoutApplet::DoLock: {
|
||||
m_dowhat = LockoutApplet::DoNothing;
|
||||
QDBusInterface screensaver(
|
||||
s_screensaver, "/ScreenSaver", s_screensaver,
|
||||
QDBusConnection::sessionBus()
|
||||
);
|
||||
if (screensaver.isValid()) {
|
||||
screensaver.call("Lock");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LockoutApplet::DoSwitch: {
|
||||
m_dowhat = LockoutApplet::DoNothing;
|
||||
KDisplayManager kdisplaymanager;
|
||||
|
@ -728,9 +626,6 @@ void LockoutApplet::slotDoIt()
|
|||
void LockoutApplet::slotCheckButtons()
|
||||
{
|
||||
int checkedcount = 0;
|
||||
if (m_lockbox->isChecked()) {
|
||||
checkedcount++;
|
||||
}
|
||||
if (m_switchbox->isChecked()) {
|
||||
checkedcount++;
|
||||
}
|
||||
|
@ -748,7 +643,6 @@ void LockoutApplet::slotCheckButtons()
|
|||
}
|
||||
|
||||
if (checkedcount > 1) {
|
||||
m_lockbox->setEnabled(true);
|
||||
m_switchbox->setEnabled(true);
|
||||
m_shutdownbox->setEnabled(true);
|
||||
m_torambox->setEnabled(true);
|
||||
|
@ -757,10 +651,6 @@ void LockoutApplet::slotCheckButtons()
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_lockbox->isChecked()) {
|
||||
m_lockbox->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (m_switchbox->isChecked()) {
|
||||
m_switchbox->setEnabled(false);
|
||||
return;
|
||||
|
@ -784,13 +674,11 @@ void LockoutApplet::slotCheckButtons()
|
|||
|
||||
void LockoutApplet::slotConfigAccepted()
|
||||
{
|
||||
m_showlock = m_lockbox->isChecked();
|
||||
m_showswitch = m_switchbox->isChecked();
|
||||
m_showshutdown = m_shutdownbox->isChecked();
|
||||
m_showtoram = m_torambox->isChecked();
|
||||
m_showtodisk = m_todiskbox->isChecked();
|
||||
m_showhybrid = m_hybridbox->isChecked();
|
||||
m_confirmlock = m_lockconfirmbox->isChecked();
|
||||
m_confirmswitch = m_switchconfirmbox->isChecked();
|
||||
m_confirmshutdown = m_shutdownconfirmbox->isChecked();
|
||||
m_confirmtoram = m_toramconfirmbox->isChecked();
|
||||
|
@ -801,13 +689,11 @@ void LockoutApplet::slotConfigAccepted()
|
|||
updateSizes();
|
||||
|
||||
KConfigGroup configgroup = config();
|
||||
configgroup.writeEntry("showLockButton", m_showlock);
|
||||
configgroup.writeEntry("showSwitchButton", m_showswitch);
|
||||
configgroup.writeEntry("showShutdownButton", m_showshutdown);
|
||||
configgroup.writeEntry("showToRamButton", m_showtoram);
|
||||
configgroup.writeEntry("showToDiskButton", m_showtodisk);
|
||||
configgroup.writeEntry("showHybridButton", m_showhybrid);
|
||||
configgroup.writeEntry("confirmLockButton", m_confirmlock);
|
||||
configgroup.writeEntry("confirmSwitchButton", m_confirmswitch);
|
||||
configgroup.writeEntry("confirmShutdownButton", m_confirmshutdown);
|
||||
configgroup.writeEntry("confirmToRamButton", m_confirmtoram);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <QGraphicsLinearLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QSpacerItem>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/IconWidget>
|
||||
#include <KConfigDialog>
|
||||
|
@ -36,12 +35,11 @@ class LockoutApplet : public Plasma::Applet
|
|||
public:
|
||||
enum DoWhat {
|
||||
DoNothing = 0,
|
||||
DoLock = 1,
|
||||
DoSwitch = 2,
|
||||
DoSwitch = 1,
|
||||
// shutdown is asked for by ksmserver
|
||||
DoToRam = 3,
|
||||
DoToDisk = 4,
|
||||
DoHybrid = 5
|
||||
DoToRam = 2,
|
||||
DoToDisk = 3,
|
||||
DoHybrid = 4
|
||||
};
|
||||
|
||||
LockoutApplet(QObject *parent, const QVariantList &args);
|
||||
|
@ -57,9 +55,6 @@ protected:
|
|||
|
||||
private Q_SLOTS:
|
||||
void slotUpdateButtons();
|
||||
void slotScreensaverRegistered(const QString &service);
|
||||
void slotScreensaverUnregistered(const QString &service);
|
||||
void slotLock();
|
||||
void slotSwitch();
|
||||
void slotShutdown();
|
||||
void slotToRam();
|
||||
|
@ -73,40 +68,34 @@ private:
|
|||
void updateSizes();
|
||||
|
||||
QGraphicsLinearLayout* m_layout;
|
||||
Plasma::IconWidget* m_lockwidget;
|
||||
Plasma::IconWidget* m_switchwidget;
|
||||
Plasma::IconWidget* m_shutdownwidget;
|
||||
Plasma::IconWidget* m_toramwidget;
|
||||
Plasma::IconWidget* m_todiskwidget;
|
||||
Plasma::IconWidget* m_hybridwidget;
|
||||
bool m_showlock;
|
||||
bool m_showswitch;
|
||||
bool m_showshutdown;
|
||||
bool m_showtoram;
|
||||
bool m_showtodisk;
|
||||
bool m_showhybrid;
|
||||
bool m_confirmlock;
|
||||
bool m_confirmswitch;
|
||||
bool m_confirmshutdown;
|
||||
bool m_confirmtoram;
|
||||
bool m_confirmtodisk;
|
||||
bool m_confirmhybrid;
|
||||
KMessageWidget* m_buttonsmessage;
|
||||
QCheckBox* m_lockbox;
|
||||
QCheckBox* m_switchbox;
|
||||
QCheckBox* m_shutdownbox;
|
||||
QCheckBox* m_torambox;
|
||||
QCheckBox* m_todiskbox;
|
||||
QCheckBox* m_hybridbox;
|
||||
QSpacerItem* m_spacer;
|
||||
QCheckBox* m_lockconfirmbox;
|
||||
QCheckBox* m_switchconfirmbox;
|
||||
QCheckBox* m_shutdownconfirmbox;
|
||||
QCheckBox* m_toramconfirmbox;
|
||||
QCheckBox* m_todiskconfirmbox;
|
||||
QCheckBox* m_hybridconfirmbox;
|
||||
QSpacerItem* m_spacer2;
|
||||
QDBusServiceWatcher* m_screensaverwatcher;
|
||||
LockoutDialog* m_dialog;
|
||||
LockoutApplet::DoWhat m_dowhat;
|
||||
};
|
||||
|
|
|
@ -4,11 +4,17 @@ set(contextmenu_SRCS
|
|||
menu.cpp
|
||||
)
|
||||
|
||||
set(screensaver_xml ${CMAKE_SOURCE_DIR}/kscreensaver/org.freedesktop.ScreenSaver.xml)
|
||||
QT4_ADD_DBUS_INTERFACE(contextmenu_SRCS ${screensaver_xml} screensaver_interface)
|
||||
|
||||
kde4_add_plugin(plasma_containmentactions_contextmenu ${contextmenu_SRCS})
|
||||
target_link_libraries(plasma_containmentactions_contextmenu KDE4::plasma KDE4::kio kworkspace)
|
||||
target_link_libraries(plasma_containmentactions_contextmenu
|
||||
KDE4::plasma KDE4::kio
|
||||
kworkspace
|
||||
)
|
||||
|
||||
install(TARGETS plasma_containmentactions_contextmenu DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
install(FILES plasma-containmentactions-contextmenu.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
||||
install(
|
||||
TARGETS plasma_containmentactions_contextmenu
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
FILES plasma-containmentactions-contextmenu.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
|
|
|
@ -35,25 +35,9 @@
|
|||
#include <Plasma/Wallpaper>
|
||||
|
||||
#include "kworkspace/kworkspace.h"
|
||||
#include "screensaver_interface.h"
|
||||
|
||||
// this short delay is due to two issues:
|
||||
// a) KWorkSpace's DBus alls are all syncronous
|
||||
// b) the destrution of the menu that this action is in is delayed
|
||||
//
|
||||
// (a) leads to the menu hanging out where everyone can see it because the even loop doesn't get
|
||||
// returned to allowing it to close.
|
||||
//
|
||||
// (b) leads to a 0ms timer not working since a 0ms timer just appends to the event queue, and then
|
||||
// the menu closing event gets appended to that.
|
||||
//
|
||||
// ergo a timer with small timeout
|
||||
static const int s_actiondelay = 10; // ms
|
||||
|
||||
|
||||
ContextMenu::ContextMenu(QObject *parent, const QVariantList &args)
|
||||
: Plasma::ContainmentActions(parent, args),
|
||||
m_lockScreenAction(0),
|
||||
m_logoutAction(0),
|
||||
m_separator1(0),
|
||||
m_separator2(0),
|
||||
|
@ -77,8 +61,8 @@ void ContextMenu::init(const KConfigGroup &config)
|
|||
} else {
|
||||
actions.insert("configure shortcuts", false);
|
||||
m_actionOrder << "_context" << "add widgets" << "_add panel"
|
||||
<< "manage activities" << "remove" << "lock widgets" << "_sep1"
|
||||
<<"_lock_screen" << "_logout" << "_sep2" << "configure"
|
||||
<< "remove" << "lock widgets" << "_sep1"
|
||||
<< "_logout" << "_sep2" << "configure"
|
||||
<< "configure shortcuts" << "_sep3" << "_wallpaper";
|
||||
disabled.insert("configure shortcuts");
|
||||
}
|
||||
|
@ -97,11 +81,7 @@ void ContextMenu::init(const KConfigGroup &config)
|
|||
if (c->containmentType() == Plasma::Containment::PanelContainment ||
|
||||
c->containmentType() == Plasma::Containment::CustomPanelContainment) {
|
||||
//FIXME: panel does its own config action atm...
|
||||
} else if (!m_lockScreenAction) {
|
||||
m_lockScreenAction = new QAction(i18n("Lock Screen"), this);
|
||||
m_lockScreenAction->setIcon(KIcon("system-lock-screen"));
|
||||
connect(m_lockScreenAction, SIGNAL(triggered(bool)), this, SLOT(startLockScreen()));
|
||||
|
||||
} else if (!m_logoutAction) {
|
||||
m_logoutAction = new QAction(i18n("Leave..."), this);
|
||||
m_logoutAction->setIcon(KIcon("system-shutdown"));
|
||||
connect(m_logoutAction, SIGNAL(triggered(bool)), this, SLOT(startLogout()));
|
||||
|
@ -166,8 +146,6 @@ QAction *ContextMenu::action(const QString &name)
|
|||
if (c->corona() && c->corona()->immutability() == Plasma::Mutable) {
|
||||
return c->corona()->action("add panel");
|
||||
}
|
||||
} else if (name == "_lock_screen") {
|
||||
return m_lockScreenAction;
|
||||
} else if (name == "_logout") {
|
||||
return m_logoutAction;
|
||||
} else {
|
||||
|
@ -177,23 +155,20 @@ QAction *ContextMenu::action(const QString &name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ContextMenu::startLockScreen()
|
||||
{
|
||||
QTimer::singleShot(s_actiondelay, this, SLOT(lockScreen()));
|
||||
}
|
||||
|
||||
void ContextMenu::lockScreen()
|
||||
{
|
||||
QString interface("org.freedesktop.ScreenSaver");
|
||||
org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver", QDBusConnection::sessionBus());
|
||||
if (screensaver.isValid()) {
|
||||
screensaver.Lock();
|
||||
}
|
||||
}
|
||||
|
||||
// this short delay is due to two issues:
|
||||
// a) KWorkSpace's DBus alls are all syncronous
|
||||
// b) the destrution of the menu that this action is in is delayed
|
||||
//
|
||||
// (a) leads to the menu hanging out where everyone can see it because the even loop doesn't get
|
||||
// returned to allowing it to close.
|
||||
//
|
||||
// (b) leads to a 0ms timer not working since a 0ms timer just appends to the event queue, and then
|
||||
// the menu closing event gets appended to that.
|
||||
//
|
||||
// ergo a timer with small timeout
|
||||
void ContextMenu::startLogout()
|
||||
{
|
||||
QTimer::singleShot(s_actiondelay, this, SLOT(logout()));
|
||||
QTimer::singleShot(10, this, SLOT(logout()));
|
||||
}
|
||||
|
||||
void ContextMenu::logout()
|
||||
|
|
|
@ -40,13 +40,10 @@ public:
|
|||
void save(KConfigGroup &config);
|
||||
|
||||
public slots:
|
||||
void startLockScreen();
|
||||
void lockScreen();
|
||||
void startLogout();
|
||||
void logout();
|
||||
|
||||
private:
|
||||
QAction *m_lockScreenAction;
|
||||
QAction *m_logoutAction;
|
||||
QAction *m_separator1;
|
||||
QAction *m_separator2;
|
||||
|
|
|
@ -2,13 +2,19 @@ set(krunner_sessions_SRCS
|
|||
sessionrunner.cpp
|
||||
)
|
||||
|
||||
set(screensaver_xml ${CMAKE_SOURCE_DIR}/kscreensaver/org.freedesktop.ScreenSaver.xml)
|
||||
QT4_ADD_DBUS_INTERFACE(krunner_sessions_SRCS ${screensaver_xml} screensaver_interface)
|
||||
|
||||
kde4_add_plugin(krunner_sessions ${krunner_sessions_SRCS})
|
||||
target_link_libraries(krunner_sessions KDE4::kio KDE4::plasma kworkspace)
|
||||
target_link_libraries(krunner_sessions
|
||||
KDE4::kio
|
||||
KDE4::plasma
|
||||
kworkspace
|
||||
)
|
||||
|
||||
install(TARGETS krunner_sessions DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} )
|
||||
|
||||
install(FILES plasma-runner-sessions.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
||||
install(
|
||||
TARGETS krunner_sessions
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES plasma-runner-sessions.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
|
|
|
@ -49,13 +49,6 @@ SessionRunner::SessionRunner(QObject *parent, const QVariantList &args)
|
|||
)
|
||||
);
|
||||
|
||||
addSyntax(
|
||||
Plasma::RunnerSyntax(
|
||||
i18nc("lock screen command", "lock"),
|
||||
i18n("Locks the current sessions and starts the screen saver")
|
||||
)
|
||||
);
|
||||
|
||||
Plasma::RunnerSyntax rebootSyntax(
|
||||
i18nc("restart computer command", "restart"),
|
||||
i18n("Reboots the computer")
|
||||
|
@ -132,14 +125,6 @@ void SessionRunner::match(Plasma::RunnerContext &context)
|
|||
match.setData(ShutdownAction);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
} else if (term.compare(i18nc("lock screen command", "lock"), Qt::CaseInsensitive) == 0 ||
|
||||
term.compare(QLatin1String("lock"), Qt::CaseInsensitive) == 0) {
|
||||
Plasma::QueryMatch match(this);
|
||||
match.setText(i18n("Lock the screen"));
|
||||
match.setIcon(KIcon("system-lock-screen"));
|
||||
match.setData(LockAction);
|
||||
match.setRelevance(0.9);
|
||||
matches << match;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,18 +185,18 @@ void SessionRunner::run(const Plasma::QueryMatch &match)
|
|||
KWorkSpace::ShutdownType type = KWorkSpace::ShutdownTypeDefault;
|
||||
|
||||
switch (match.data().toInt()) {
|
||||
case LogoutAction:
|
||||
case LogoutAction: {
|
||||
type = KWorkSpace::ShutdownTypeNone;
|
||||
break;
|
||||
case RestartAction:
|
||||
}
|
||||
case RestartAction: {
|
||||
type = KWorkSpace::ShutdownTypeReboot;
|
||||
break;
|
||||
case ShutdownAction:
|
||||
}
|
||||
case ShutdownAction: {
|
||||
type = KWorkSpace::ShutdownTypeHalt;
|
||||
break;
|
||||
case LockAction:
|
||||
lock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != KWorkSpace::ShutdownTypeDefault) {
|
||||
|
@ -222,7 +207,7 @@ void SessionRunner::run(const Plasma::QueryMatch &match)
|
|||
}
|
||||
|
||||
if (!match.data().toString().isEmpty()) {
|
||||
dm.lockSwitchVT(match.data().toString().toInt());
|
||||
dm.switchVT(match.data().toString().toInt());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -246,18 +231,7 @@ void SessionRunner::run(const Plasma::QueryMatch &match)
|
|||
return;
|
||||
}
|
||||
|
||||
lock();
|
||||
dm.newSession();
|
||||
}
|
||||
|
||||
void SessionRunner::lock()
|
||||
{
|
||||
QString interface("org.freedesktop.ScreenSaver");
|
||||
org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver",
|
||||
QDBusConnection::sessionBus());
|
||||
if (screensaver.isValid()) {
|
||||
screensaver.Lock();
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_sessionrunner.cpp"
|
||||
|
|
|
@ -35,8 +35,7 @@ public:
|
|||
enum {
|
||||
LogoutAction = 1,
|
||||
ShutdownAction,
|
||||
RestartAction,
|
||||
LockAction
|
||||
RestartAction
|
||||
};
|
||||
|
||||
SessionRunner(QObject *parent, const QVariantList &args);
|
||||
|
@ -45,8 +44,6 @@ public:
|
|||
void run(const Plasma::QueryMatch &action);
|
||||
|
||||
private:
|
||||
void lock();
|
||||
|
||||
QString m_triggerWord;
|
||||
KDisplayManager dm;
|
||||
};
|
||||
|
|
|
@ -175,11 +175,6 @@ void DesktopToolBox::init()
|
|||
action->setIcon(KIcon("system-shutdown"));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(startLogout()));
|
||||
addTool(action);
|
||||
|
||||
action = new QAction(i18n("Lock Screen"), this);
|
||||
action->setIcon(KIcon("system-lock-screen"));
|
||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(lockScreen()));
|
||||
addTool(action);
|
||||
}
|
||||
|
||||
QSize DesktopToolBox::cornerSize() const
|
||||
|
@ -593,19 +588,6 @@ void DesktopToolBox::adjustBackgroundBorders() const
|
|||
}
|
||||
}
|
||||
|
||||
void DesktopToolBox::lockScreen()
|
||||
{
|
||||
if (m_containment) {
|
||||
m_containment->closeToolBox();
|
||||
} else {
|
||||
setShowing(false);
|
||||
}
|
||||
|
||||
const QString interface("org.freedesktop.ScreenSaver");
|
||||
QDBusInterface screensaver(interface, "/ScreenSaver");
|
||||
screensaver.asyncCall("Lock");
|
||||
}
|
||||
|
||||
void DesktopToolBox::startLogout()
|
||||
{
|
||||
if (m_containment) {
|
||||
|
|
|
@ -80,7 +80,6 @@ protected Q_SLOTS:
|
|||
// basic desktop controls
|
||||
void startLogout();
|
||||
void logout();
|
||||
void lockScreen();
|
||||
|
||||
private:
|
||||
void adjustToolBackerGeometry();
|
||||
|
|
Loading…
Add table
Reference in a new issue