chiark / gitweb /
logind: introduce session "positions"
[elogind.git] / src / login / logind-session.c
index 4476f5820a4bee122ae7d4f6d4321ff77d311945..ff0a7a4f2e2253094317f1e2cba5a3d3b3636aac 100644 (file)
@@ -125,6 +125,7 @@ void session_free(Session *s) {
                 if (s->seat->pending_switch == s)
                         s->seat->pending_switch = NULL;
 
                 if (s->seat->pending_switch == s)
                         s->seat->pending_switch = NULL;
 
+                seat_evict_position(s->seat, s);
                 LIST_REMOVE(sessions_by_seat, s->seat->sessions, s);
         }
 
                 LIST_REMOVE(sessions_by_seat, s->seat->sessions, s);
         }
 
@@ -231,6 +232,9 @@ int session_save(Session *s) {
         if (s->seat && seat_has_vts(s->seat))
                 fprintf(f, "VTNR=%u\n", s->vtnr);
 
         if (s->seat && seat_has_vts(s->seat))
                 fprintf(f, "VTNR=%u\n", s->vtnr);
 
+        if (!s->vtnr)
+                fprintf(f, "POS=%u\n", s->pos);
+
         if (s->leader > 0)
                 fprintf(f, "LEADER=%lu\n", (unsigned long) s->leader);
 
         if (s->leader > 0)
                 fprintf(f, "LEADER=%lu\n", (unsigned long) s->leader);
 
@@ -266,6 +270,7 @@ int session_load(Session *s) {
         _cleanup_free_ char *remote = NULL,
                 *seat = NULL,
                 *vtnr = NULL,
         _cleanup_free_ char *remote = NULL,
                 *seat = NULL,
                 *vtnr = NULL,
+                *pos = NULL,
                 *leader = NULL,
                 *type = NULL,
                 *class = NULL,
                 *leader = NULL,
                 *type = NULL,
                 *class = NULL,
@@ -290,6 +295,7 @@ int session_load(Session *s) {
                            "REMOTE_USER",    &s->remote_user,
                            "SERVICE",        &s->service,
                            "VTNR",           &vtnr,
                            "REMOTE_USER",    &s->remote_user,
                            "SERVICE",        &s->service,
                            "VTNR",           &vtnr,
+                           "POS",            &pos,
                            "LEADER",         &leader,
                            "TYPE",           &type,
                            "CLASS",          &class,
                            "LEADER",         &leader,
                            "TYPE",           &type,
                            "CLASS",          &class,
@@ -350,6 +356,13 @@ int session_load(Session *s) {
         if (!s->seat || !seat_has_vts(s->seat))
                 s->vtnr = 0;
 
         if (!s->seat || !seat_has_vts(s->seat))
                 s->vtnr = 0;
 
+        if (pos && s->seat) {
+                unsigned int npos;
+
+                safe_atou(pos, &npos);
+                seat_claim_position(s->seat, s, npos);
+        }
+
         if (leader) {
                 k = parse_pid(leader, &s->leader);
                 if (k >= 0)
         if (leader) {
                 k = parse_pid(leader, &s->leader);
                 if (k >= 0)