diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-02-19 17:38:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-19 17:38:57 +0300 |
commit | 79ea8b9482ec07b894ea9f6a0a79712751fe151c (patch) | |
tree | a23429430ac4fcac5ee585b726f7b7225b26c761 | |
parent | c682a357ec78f13d2e6222c83abfa9071d8a18f3 (diff) | |
download | alacritty-79ea8b9482ec07b894ea9f6a0a79712751fe151c.tar.gz alacritty-79ea8b9482ec07b894ea9f6a0a79712751fe151c.zip |
Relax horizontal scrolling
Apply horizontal scrolling when the angle between the axis X
and (x, y) vector is lower than 25 degrees.
Fixes #6711.
-rw-r--r-- | alacritty/src/input.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index f4c81006..5728665a 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -648,13 +648,21 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> { let new_scroll_px_y = lines * self.ctx.size_info().cell_height(); self.scroll_terminal(new_scroll_px_x as f64, new_scroll_px_y as f64); }, - MouseScrollDelta::PixelDelta(lpos) => { + MouseScrollDelta::PixelDelta(mut lpos) => { match phase { TouchPhase::Started => { // Reset offset to zero. self.ctx.mouse_mut().accumulated_scroll = Default::default(); }, TouchPhase::Moved => { + // When the angle between (x, 0) and (x, y) is lower than ~25 degrees + // (cosine is larger that 0.9) we consider this scrolling as horizontal. + if lpos.x.abs() / lpos.x.hypot(lpos.y) > 0.9 { + lpos.y = 0.; + } else { + lpos.x = 0.; + } + self.scroll_terminal(lpos.x, lpos.y); }, _ => (), |