summaryrefslogtreecommitdiff
path: root/src/login/logind-user.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-05-19 09:03:20 +0900
committerLennart Poettering <lennart@poettering.net>2014-05-19 09:03:20 +0900
commit952d32609f9bceee444fa2690afb4d28539b4b92 (patch)
treed952a24f01c7f0727e68b29b26a6fdb74d86b8cc /src/login/logind-user.c
parent2be6107255c3cf47bb5a9eddf2411953f29522e1 (diff)
logind: fix Display property of user objects
When we dropped support for creating a per-user to the "main" X11 display we stopped returning useful data in the "Display" user property. With this change this is fixed and we again expose an appropriate (graphical session) in the property that is useful as the "main" one, if one is needed.
Diffstat (limited to 'src/login/logind-user.c')
-rw-r--r--src/login/logind-user.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 5fffa651a..fdbccb364 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -713,6 +713,43 @@ int user_kill(User *u, int signo) {
return manager_kill_unit(u->manager, u->slice, KILL_ALL, signo, NULL);
}
+void user_elect_display(User *u) {
+ Session *graphical = NULL, *text = NULL, *s;
+
+ assert(u);
+
+ /* This elects a primary session for each user, which we call
+ * the "display". We try to keep the assignment stable, but we
+ * "upgrade" to better choices. */
+
+ LIST_FOREACH(sessions_by_user, s, u->sessions) {
+
+ if (s->class != SESSION_USER)
+ continue;
+
+ if (s->stopping)
+ continue;
+
+ if (SESSION_TYPE_IS_GRAPHICAL(s->type))
+ graphical = s;
+ else
+ text = s;
+ }
+
+ if (graphical &&
+ (!u->display ||
+ u->display->class != SESSION_USER ||
+ u->display->stopping ||
+ !SESSION_TYPE_IS_GRAPHICAL(u->display->type)))
+ u->display = graphical;
+
+ if (text &&
+ (!u->display ||
+ u->display->class != SESSION_USER ||
+ u->display->stopping))
+ u->display = text;
+}
+
static const char* const user_state_table[_USER_STATE_MAX] = {
[USER_OFFLINE] = "offline",
[USER_OPENING] = "opening",