aboutsummaryrefslogtreecommitdiff
path: root/src/ui/config_error_notification.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-11-24 09:41:43 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-11-25 04:07:59 -0800
commit4c22c3285d8b10fbcef1c45a0788c3ddca03ec62 (patch)
tree506174fe9962a91598ac25d4d2dee1cdaa3d5292 /src/ui/config_error_notification.rs
parent93cee2994ab9ccf59a09f61d5b8acf6cd937d654 (diff)
downloadniri-4c22c3285d8b10fbcef1c45a0788c3ddca03ec62.tar.gz
niri-4c22c3285d8b10fbcef1c45a0788c3ddca03ec62.tar.bz2
niri-4c22c3285d8b10fbcef1c45a0788c3ddca03ec62.zip
Refactor animation timing to use lazy clocks
Diffstat (limited to 'src/ui/config_error_notification.rs')
-rw-r--r--src/ui/config_error_notification.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ui/config_error_notification.rs b/src/ui/config_error_notification.rs
index af4f67e3..bd46aa7d 100644
--- a/src/ui/config_error_notification.rs
+++ b/src/ui/config_error_notification.rs
@@ -60,7 +60,7 @@ impl ConfigErrorNotification {
fn animation(&self, from: f64, to: f64) -> Animation {
let c = self.config.borrow();
Animation::new(
- self.clock.now(),
+ self.clock.clone(),
from,
to,
0.,
@@ -96,11 +96,10 @@ impl ConfigErrorNotification {
self.state = State::Hiding(self.animation(1., 0.));
}
- pub fn advance_animations(&mut self, target_presentation_time: Duration) {
+ pub fn advance_animations(&mut self) {
match &mut self.state {
State::Hidden => (),
State::Showing(anim) => {
- anim.set_current_time(target_presentation_time);
if anim.is_done() {
let duration = if self.created_path.is_some() {
// Make this quite a bit longer because it comes with a monitor modeset
@@ -110,16 +109,15 @@ impl ConfigErrorNotification {
} else {
Duration::from_secs(4)
};
- self.state = State::Shown(target_presentation_time + duration);
+ self.state = State::Shown(self.clock.now() + duration);
}
}
State::Shown(deadline) => {
- if target_presentation_time >= *deadline {
+ if self.clock.now() >= *deadline {
self.hide();
}
}
State::Hiding(anim) => {
- anim.set_current_time(target_presentation_time);
if anim.is_clamped_done() {
self.state = State::Hidden;
}