Blob Blame History Raw
From 9d811fef691d872a3dd8fcb9d9210a7c6b48e5c0 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Thu, 16 Jul 2015 18:18:01 +0200
Subject: [PATCH] logind: prefer new sessions over older ones on VT switches

Our seat->positions[] array keeps track of the 'preferred' session on a
VT. The only situation this is used, is to select the session to activate
when a VT is activated. In the normal case, there's only one session per
VT so the selection is trivial.

Older greeters, however, implement take-overs when they start sessions on
the same VT that the greeter ran on. We recently limited such take-overs
to VTs where a greeter is running on, to force people to never share VTs
in new code that is written.

For legacy reasons, we need to be compatible to old greeters, though.
Hence, we allow those greeters to implement take-over. In such take-overs,
however, we should really make sure that the new sessions gets preferred
over the old one under all circumstances. Hence, make sure we override
the previous preferred session with a new session.

(cherry picked from commit da770c386f8cc6efd3430ebab4e0707a4bb06c16)
---
 src/login/logind-seat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 126c5b84cc..6877dcd807 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -508,7 +508,7 @@ void seat_claim_position(Seat *s, Session *session, unsigned int pos) {
         seat_evict_position(s, session);
 
         session->pos = pos;
-        if (pos > 0 && !s->positions[pos])
+        if (pos > 0)
                 s->positions[pos] = session;
 }