diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-10 11:28:49 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-04-10 11:28:49 +0400 |
| commit | 5383a0591f22b9640a570e299a73706eb4a27ffc (patch) | |
| tree | f1ead9293eaf63676573494c9d0b3571fc3698eb | |
| parent | 0c686090637f51caee2dd2fea2223a3c5bc4995b (diff) | |
| download | niri-5383a0591f22b9640a570e299a73706eb4a27ffc.tar.gz niri-5383a0591f22b9640a570e299a73706eb4a27ffc.tar.bz2 niri-5383a0591f22b9640a570e299a73706eb4a27ffc.zip | |
Use clamped animations where it makes sense
| -rw-r--r-- | src/layout/closing_window.rs | 4 | ||||
| -rw-r--r-- | src/layout/tile.rs | 2 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 6 | ||||
| -rw-r--r-- | src/ui/config_error_notification.rs | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/layout/closing_window.rs b/src/layout/closing_window.rs index 3de0d51f..f863a5d3 100644 --- a/src/layout/closing_window.rs +++ b/src/layout/closing_window.rs @@ -125,7 +125,7 @@ impl ClosingWindow { } pub fn are_animations_ongoing(&self) -> bool { - !self.anim.is_done() + !self.anim.is_clamped_done() } pub fn render( @@ -134,7 +134,7 @@ impl ClosingWindow { scale: Scale<f64>, target: RenderTarget, ) -> ClosingWindowRenderElement { - let val = self.anim.value(); + let val = self.anim.clamped_value(); let block_out = match self.block_out_from { None => false, diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 53300bec..1fcf4f1b 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -387,7 +387,7 @@ impl<W: LayoutElement> Tile<W> { renderer, scale.x as i32, &elements, - anim.value().clamp(0., 1.) as f32, + anim.clamped_value().clamp(0., 1.) as f32, ); self.window() .set_offscreen_element_id(Some(elem.id().clone())); diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 61cf6e79..d5735bbd 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -956,8 +956,10 @@ impl<W: LayoutElement> Workspace<W> { // FIXME: this is a bit cursed since it's relying on Tile's internal details. let (starting_alpha, starting_scale) = if let Some(anim) = tile.open_animation() { - let val = anim.value(); - (val.clamp(0., 1.) as f32, (val / 2. + 0.5).max(0.)) + ( + anim.clamped_value().clamp(0., 1.) as f32, + (anim.value() / 2. + 0.5).max(0.), + ) } else { (1., 1.) }; diff --git a/src/ui/config_error_notification.rs b/src/ui/config_error_notification.rs index b9e68e8e..d49ab4f0 100644 --- a/src/ui/config_error_notification.rs +++ b/src/ui/config_error_notification.rs @@ -119,9 +119,7 @@ impl ConfigErrorNotification { } State::Hiding(anim) => { anim.set_current_time(target_presentation_time); - // HACK: prevent bounciness on hiding. This is better done with a clamp property on - // the spring animation. - if anim.is_done() || anim.value() <= 0. { + if anim.is_clamped_done() { self.state = State::Hidden; } } |
