diff options
author | Christian Dürr <contact@christianduerr.com> | 2017-12-18 17:49:57 +0100 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-12-22 14:00:17 -0800 |
commit | 14884deba7ff61495a87cd3be91dc620a1eba5fa (patch) | |
tree | 2a414326758a1698e52bd9b46c8433439e3aa4af | |
parent | e0993587e7c994214aef83a6d50e70959ee05d96 (diff) | |
download | alacritty-14884deba7ff61495a87cd3be91dc620a1eba5fa.tar.gz alacritty-14884deba7ff61495a87cd3be91dc620a1eba5fa.zip |
Fix faux scrolling for line-based touchpads
Touchpads which use line-based instead of pixel-based updates send
partial scroll requests, so decimal numbers are important. The current
implementation only really used scroll amounts that are either 1 or -1.
This has been fixed and now the line-based touchpads should have very
smooth scrolling, but the pixel-based approach is still WIP and
completely untested.
-rw-r--r-- | src/input.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/input.rs b/src/input.rs index 8f6048f0..c653d486 100644 --- a/src/input.rs +++ b/src/input.rs @@ -373,19 +373,6 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { match delta { MouseScrollDelta::LineDelta(_columns, lines) => { let to_scroll = self.ctx.mouse_mut().lines_scrolled + lines; - - // Faux scrolling - if self.ctx.terminal_mode().intersects(mode::ALT_SCREEN_BUF) { - if to_scroll > 0. { - // Scroll up three lines - self.ctx.write_to_pty("\x1bOA\x1bOA\x1bOA".as_bytes()); - } else { - // Scroll down three lines - self.ctx.write_to_pty("\x1bOB\x1bOB\x1bOB".as_bytes()); - } - return; - } - let code = if to_scroll > 0.0 { 64 } else { @@ -393,8 +380,20 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { }; for _ in 0..(to_scroll.abs() as usize) { - self.normal_mouse_report(code); + if self.ctx.terminal_mode().intersects(mode::ALT_SCREEN_BUF) { + // Faux scrolling + if code == 64 { + // Scroll up one line + self.ctx.write_to_pty("\x1bOA".as_bytes()); + } else { + // Scroll down one line + self.ctx.write_to_pty("\x1bOB".as_bytes()); + } + } else { + self.normal_mouse_report(code); + } } + self.ctx.mouse_mut().lines_scrolled = to_scroll % 1.0; }, MouseScrollDelta::PixelDelta(_x, y) => { |