Skip to content

Commit

Permalink
Fix idle time being doubled in case of activity
Browse files Browse the repository at this point in the history
  • Loading branch information
jD91mZM2 committed Feb 28, 2021
1 parent 4221aa8 commit be3faea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions xidlehook-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ where
pub fn poll(&mut self, absolute_time: Duration) -> Result<Action> {
if absolute_time < self.previous_idle_time {
// If the idle time has decreased, the only reasonable explanation is that the user
// briefly wasn't idle.
self.reset(absolute_time)?;
// briefly wasn't idle. We reset the base idle time to zero so the entire idle duration
// is counted.
self.reset(Duration::from_millis(0))?;
}

self.previous_idle_time = absolute_time;
Expand Down

0 comments on commit be3faea

Please sign in to comment.