Skip to content

Commit

Permalink
fix(surface): Draw new wallpaper when updating duration
Browse files Browse the repository at this point in the history
  • Loading branch information
danyspin97 committed Nov 18, 2024
1 parent 7c16be1 commit b4cffe7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions daemon/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,12 @@ impl Surface {
// it was on screen without the timer being paused
let time_passed = match self.event_source {
EventSource::Running(_, duration, instant) => {
if old_duration != duration {
old_duration - duration + instant.elapsed()
} else {
instant.elapsed()
}
// The old_duration is the full duration that the wallpaper needed
// to be displayed. The duration is the one that the timer is set
// to, which might be different than old_duration if the timer was
// paused. So calculate how much time the image was displayed with
// this information.
old_duration.saturating_sub(duration) + instant.elapsed()
}
EventSource::Paused(duration) => old_duration - duration,
EventSource::NotSet => unreachable!(),
Expand All @@ -547,6 +548,9 @@ impl Surface {
if saturating_sub.is_zero() {
// The image was on screen for the same time as the new duration
self.image_picker.next_image(&self.wallpaper_info.path);
if let Err(err) = self.load_wallpaper(None) {
warn!("{err:?}");
}
new_duration
} else {
saturating_sub
Expand Down

0 comments on commit b4cffe7

Please sign in to comment.