Skip to content

Commit

Permalink
Fix generation of axis_stop events
Browse files Browse the repository at this point in the history
`axis_stop` should only be sent if the value is `Some(0)`, while this
also sent it for `None`. So every scroll event on one axis generated
stop events for the other.

This fixes scrolling with a touchpad in Alacritty.

Anvil already does this, comparing against `Some(0.0)`.
  • Loading branch information
ids1024 authored and Drakulix committed Dec 22, 2023
1 parent ad3a917 commit 144f8cb
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
backend::render::cursor::CursorState,
config::{xkb_config_to_wl, Action, Config, KeyPattern, KeyModifiers},
config::{xkb_config_to_wl, Action, Config, KeyModifiers, KeyPattern},
shell::{
focus::{target::PointerFocusTarget, FocusDirection},
grabs::{ResizeEdge, SeatMenuGrabState, SeatMoveGrabState},
Expand Down Expand Up @@ -1027,38 +1027,31 @@ impl State {
}
}

let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| {
event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.
});
let vertical_amount = event.amount(Axis::Vertical).unwrap_or_else(|| {
event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 3.0 / 120.
});
let horizontal_amount_discrete = event.amount_v120(Axis::Horizontal);
let vertical_amount_discrete = event.amount_v120(Axis::Vertical);

{
let mut frame = AxisFrame::new(event.time_msec()).source(event.source());
let mut frame = AxisFrame::new(event.time_msec()).source(event.source());
if let Some(horizontal_amount) = event.amount(Axis::Horizontal) {
if horizontal_amount != 0.0 {
frame =
frame.value(Axis::Horizontal, scroll_factor * horizontal_amount);
if let Some(discrete) = horizontal_amount_discrete {
if let Some(discrete) = event.amount_v120(Axis::Horizontal) {
frame = frame.v120(Axis::Horizontal, discrete as i32);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Horizontal);
}
}
if let Some(vertical_amount) = event.amount(Axis::Vertical) {
if vertical_amount != 0.0 {
frame = frame.value(Axis::Vertical, scroll_factor * vertical_amount);
if let Some(discrete) = vertical_amount_discrete {
if let Some(discrete) = event.amount_v120(Axis::Vertical) {
frame = frame.v120(Axis::Vertical, discrete as i32);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Vertical);
}
let ptr = seat.get_pointer().unwrap();
ptr.axis(self, frame);
ptr.frame(self);
}
let ptr = seat.get_pointer().unwrap();
ptr.axis(self, frame);
ptr.frame(self);
}
}
InputEvent::GestureSwipeBegin { event, .. } => {
Expand Down

0 comments on commit 144f8cb

Please sign in to comment.