chiark / gitweb /
logind: redefine idleness to start at last activity
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jul 2012 13:39:37 +0000 (15:39 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Sep 2012 09:34:53 +0000 (11:34 +0200)
Before, after the timeout, a session would be timestamped as idle
since 'last activity' + 'idle timeout'. Now, it is timestamped as idle
since 'last activity'.

Before, after all sessions were idle, the seat would be marked with as
idle with the timestamp of the oldest idle session. Now it is
marked with the timestamp of the youngest idle session.

Both changes seem to me to be closer to natural understanding of
idleness: the time since last activity counts.

src/login/logind-seat.c
src/login/logind-session.c

index c2cf6e5e137147c5e07c18d92e7d88103b3b09ce..0ae0c520e6d564bfd5a993874d4419d1f98ba2cf 100644 (file)
@@ -471,7 +471,7 @@ int seat_get_idle_hint(Seat *s, dual_timestamp *t) {
 
                 if (!ih) {
                         if (!idle_hint) {
-                                if (k.monotonic < ts.monotonic)
+                                if (k.monotonic > ts.monotonic)
                                         ts = k;
                         } else {
                                 idle_hint = false;
index 9740e23a1670f2556455ced06148dddc3de5e8fc..f670db853c9e65709ab6b420c8b2c34c013b7cc0 100644 (file)
@@ -738,7 +738,6 @@ int session_get_idle_hint(Session *s, dual_timestamp *t) {
         char *p;
         struct stat st;
         usec_t u, n;
-        bool b;
         int k;
 
         assert(s);
@@ -773,12 +772,11 @@ int session_get_idle_hint(Session *s, dual_timestamp *t) {
 
         u = timespec_load(&st.st_atim);
         n = now(CLOCK_REALTIME);
-        b = u + IDLE_THRESHOLD_USEC < n;
 
         if (t)
-                dual_timestamp_from_realtime(t, u + b*IDLE_THRESHOLD_USEC);
+                dual_timestamp_from_realtime(t, u);
 
-        return b;
+        return u + IDLE_THRESHOLD_USEC < n;
 
 dont_know:
         if (t)