summaryrefslogtreecommitdiff
path: root/src/login/logind-seat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/logind-seat.c')
-rw-r--r--src/login/logind-seat.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 197138c4e0..126c5b84cc 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -340,12 +340,24 @@ int seat_active_vt_changed(Seat *s, unsigned int vtnr) {
log_debug("VT changed to %u", vtnr);
+ /* we might have earlier closing sessions on the same VT, so try to
+ * find a running one first */
LIST_FOREACH(sessions_by_seat, i, s->sessions)
- if (i->vtnr == vtnr) {
+ if (i->vtnr == vtnr && !i->stopping) {
new_active = i;
break;
}
+ if (!new_active) {
+ /* no running one? then we can't decide which one is the
+ * active one, let the first one win */
+ LIST_FOREACH(sessions_by_seat, i, s->sessions)
+ if (i->vtnr == vtnr) {
+ new_active = i;
+ break;
+ }
+ }
+
r = seat_set_active(s, new_active);
manager_spawn_autovt(s->manager, vtnr);