X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-seat.c;h=126c5b84cc5b4f4ade8dddfb53174c635ddb6754;hb=2723b3b51d409340558e46e37e90525d4f880fe1;hp=197138c4e0ebe2a84a09630d4ede3cafc966e7e0;hpb=1fa2f38f0f011010bf57522b42fcc168856a7003;p=elogind.git diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 197138c4e..126c5b84c 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);