From 8c0d75403fa68162e30667c6f0491a943bf78280 Mon Sep 17 00:00:00 2001 From: chani Date: Tue, 30 Sep 2008 00:06:59 +0000 Subject: [PATCH] get rid of the "free unlock" concept (although the bool's not dead yet) and actually unlock the screen without quitting. sometimes I wonder what the hell I was thinking when I wrote this stuff... and why nobody pointed out how crazy it was... git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase@866085 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- workspace/krunner/lock/lockprocess.cc | 39 ++++++++++++++++++++++++++++------- workspace/krunner/lock/lockprocess.h | 4 ++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/workspace/krunner/lock/lockprocess.cc b/workspace/krunner/lock/lockprocess.cc index db191add99..ab340ce359 100644 --- a/workspace/krunner/lock/lockprocess.cc +++ b/workspace/krunner/lock/lockprocess.cc @@ -801,6 +801,22 @@ i18n("kcheckpass is unable to operate. Possibly it is not setuid root."); // bool LockProcess::startLock() { + if (loadGreetPlugin()) { + mLocked = true; + KDisplayManager().setLock(true); + lockPlasma(); + return true; + } + return false; +} + +bool LockProcess::loadGreetPlugin() +{ + if (greetPlugin.library) { + //we were locked once before, so all the plugin loading's done already + //FIXME should I be unloading the plugin on unlock instead? + return true; + } for (QStringList::ConstIterator it = mPlugins.begin(); it != mPlugins.end(); ++it) { GreeterPluginHandle plugin; KLibrary *lib = new KLibrary( (*it)[0] == '/' ? *it : "kgreet_" + *it ); @@ -836,9 +852,7 @@ bool LockProcess::startLock() } kDebug(1204) << "GreeterPlugin " << *it << " (" << plugin.info->method << ", " << plugin.info->name << ") loaded"; greetPlugin = plugin; - mLocked = true; - KDisplayManager().setLock( true ); - return true; + return true; } cantLock( i18n("No appropriate greeter plugin configured.") ); return false; @@ -993,10 +1007,14 @@ void LockProcess::newService(QString name) void LockProcess::deactivatePlasma() { - mFreeUnlock = false; if (mPlasmaDBus && mPlasmaDBus->isValid()) { mPlasmaDBus->call(QDBus::NoBlock, "deactivate"); } + if (!mLocked && mLockGrace >=0) { + //I can't remember why we do nothing on mLockGrace=0 + //wouldn't we want to lock immediately? FIXME + QTimer::singleShot(mLockGrace, this, SLOT(startLock())); + } } void LockProcess::lockPlasma() @@ -1008,21 +1026,23 @@ void LockProcess::lockPlasma() void LockProcess::unSuppressUnlock() { + //note: suppressing unlock also now means suppressing quit-on-activity + //maybe some var renaming is in order. mSuppressUnlock.stop(); - mFreeUnlock = false; } +//TODO can we rename this to tryQuit() or attemptExit() or something? void LockProcess::unlock() { mSuppressUnlock.stop(); - if (!mLocked || mFreeUnlock || checkPass()) { + if (!mLocked || checkPass()) { quitSaver(); } } void LockProcess::endFreeUnlock() { - mFreeUnlock = false; + startLock(); //TODO rename or delete this func } void LockProcess::suspend() @@ -1097,7 +1117,10 @@ bool LockProcess::checkPass(const QString &reason) //FIXME do we need to copy&paste that SubstructureNotifyMask code above? if (ret == QDialog::Accepted) { - mFreeUnlock = true; //now we don't need the password for a while + //we don't quit on a custom checkpass, but we do unlock + //so that the user doesn't have to type their password twice + mLocked = false; + KDisplayManager().setLock(false); return true; } return false; diff --git a/workspace/krunner/lock/lockprocess.h b/workspace/krunner/lock/lockprocess.h index 93c329a16c..c14476e152 100644 --- a/workspace/krunner/lock/lockprocess.h +++ b/workspace/krunner/lock/lockprocess.h @@ -135,8 +135,7 @@ private: void stopPlasma(); void setupSignals(); /** - * if the password dialog is not suppressed, this execs it - * if the dialog *is* suppressed we just restart the timer + * exec the password dialog * @return true iff the password was checked and is valid */ bool checkPass(); @@ -155,6 +154,7 @@ private: WindowType windowType(WId id); static QVariant getConf(void *ctx, const char *key, const QVariant &dflt); + bool loadGreetPlugin(); bool mLocked; int mLockGrace; -- 2.11.4.GIT