on xenial help sign in
Workaround bug in logind not telling us when a session becomes inactive, and also hide launcher when that happens
3d77c8aMichael Terry
plugins/SessionManager/SessionManager.cpp+17
@@ -79,6 +79,17 @@ void SessionManager::getSessionSlot(QDBusPendingCallWatcher *watcher)
79 this,
79 this,
80 SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
80 SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
81
81
82+ // Login1 is very odd about emitting PropertiesChanged. It often does
83+ // not do so when active is becoming false. But it always does when
84+ // it becomes true. So we watch for the "Lock" signal too, which is a
85+ // reliably hint that active is false.
86+ l1_manager->connection().connect("org.freedesktop.login1",
87+ path.path(),
88+ "org.freedesktop.login1.Session",
89+ "Lock",
90+ this,
91+ SLOT(sessionLocked()));
92+
82 propertiesChanged("", QVariantMap(), QStringList() << "Active");
93 propertiesChanged("", QVariantMap(), QStringList() << "Active");
83 }
94 }
84 watcher->deleteLater();
95 watcher->deleteLater();
@@ -105,3 +116,9 @@ void SessionManager::propertiesChanged(const QString &interface, const QVariantM
105 Q_EMIT activeChanged();
116 Q_EMIT activeChanged();
106 }
117 }
107}
118}
119+
120+void SessionManager::sessionLocked()
121+{
122+ is_active = false;
123+ Q_EMIT activeChanged();
124+}
plugins/SessionManager/SessionManager.h+1
@@ -49,6 +49,7 @@ Q_SIGNALS:
49private Q_SLOTS:
49private Q_SLOTS:
50 void getSessionSlot(QDBusPendingCallWatcher *watcher);
50 void getSessionSlot(QDBusPendingCallWatcher *watcher);
51 void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
51 void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
52+ void sessionLocked();
52
53
53private:
54private:
54 QDBusInterface *l1_manager;
55 QDBusInterface *l1_manager;
qml/Shell.qml+5
@@ -393,6 +393,11 @@ BasicShell {
393 panel.indicators.hide()
393 panel.indicators.hide()
394 }
394 }
395 }
395 }
396+
397+ Connections {
398+ target: SessionManager
399+ onActiveChanged: if (!SessionManager.active) launcher.hide()
400+ }
396 }
401 }
397
402
398 Rectangle {
403 Rectangle {