summaryrefslogtreecommitdiff
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
parent1972cce8a4226dbe278e0a3b5d16fa13937e0463 (diff)
downloadalacritty-f83d55f0f05aeec943115e9c767e5c221d7f4317.tar.gz
alacritty-f83d55f0f05aeec943115e9c767e5c221d7f4317.zip
Fix ignoring of slow touchpad scrolling
Fixes #3377.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs6
-rw-r--r--alacritty/src/input.rs26
3 files changed, 17 insertions, 16 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d35dd047..a0ab066e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Tabstops cleared on resize
- Tabstops not breaking across lines
- Crash when parsing DCS escape with more than 16 parameters
+- Ignoring of slow touchpad scrolling
### Removed
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 587a5078..5888140f 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -272,7 +272,7 @@ pub struct Mouse {
pub right_button_state: ElementState,
pub last_click_timestamp: Instant,
pub click_state: ClickState,
- pub scroll_px: i32,
+ pub scroll_px: f64,
pub line: Line,
pub column: Column,
pub cell_side: Side,
@@ -292,11 +292,11 @@ impl Default for Mouse {
middle_button_state: ElementState::Released,
right_button_state: ElementState::Released,
click_state: ClickState::None,
- scroll_px: 0,
+ scroll_px: 0.,
line: Line(0),
column: Column(0),
cell_side: Side::Left,
- lines_scrolled: 0.0,
+ lines_scrolled: 0.,
block_url_launcher: false,
last_button: MouseButton::Other(0),
inside_grid: false,
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,
};