summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-02-19 17:38:57 +0300
committerChristian Duerr <contact@christianduerr.com>2023-03-06 08:19:58 +0100
commite292aedf27ce97015a203365378515629d3df3c5 (patch)
tree825f4cac355c94550d432aef28ec385ed16c0657
parentae90338bb6045fdfa8f73965fd4b70c67e326af6 (diff)
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.rs10
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);
},
_ => (),