on xenial help sign in
Lock the session when putting the laptop into sleep Fixes: #1581063

Approved by: Unity8 CI Bot, Andrea Cimitan

commite5705186cee709b1c6304c9ba27fe5adc5f1dbb9 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 27 May 2016, 13:54 (10 years ago) parentb3acd662427514
1 file changed+7
plugins/Unity/Session/dbusunitysessionservice.cpp+7
plugins/Unity/Session/dbusunitysessionservice.cpp+7
@@ -227,11 +227,14 @@ private Q_SLOTS:
227227 {
228228 if (!active) {
229229 setupSystemdInhibition();
230+ } else {
231+ Q_EMIT prepareForSleep();
230232 }
231233 }
232234
233235Q_SIGNALS:
234236 void screensaverActiveChanged(bool active);
237+ void prepareForSleep();
235238};
236239
237240Q_GLOBAL_STATIC(DBusUnitySessionServicePrivate, d)
@@ -245,6 +248,7 @@ DBusUnitySessionService::DBusUnitySessionService()
245248 // ... and our Unlocked() signal to the logind's session Unlock() signal
246249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
247250 QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
251+ connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
248252 } else {
249253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
250254 }
@@ -390,16 +394,19 @@ void DBusUnitySessionService::Shutdown()
390394
391395void DBusUnitySessionService::Suspend()
392396{
397+ PromptLock();
393398 d->makeLogin1Call(QStringLiteral("Suspend"), {false});
394399}
395400
396401void DBusUnitySessionService::Hibernate()
397402{
403+ PromptLock();
398404 d->makeLogin1Call(QStringLiteral("Hibernate"), {false});
399405}
400406
401407void DBusUnitySessionService::HybridSleep()
402408{
409+ PromptLock();
403410 d->makeLogin1Call(QStringLiteral("HybridSleep"), {false});
404411}
405412