diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-06-17 15:59:18 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-06-21 19:29:45 +0200 |
commit | a185c5aa2d8bef98716f8cf160da263c17e588b2 (patch) | |
tree | ef6ff057c606efefe86b34503fe92bf40cf05b6d /src/logind.c | |
parent | 91f9dcaf9270fe465525638cc08bd94590273349 (diff) |
logind: implement idle hint logic
Diffstat (limited to 'src/logind.c')
-rw-r--r-- | src/logind.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/logind.c b/src/logind.c index a62802895c..d72a5bfa8b 100644 --- a/src/logind.c +++ b/src/logind.c @@ -853,6 +853,44 @@ void manager_gc(Manager *m) { } } +int manager_get_idle_hint(Manager *m, dual_timestamp *t) { + Session *s; + bool idle_hint = true; + dual_timestamp ts = { 0, 0 }; + Iterator i; + + assert(m); + + HASHMAP_FOREACH(s, m->sessions, i) { + dual_timestamp k; + int ih; + + ih = session_get_idle_hint(s, &k); + if (ih < 0) + return ih; + + if (!ih) { + if (!idle_hint) { + if (k.monotonic < ts.monotonic) + ts = k; + } else { + idle_hint = false; + ts = k; + } + } else if (idle_hint) { + + if (k.monotonic > ts.monotonic) + ts = k; + } + } + + if (t) + *t = ts; + + return idle_hint; +} + + int manager_startup(Manager *m) { int r; Seat *seat; |