From 79ea8b9482ec07b894ea9f6a0a79712751fe151c Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Sun, 19 Feb 2023 17:38:57 +0300 Subject: Relax horizontal scrolling Apply horizontal scrolling when the angle between the axis X and (x, y) vector is lower than 25 degrees. Fixes #6711. --- alacritty/src/input.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'alacritty/src') 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> Processor { 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); }, _ => (), -- cgit