aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/input.rs
diff options
context:
space:
mode:
authorTimo <16718859+toger5@users.noreply.github.com>2020-03-02 06:32:18 +0100
committerGitHub <noreply@github.com>2020-03-02 08:32:18 +0300
commitf83d55f0f05aeec943115e9c767e5c221d7f4317 (patch)
tree57eb833daf4ea4db13a05db6ea8b6b09f745c629 /alacritty/src/input.rs
parent1972cce8a4226dbe278e0a3b5d16fa13937e0463 (diff)
downloadr-alacritty-f83d55f0f05aeec943115e9c767e5c221d7f4317.tar.gz
r-alacritty-f83d55f0f05aeec943115e9c767e5c221d7f4317.tar.bz2
r-alacritty-f83d55f0f05aeec943115e9c767e5c221d7f4317.zip
Fix ignoring of slow touchpad scrolling
Fixes #3377.
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r--alacritty/src/input.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs
index bb89417e..01adedbc 100644
--- a/alacritty/src/input.rs
+++ b/alacritty/src/input.rs
@@ -469,16 +469,16 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
match delta {
MouseScrollDelta::LineDelta(_columns, lines) => {
let new_scroll_px = lines * self.ctx.size_info().cell_height;
- self.scroll_terminal(new_scroll_px as i32);
+ self.scroll_terminal(new_scroll_px as f64);
},
MouseScrollDelta::PixelDelta(lpos) => {
match phase {
TouchPhase::Started => {
// Reset offset to zero
- self.ctx.mouse_mut().scroll_px = 0;
+ self.ctx.mouse_mut().scroll_px = 0.;
},
TouchPhase::Moved => {
- self.scroll_terminal(lpos.y as i32);
+ self.scroll_terminal(lpos.y);
},
_ => (),
}
@@ -486,14 +486,14 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
}
}
- fn scroll_terminal(&mut self, new_scroll_px: i32) {
- let height = self.ctx.size_info().cell_height as i32;
+ fn scroll_terminal(&mut self, new_scroll_px: f64) {
+ let height = self.ctx.size_info().cell_height as f64;
if self.ctx.terminal().mode().intersects(TermMode::MOUSE_MODE) {
self.ctx.mouse_mut().scroll_px += new_scroll_px;
- let code = if new_scroll_px > 0 { 64 } else { 65 };
- let lines = (self.ctx.mouse().scroll_px / height).abs();
+ let code = if new_scroll_px > 0. { 64 } else { 65 };
+ let lines = (self.ctx.mouse().scroll_px / height).abs() as i32;
for _ in 0..lines {
self.mouse_report(code, ElementState::Pressed);
@@ -505,7 +505,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
.contains(TermMode::ALT_SCREEN | TermMode::ALTERNATE_SCROLL)
&& !self.ctx.modifiers().shift()
{
- let multiplier = i32::from(
+ let multiplier = f64::from(
self.ctx
.config()
.scrolling
@@ -514,8 +514,8 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
);
self.ctx.mouse_mut().scroll_px += new_scroll_px * multiplier;
- let cmd = if new_scroll_px > 0 { b'A' } else { b'B' };
- let lines = (self.ctx.mouse().scroll_px / height).abs();
+ let cmd = if new_scroll_px > 0. { b'A' } else { b'B' };
+ let lines = (self.ctx.mouse().scroll_px / height).abs() as i32;
let mut content = Vec::with_capacity(lines as usize * 3);
for _ in 0..lines {
@@ -525,7 +525,7 @@ impl<'a, T: EventListener, A: ActionContext<T>> Processor<'a, T, A> {
}
self.ctx.write_to_pty(content);
} else {
- let multiplier = i32::from(self.ctx.config().scrolling.multiplier());
+ let multiplier = f64::from(self.ctx.config().scrolling.multiplier());
self.ctx.mouse_mut().scroll_px += new_scroll_px * multiplier;
let lines = self.ctx.mouse().scroll_px / height;
@@ -953,8 +953,8 @@ mod tests {
height: 51.0,
cell_width: 3.0,
cell_height: 3.0,
- padding_x: 0.0,
- padding_y: 0.0,
+ padding_x: 0.,
+ padding_y: 0.,
dpr: 1.0,
};