diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-07-09 09:38:56 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-07-09 09:43:43 +0400 |
| commit | 22bfec7259282c4e7f629b502e171dbf7580b5a1 (patch) | |
| tree | 5ac39d2a0e7f3e0d9bdd1436bbeae4d14a81358f /src/layout/workspace.rs | |
| parent | 1af9f9bd95283544b068dbbe33e923ab9e836243 (diff) | |
| download | niri-22bfec7259282c4e7f629b502e171dbf7580b5a1.tar.gz niri-22bfec7259282c4e7f629b502e171dbf7580b5a1.tar.bz2 niri-22bfec7259282c4e7f629b502e171dbf7580b5a1.zip | |
Add tolerance to view offset anim restart check
It was getting tripped by tiny differences.
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 625f4d5c..4b873fff 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -771,16 +771,22 @@ impl<W: LayoutElement> Workspace<W> { let from_view_offset = current_x - new_col_x; self.view_offset = from_view_offset; + let pixel = 1. / self.scale.fractional_scale(); + // If we're already animating towards that, don't restart it. - if let Some(ViewOffsetAdjustment::Animation(anim)) = &self.view_offset_adj { - let pixel = 1. / self.scale.fractional_scale(); - if (anim.value() - self.view_offset).abs() < pixel && anim.to() == new_view_offset { + if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj { + let to_diff = new_view_offset - anim.to(); + if (anim.value() - self.view_offset).abs() < pixel && to_diff.abs() < pixel { + // Correct for any inaccuracy. + anim.offset(to_diff); return; } } // If our view offset is already this, we don't need to do anything. - if self.view_offset == new_view_offset { + if (self.view_offset - new_view_offset).abs() < pixel { + // Correct for any inaccuracy. + self.view_offset = new_view_offset; self.view_offset_adj = None; return; } |
