From 8b39f986d9a2c99e87a9afc2e9d448a2c5280189 Mon Sep 17 00:00:00 2001 From: elipp <1861512+elipp@users.noreply.github.com> Date: Sun, 3 Nov 2024 20:43:03 +0200 Subject: Implement scroll_factor mouse and touchpad setting (#730) * Implement scroll_factor mouse and touchpad setting * Change to FloatOrInt, add docs * Also change v120 values --------- Co-authored-by: Ivan Molodetskikh --- src/input/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input/mod.rs b/src/input/mod.rs index 5800b8a4..9936102e 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1881,14 +1881,23 @@ impl State { } } + let scroll_factor = match source { + AxisSource::Wheel => self.niri.config.borrow().input.mouse.scroll_factor.0, + AxisSource::Finger => self.niri.config.borrow().input.touchpad.scroll_factor.0, + _ => 1.0, + }; + let horizontal_amount = horizontal_amount.unwrap_or_else(|| { // Winit backend, discrete scrolling. horizontal_amount_v120.unwrap_or(0.0) / 120. * 15. - }); + }) * scroll_factor; let vertical_amount = vertical_amount.unwrap_or_else(|| { // Winit backend, discrete scrolling. vertical_amount_v120.unwrap_or(0.0) / 120. * 15. - }); + }) * scroll_factor; + + let horizontal_amount_v120 = horizontal_amount_v120.map(|x| x * scroll_factor); + let vertical_amount_v120 = vertical_amount_v120.map(|x| x * scroll_factor); let mut frame = AxisFrame::new(event.time_msec()).source(source); if horizontal_amount != 0.0 { -- cgit