forge
Explore
Log in

Don't you dare go Hollow

Implement scroll_factor mouse and touchpad setting (#730)

Browse files at this commit

8b39f986d9a2c99e87a9afc2e9d448a2c5280189Unverifiedelipp and Ivan MolodetskikhParent: 354c365
* Implement scroll_factor mouse and touchpad setting

* Change to FloatOrInt, add docs

* Also change v120 values

---------
niri-config/src/lib.rsmodified+8 -0
@@ -188,6 +188,8 @@ pub struct Touchpad {
188188 pub disabled_on_external_mouse: bool,
189189 #[knuffel(child)]
190190 pub middle_emulation: bool,
191+ #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]
192+ pub scroll_factor: FloatOrInt<0, 100>,
191193 }
192194
193195 #[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -208,6 +210,8 @@ pub struct Mouse {
208210 pub left_handed: bool,
209211 #[knuffel(child)]
210212 pub middle_emulation: bool,
213+ #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]
214+ pub scroll_factor: FloatOrInt<0, 100>,
211215 }
212216
213217 #[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -2958,6 +2962,7 @@ mod tests {
29582962 scroll-button 272
29592963 tap-button-map "left-middle-right"
29602964 disabled-on-external-mouse
2965+ scroll-factor 0.9
29612966 }
29622967
29632968 mouse {
@@ -2967,6 +2972,7 @@ mod tests {
29672972 scroll-method "no-scroll"
29682973 scroll-button 273
29692974 middle-emulation
2975+ scroll-factor 0.2
29702976 }
29712977
29722978 trackpoint {
@@ -3169,6 +3175,7 @@ mod tests {
31693175 left_handed: false,
31703176 disabled_on_external_mouse: true,
31713177 middle_emulation: false,
3178+ scroll_factor: FloatOrInt(0.9),
31723179 },
31733180 mouse: Mouse {
31743181 off: false,
@@ -3179,6 +3186,7 @@ mod tests {
31793186 scroll_button: Some(273),
31803187 left_handed: false,
31813188 middle_emulation: true,
3189+ scroll_factor: FloatOrInt(0.2),
31823190 },
31833191 trackpoint: Trackpoint {
31843192 off: true,
src/input/mod.rsmodified+11 -2
@@ -1881,14 +1881,23 @@ impl State {
18811881 }
18821882 }
18831883
1884+ let scroll_factor = match source {
1885+ AxisSource::Wheel => self.niri.config.borrow().input.mouse.scroll_factor.0,
1886+ AxisSource::Finger => self.niri.config.borrow().input.touchpad.scroll_factor.0,
1887+ _ => 1.0,
1888+ };
1889+
18841890 let horizontal_amount = horizontal_amount.unwrap_or_else(|| {
18851891 // Winit backend, discrete scrolling.
18861892 horizontal_amount_v120.unwrap_or(0.0) / 120. * 15.
1887- });
1893+ }) * scroll_factor;
18881894 let vertical_amount = vertical_amount.unwrap_or_else(|| {
18891895 // Winit backend, discrete scrolling.
18901896 vertical_amount_v120.unwrap_or(0.0) / 120. * 15.
1891- });
1897+ }) * scroll_factor;
1898+
1899+ let horizontal_amount_v120 = horizontal_amount_v120.map(|x| x * scroll_factor);
1900+ let vertical_amount_v120 = vertical_amount_v120.map(|x| x * scroll_factor);
18921901
18931902 let mut frame = AxisFrame::new(event.time_msec()).source(source);
18941903 if horizontal_amount != 0.0 {
wiki/Configuration:-Input.mdmodified+6 -0
@@ -32,6 +32,7 @@ input {
3232 natural-scroll
3333 // accel-speed 0.2
3434 // accel-profile "flat"
35+ // scroll-factor 1.0
3536 // scroll-method "two-finger"
3637 // tap-button-map "left-middle-right"
3738 // click-method "clickfinger"
@@ -45,6 +46,7 @@ input {
4546 // natural-scroll
4647 // accel-speed 0.2
4748 // accel-profile "flat"
49+ // scroll-factor 1.0
4850 // scroll-method "no-scroll"
4951 // left-handed
5052 // middle-emulation
@@ -154,6 +156,10 @@ Settings specific to `touchpad`s:
154156 - `click-method`: can be `button-areas` or `clickfinger`, changes the [click method](https://wayland.freedesktop.org/libinput/doc/latest/clickpad-softbuttons.html).
155157 - `disabled-on-external-mouse`: do not send events while external pointer device is plugged in.
156158
159+Settings specific to `touchpad` and `mouse`:
160+
161+- `scroll-factor`: scales the scrolling by this value.
162+
157163 Settings specific to `touchpad`, `mouse` and `tablet`:
158164
159165 - `left-handed`: if set, changes the device to left-handed mode.