Skip to content

Commit

Permalink
fix: Apply scroll_factor to v120 events
Browse files Browse the repository at this point in the history
I wasn't sure if, or how, scaling should apply to the `scroll_value120`
events. But it seems both sway and kwin just multiply by the scale
factor then round, so that seems reasonable.

This seems to fix pop-os/cosmic-settings#270.
  • Loading branch information
ids1024 authored and Drakulix committed May 10, 2024
1 parent 73b1219 commit 36bf611
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,10 @@ impl State {
frame =
frame.value(Axis::Horizontal, scroll_factor * horizontal_amount);
if let Some(discrete) = event.amount_v120(Axis::Horizontal) {
frame = frame.v120(Axis::Horizontal, discrete as i32);
frame = frame.v120(
Axis::Horizontal,
(discrete * scroll_factor).round() as i32,
);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Horizontal);
Expand All @@ -1049,7 +1052,10 @@ impl State {
if vertical_amount != 0.0 {
frame = frame.value(Axis::Vertical, scroll_factor * vertical_amount);
if let Some(discrete) = event.amount_v120(Axis::Vertical) {
frame = frame.v120(Axis::Vertical, discrete as i32);
frame = frame.v120(
Axis::Vertical,
(discrete * scroll_factor).round() as i32,
);
}
} else if event.source() == AxisSource::Finger {
frame = frame.stop(Axis::Vertical);
Expand Down

0 comments on commit 36bf611

Please sign in to comment.