From 952d32609f9bceee444fa2690afb4d28539b4b92 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 May 2014 09:03:20 +0900 Subject: 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. --- src/login/logind-user.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/login/logind-user.c') diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 5fffa651a3..fdbccb364c 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", -- cgit v1.2.3-54-g00ecf