Commit 3afcbffa authored by David Edmundson's avatar David Edmundson

RFC: Make Switch User option invoke the switch user UI in the lockscreen

Summary:
Instead of having a separate switch user screen, we just invoke the lock
screen with a parameter to default to the switch session page.

This is better because:

- it's a familiar consistent UI to the lockscreen

- It has all the lockscreen features. (Wallpapers, Multiscreen, OSDs)

- Session switching is simpler as we won't have to wait to invoke the
lock screen before switching VTs

- We get rid of one more chunk of rubbish code from ksmserver
(it becomes just KSldApp::self()->lock(DefaultToSwitchUser) instead of a
blocking dialog)

- There's one less lnf component to maintain

However, it does bring the behavioural change that you can't cancel from
the "switch user screen" without entering a password

(argubaly a feature... Switch User locks on some other platforms)

And the session will unconditionally lock when you switch session,
currently it's linked to the config option "Lock screen automatically"

(which is arguably completely wrong anyway, as that config option is
displayed as being about locking after a timeout)

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D2525
parent a355bca0
......@@ -100,6 +100,7 @@ UnlockApp::UnlockApp(int &argc, char **argv)
, m_authenticator(new Authenticator(this))
, m_graceTime(0)
, m_noLock(false)
, m_defaultToSwitchUser(false)
, m_wallpaperIntegration(new WallpaperIntegration(this))
{
connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit);
......@@ -263,6 +264,8 @@ void UnlockApp::desktopResized()
context->setContextProperty(QStringLiteral("authenticator"), m_authenticator);
context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_interfaceVersion"), 2);
context->setContextProperty(QStringLiteral("org_kde_plasma_screenlocker_greeter_view"), view);
context->setContextProperty(QStringLiteral("defaultToSwitchUser"), m_defaultToSwitchUser);
view->setSource(m_mainQmlPath);
// on error, load the fallback lockscreen to not lock the user out of the system
......@@ -564,6 +567,11 @@ void UnlockApp::setNoLock(bool noLock)
m_noLock = noLock;
}
void UnlockApp::setDefaultToSwitchUser(bool defaultToSwitchUser)
{
m_defaultToSwitchUser = defaultToSwitchUser;
}
static void osdProgress(void *data, org_kde_ksld *org_kde_ksld, const char *icon, int32_t percent, const char *text)
{
......
......@@ -60,6 +60,7 @@ public:
void setGraceTime(int milliseconds);
void setNoLock(bool noLock);
void setKsldSocket(int socket);
void setDefaultToSwitchUser(bool defaultToSwitchUser);
void osdProgress(const QString &icon, int percent, const QString &additionalText);
void osdText(const QString &icon, const QString &additionalText);
......@@ -99,6 +100,7 @@ private:
Authenticator *m_authenticator;
int m_graceTime;
bool m_noLock;
bool m_defaultToSwitchUser;
bool m_canSuspend = false;
bool m_canHibernate = false;
......
......@@ -110,6 +110,9 @@ int main(int argc, char* argv[])
QStringLiteral("0"));
QCommandLineOption nolockOption(QStringLiteral("nolock"),
i18n("Don't show any lock user interface."));
QCommandLineOption switchUserOption(QStringLiteral("switchuser"),
i18n("Default to the switch user UI."));
QCommandLineOption waylandFdOption(QStringLiteral("ksldfd"),
i18n("File descriptor for connecting to ksld."),
QStringLiteral("fd"));
......@@ -119,6 +122,7 @@ int main(int argc, char* argv[])
parser.addOption(immediateLockOption);
parser.addOption(graceTimeOption);
parser.addOption(nolockOption);
parser.addOption(switchUserOption);
parser.addOption(waylandFdOption);
parser.process(app);
......@@ -151,6 +155,10 @@ int main(int argc, char* argv[])
app.setGraceTime(graceTime);
}
if (parser.isSet(switchUserOption)) {
app.setDefaultToSwitchUser(true);
}
if (parser.isSet(waylandFdOption)) {
ok = false;
const int fd = parser.value(waylandFdOption).toInt(&ok);
......
......@@ -572,6 +572,11 @@ void KSldApp::startLockProcess(EstablishLock establishLock)
if (establishLock == EstablishLock::Immediate) {
args << QStringLiteral("--immediateLock");
}
if (establishLock == EstablishLock::DefaultToSwitchUser) {
args << QStringLiteral("--immediateLock");
args << QStringLiteral("--switchuser");
}
if (m_lockGrace > 0) {
args << QStringLiteral("--graceTime");
args << QString::number(m_lockGrace);
......
......@@ -47,8 +47,9 @@ namespace ScreenLocker
{
enum class EstablishLock {
Immediate,
Delayed
Immediate, ///Require password from the start. Use if invoked explicitly by the user
Delayed, ///Allow the user to log back in without a password for a configured grace time.
DefaultToSwitchUser ///UI should default to showing the "switch user dialog"
};
class AbstractLocker;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment