aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-02-07 16:32:38 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-02-07 16:32:38 +0400
commit753a90430abbdf166a86b95c5c69aa1e68b3c412 (patch)
tree78491ad15f528bb30b8a7755b6d7a45f1ad17270
parentf9085db5648bc6bad7fb0abf45e2a11f2e03d1af (diff)
downloadniri-753a90430abbdf166a86b95c5c69aa1e68b3c412.tar.gz
niri-753a90430abbdf166a86b95c5c69aa1e68b3c412.tar.bz2
niri-753a90430abbdf166a86b95c5c69aa1e68b3c412.zip
animation: Accept ms as u32
Less boilerplate elsewhere.
-rw-r--r--src/animation.rs6
-rw-r--r--src/config_error_notification.rs6
-rw-r--r--src/layout/mod.rs2
-rw-r--r--src/layout/monitor.rs2
-rw-r--r--src/layout/tile.rs3
-rw-r--r--src/layout/workspace.rs2
6 files changed, 11 insertions, 10 deletions
diff --git a/src/animation.rs b/src/animation.rs
index bf0536e2..404c3d85 100644
--- a/src/animation.rs
+++ b/src/animation.rs
@@ -25,15 +25,17 @@ pub enum Curve {
}
impl Animation {
- pub fn new(from: f64, to: f64, over: Duration) -> Self {
+ pub fn new(from: f64, to: f64, over_ms: u32) -> Self {
// FIXME: ideally we shouldn't use current time here because animations started within the
// same frame cycle should have the same start time to be synchronized.
let now = get_monotonic_time();
+ let duration = Duration::from_millis(u64::from(over_ms))
+ .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed));
Self {
from,
to,
- duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)),
+ duration,
start_time: now,
current_time: now,
curve: Curve::EaseOutCubic,
diff --git a/src/config_error_notification.rs b/src/config_error_notification.rs
index 73ae3d9b..b80e8d27 100644
--- a/src/config_error_notification.rs
+++ b/src/config_error_notification.rs
@@ -58,7 +58,7 @@ impl ConfigErrorNotification {
self.buffers.borrow_mut().clear();
}
- self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));
+ self.state = State::Showing(Animation::new(0., 1., 250));
}
pub fn show(&mut self) {
@@ -68,7 +68,7 @@ impl ConfigErrorNotification {
}
// Show from scratch even if already showing to bring attention.
- self.state = State::Showing(Animation::new(0., 1., Duration::from_millis(250)));
+ self.state = State::Showing(Animation::new(0., 1., 250));
}
pub fn hide(&mut self) {
@@ -76,7 +76,7 @@ impl ConfigErrorNotification {
return;
}
- self.state = State::Hiding(Animation::new(1., 0., Duration::from_millis(250)));
+ self.state = State::Hiding(Animation::new(1., 0., 250));
}
pub fn advance_animations(&mut self, target_presentation_time: Duration) {
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 36f60d12..7c381358 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -1577,7 +1577,7 @@ impl<W: LayoutElement> Layout<W> {
monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
current_idx,
idx as f64,
- Duration::from_millis(250),
+ 250,
)));
return Some(monitor.output.clone());
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs
index 383ff965..accce645 100644
--- a/src/layout/monitor.rs
+++ b/src/layout/monitor.rs
@@ -96,7 +96,7 @@ impl<W: LayoutElement> Monitor<W> {
self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
current_idx,
idx as f64,
- Duration::from_millis(250),
+ 250,
)));
}
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index dfda6fbb..be96f6e6 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -114,8 +114,7 @@ impl<W: LayoutElement> Tile<W> {
}
pub fn start_open_animation(&mut self) {
- self.open_animation =
- Some(Animation::new(0., 1., Duration::from_millis(150)).with_curve(Curve::EaseOutExpo));
+ self.open_animation = Some(Animation::new(0., 1., 150).with_curve(Curve::EaseOutExpo));
}
pub fn window(&self) -> &W {
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 24372074..9165d7e0 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -401,7 +401,7 @@ impl<W: LayoutElement> Workspace<W> {
self.view_offset_anim = Some(Animation::new(
self.view_offset as f64,
new_view_offset as f64,
- Duration::from_millis(250),
+ 250,
));
}