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.
This commit is contained in:
parent
e0993587e7
commit
14884deba7
25
src/input.rs
25
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) {
|
||||
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) => {
|
||||
|
|
Loading…
Reference in New Issue