diff --git a/kscreensaver/kscreensaver.cpp b/kscreensaver/kscreensaver.cpp index f1c34924..8c378c8e 100644 --- a/kscreensaver/kscreensaver.cpp +++ b/kscreensaver/kscreensaver.cpp @@ -34,15 +34,16 @@ # include #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 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 dmsessions = qvariant_cast>(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" diff --git a/kscreensaver/kscreensaver.h b/kscreensaver/kscreensaver.h index 6d52b3f2..22f36031 100644 --- a/kscreensaver/kscreensaver.h +++ b/kscreensaver/kscreensaver.h @@ -22,7 +22,6 @@ #include #include #include -#include 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 m_cookies; - QDBusInterface m_login1; - QDBusInterface m_consolekit; }; #endif // KSCREENSAVER_H diff --git a/kscreensaver/org.freedesktop.ScreenSaver.xml b/kscreensaver/org.freedesktop.ScreenSaver.xml index 761871a5..92a1a806 100644 --- a/kscreensaver/org.freedesktop.ScreenSaver.xml +++ b/kscreensaver/org.freedesktop.ScreenSaver.xml @@ -4,8 +4,6 @@ - - diff --git a/ksmserver/main.cpp b/ksmserver/main.cpp index 975d45ac..3956dc81 100644 --- a/ksmserver/main.cpp +++ b/ksmserver/main.cpp @@ -195,7 +195,6 @@ int main( int argc, char* argv[] ) options.add("w"); options.add("windowmanager ", 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); diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp index 029e66b4..39ff9969 100644 --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -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); diff --git a/ksmserver/server.h b/ksmserver/server.h index 2080aa72..95662b3b 100644 --- a/ksmserver/server.h +++ b/ksmserver/server.h @@ -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(); diff --git a/kwin/CMakeLists.txt b/kwin/CMakeLists.txt index 3fabb591..5787df94 100644 --- a/kwin/CMakeLists.txt +++ b/kwin/CMakeLists.txt @@ -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 ############### diff --git a/kwin/effects.cpp b/kwin/effects.cpp index 89049704..36a81a8d 100644 --- a/kwin/effects.cpp +++ b/kwin/effects.cpp @@ -39,8 +39,6 @@ along with this program. If not, see . #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 . 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 reply = dbusConnection->isServiceRegistered(SCREEN_LOCKER_SERVICE_NAME); - if (reply.isValid() && reply.value()) { - QDBusReply 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 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; diff --git a/kwin/effects.h b/kwin/effects.h index d4aa7aea..60b608ad 100644 --- a/kwin/effects.h +++ b/kwin/effects.h @@ -32,7 +32,6 @@ along with this program. If not, see . #include 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 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 EffectsHandlerImpl::elevatedWindows() const { diff --git a/kwin/effects/highlightwindow/highlightwindow.cpp b/kwin/effects/highlightwindow/highlightwindow.cpp index 9b599984..0c4c182a 100644 --- a/kwin/effects/highlightwindow/highlightwindow.cpp +++ b/kwin/effects/highlightwindow/highlightwindow.cpp @@ -260,7 +260,7 @@ void HighlightWindowEffect::finishHighlighting() bool HighlightWindowEffect::isActive() const { - return !(m_windowOpacity.isEmpty() || effects->isScreenLocked()); + return !m_windowOpacity.isEmpty(); } } // namespace diff --git a/kwin/effects/mousemark/mousemark.cpp b/kwin/effects/mousemark/mousemark.cpp index 7503bb46..69934dd0 100644 --- a/kwin/effects/mousemark/mousemark.cpp +++ b/kwin/effects/mousemark/mousemark.cpp @@ -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()); } diff --git a/kwin/effects/mousemark/mousemark.h b/kwin/effects/mousemark/mousemark.h index 36568de2..760c59cd 100644 --- a/kwin/effects/mousemark/mousemark.h +++ b/kwin/effects/mousemark/mousemark.h @@ -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); diff --git a/kwin/effects/taskbarthumbnail/taskbarthumbnail.cpp b/kwin/effects/taskbarthumbnail/taskbarthumbnail.cpp index 7f8c416f..b37b5257 100644 --- a/kwin/effects/taskbarthumbnail/taskbarthumbnail.cpp +++ b/kwin/effects/taskbarthumbnail/taskbarthumbnail.cpp @@ -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 diff --git a/kwin/effects/taskbarthumbnail/taskbarthumbnail.h b/kwin/effects/taskbarthumbnail/taskbarthumbnail.h index 50f70401..2fb6e39d 100644 --- a/kwin/effects/taskbarthumbnail/taskbarthumbnail.h +++ b/kwin/effects/taskbarthumbnail/taskbarthumbnail.h @@ -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 diff --git a/kwin/effects/thumbnailaside/thumbnailaside.cpp b/kwin/effects/thumbnailaside/thumbnailaside.cpp index 52e0ddd0..8c837515 100644 --- a/kwin/effects/thumbnailaside/thumbnailaside.cpp +++ b/kwin/effects/thumbnailaside/thumbnailaside.cpp @@ -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 diff --git a/kwin/kcmkwin/kwinscreenedges/main.cpp b/kwin/kcmkwin/kwinscreenedges/main.cpp index ab19d2af..cd836f8e 100644 --- a/kwin/kcmkwin/kwinscreenedges/main.cpp +++ b/kwin/kcmkwin/kwinscreenedges/main.cpp @@ -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() diff --git a/kwin/libkwineffects/kwineffects.h b/kwin/libkwineffects/kwineffects.h index 05f3c43f..0dfd68b0 100644 --- a/kwin/libkwineffects/kwineffects.h +++ b/kwin/libkwineffects/kwineffects.h @@ -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 diff --git a/kwin/libkwineffects/kwinglobals.h b/kwin/libkwineffects/kwinglobals.h index 3ffb9e7d..ba7c3cd1 100644 --- a/kwin/libkwineffects/kwinglobals.h +++ b/kwin/libkwineffects/kwinglobals.h @@ -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 }; diff --git a/kwin/screenedge.cpp b/kwin/screenedge.cpp index 9e3e820a..34fff3d9 100644 --- a/kwin/screenedge.cpp +++ b/kwin/screenedge.cpp @@ -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; } diff --git a/libs/kworkspace/kdisplaymanager.cpp b/libs/kworkspace/kdisplaymanager.cpp index 1139a83c..eeb4581b 100644 --- a/libs/kworkspace/kdisplaymanager.cpp +++ b/libs/kworkspace/kdisplaymanager.cpp @@ -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); -} diff --git a/libs/kworkspace/kdisplaymanager.h b/libs/kworkspace/kdisplaymanager.h index b9b406f1..fbf0f80e 100644 --- a/libs/kworkspace/kdisplaymanager.h +++ b/libs/kworkspace/kdisplaymanager.h @@ -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); diff --git a/plasma/applets/launcher/launcher.cpp b/plasma/applets/launcher/launcher.cpp index 6217c704..e80858ec 100644 --- a/plasma/applets/launcher/launcher.cpp +++ b/plasma/applets/launcher/launcher.cpp @@ -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 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(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(); } diff --git a/plasma/applets/lockout/lockout.cpp b/plasma/applets/lockout/lockout.cpp index 00a3cf75..e43a8922 100644 --- a/plasma/applets/lockout/lockout.cpp +++ b/plasma/applets/lockout/lockout.cpp @@ -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); diff --git a/plasma/applets/lockout/lockout.h b/plasma/applets/lockout/lockout.h index 78bbab95..d2597b8c 100644 --- a/plasma/applets/lockout/lockout.h +++ b/plasma/applets/lockout/lockout.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -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; }; diff --git a/plasma/containmentactions/contextmenu/CMakeLists.txt b/plasma/containmentactions/contextmenu/CMakeLists.txt index c3bc528d..f814b533 100644 --- a/plasma/containmentactions/contextmenu/CMakeLists.txt +++ b/plasma/containmentactions/contextmenu/CMakeLists.txt @@ -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} +) diff --git a/plasma/containmentactions/contextmenu/menu.cpp b/plasma/containmentactions/contextmenu/menu.cpp index ac9b32ff..e15b9a0a 100644 --- a/plasma/containmentactions/contextmenu/menu.cpp +++ b/plasma/containmentactions/contextmenu/menu.cpp @@ -35,30 +35,14 @@ #include #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), - m_separator3(0), - m_buttons(0) + m_logoutAction(0), + m_separator1(0), + m_separator2(0), + m_separator3(0), + m_buttons(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() diff --git a/plasma/containmentactions/contextmenu/menu.h b/plasma/containmentactions/contextmenu/menu.h index eb716a45..29bc743d 100644 --- a/plasma/containmentactions/contextmenu/menu.h +++ b/plasma/containmentactions/contextmenu/menu.h @@ -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; diff --git a/plasma/runners/sessions/CMakeLists.txt b/plasma/runners/sessions/CMakeLists.txt index cdb3903c..38557db2 100644 --- a/plasma/runners/sessions/CMakeLists.txt +++ b/plasma/runners/sessions/CMakeLists.txt @@ -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} +) diff --git a/plasma/runners/sessions/sessionrunner.cpp b/plasma/runners/sessions/sessionrunner.cpp index d1d392a3..6e1cbc30 100644 --- a/plasma/runners/sessions/sessionrunner.cpp +++ b/plasma/runners/sessions/sessionrunner.cpp @@ -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" diff --git a/plasma/runners/sessions/sessionrunner.h b/plasma/runners/sessions/sessionrunner.h index 16272cfa..15eef9e2 100644 --- a/plasma/runners/sessions/sessionrunner.h +++ b/plasma/runners/sessions/sessionrunner.h @@ -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; }; diff --git a/plasma/toolboxes/desktoptoolbox.cpp b/plasma/toolboxes/desktoptoolbox.cpp index b2baf187..9dcbeb43 100644 --- a/plasma/toolboxes/desktoptoolbox.cpp +++ b/plasma/toolboxes/desktoptoolbox.cpp @@ -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) { diff --git a/plasma/toolboxes/desktoptoolbox.h b/plasma/toolboxes/desktoptoolbox.h index 6d4fc93c..ecf78d28 100644 --- a/plasma/toolboxes/desktoptoolbox.h +++ b/plasma/toolboxes/desktoptoolbox.h @@ -80,7 +80,6 @@ protected Q_SLOTS: // basic desktop controls void startLogout(); void logout(); - void lockScreen(); private: void adjustToolBackerGeometry();