X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-seat.c;h=8198011c207c5586655039af8bbc297781eb98db;hb=f5765a8e9044f87b6acbf9c4fbf4f63553ff0276;hp=197138c4e0ebe2a84a09630d4ede3cafc966e7e0;hpb=1fa2f38f0f011010bf57522b42fcc168856a7003;p=elogind.git diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 197138c4e..8198011c2 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -19,21 +19,18 @@ along with systemd; If not, see . ***/ -#include #include #include #include -#include -#include #include -#include "sd-id128.h" #include "sd-messages.h" #include "logind-seat.h" #include "logind-acl.h" #include "util.h" #include "mkdir.h" -#include "path-util.h" +#include "formats-util.h" +#include "terminal-util.h" Seat *seat_new(Manager *m, const char *id) { Seat *s; @@ -181,34 +178,6 @@ static int vt_allocate(unsigned int vtnr) { return 0; } -int seat_preallocate_vts(Seat *s) { - int r = 0; - unsigned i; - - assert(s); - assert(s->manager); - - log_debug("Preallocating VTs..."); - - if (s->manager->n_autovts <= 0) - return 0; - - if (!seat_has_vts(s)) - return 0; - - for (i = 1; i <= s->manager->n_autovts; i++) { - int q; - - q = vt_allocate(i); - if (q < 0) { - log_error_errno(q, "Failed to preallocate VT %u: %m", i); - r = q; - } - } - - return r; -} - int seat_apply_acls(Seat *s, Session *old_active) { int r; @@ -340,14 +309,25 @@ 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); return r; } @@ -405,9 +385,6 @@ int seat_start(Seat *s) { LOG_MESSAGE("New seat %s.", s->id), NULL); - /* Initialize VT magic stuff */ - seat_preallocate_vts(s); - /* Read current VT */ seat_read_active_vt(s); @@ -590,7 +567,7 @@ bool seat_can_graphical(Seat *s) { int seat_get_idle_hint(Seat *s, dual_timestamp *t) { Session *session; bool idle_hint = true; - dual_timestamp ts = { 0, 0 }; + dual_timestamp ts = DUAL_TIMESTAMP_NULL; assert(s);