on xenial help sign in
Lock the session when putting the laptop into sleep Fixes: #1581063
e570518Lukáš Tinkl
plugins/Unity/Session/dbusunitysessionservice.cpp+7
@@ -227,11 +227,14 @@ private Q_SLOTS:
227 {
227 {
228 if (!active) {
228 if (!active) {
229 setupSystemdInhibition();
229 setupSystemdInhibition();
230+ } else {
231+ Q_EMIT prepareForSleep();
230 }
232 }
231 }
233 }
232
234
233Q_SIGNALS:
235Q_SIGNALS:
234 void screensaverActiveChanged(bool active);
236 void screensaverActiveChanged(bool active);
237+ void prepareForSleep();
235};
238};
236
239
237Q_GLOBAL_STATIC(DBusUnitySessionServicePrivate, d)
240Q_GLOBAL_STATIC(DBusUnitySessionServicePrivate, d)
@@ -245,6 +248,7 @@ DBusUnitySessionService::DBusUnitySessionService()
245 // ... and our Unlocked() signal to the logind's session Unlock() signal
248 // ... and our Unlocked() signal to the logind's session Unlock() signal
246 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
247 QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
250 QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
251+ connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
248 } else {
252 } else {
249 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
250 }
254 }
@@ -390,16 +394,19 @@ void DBusUnitySessionService::Shutdown()
390
394
391void DBusUnitySessionService::Suspend()
395void DBusUnitySessionService::Suspend()
392{
396{
397+ PromptLock();
393 d->makeLogin1Call(QStringLiteral("Suspend"), {false});
398 d->makeLogin1Call(QStringLiteral("Suspend"), {false});
394}
399}
395
400
396void DBusUnitySessionService::Hibernate()
401void DBusUnitySessionService::Hibernate()
397{
402{
403+ PromptLock();
398 d->makeLogin1Call(QStringLiteral("Hibernate"), {false});
404 d->makeLogin1Call(QStringLiteral("Hibernate"), {false});
399}
405}
400
406
401void DBusUnitySessionService::HybridSleep()
407void DBusUnitySessionService::HybridSleep()
402{
408{
409+ PromptLock();
403 d->makeLogin1Call(QStringLiteral("HybridSleep"), {false});
410 d->makeLogin1Call(QStringLiteral("HybridSleep"), {false});
404}
411}
405
412