forge
Explore
Log in

Don't you dare go Hollow

Fix scrolling not working with missing mouse config

Browse files at this commit

1951d2a9f262196a706f2645efb18dac3c4d6839Ivan MolodetskikhParent: 9d8f640
niri-config/src/lib.rsmodified+6 -6
@@ -188,8 +188,8 @@ pub struct Touchpad {
188 pub disabled_on_external_mouse: bool,188 pub disabled_on_external_mouse: bool,
189 #[knuffel(child)]189 #[knuffel(child)]
190 pub middle_emulation: bool,190 pub middle_emulation: bool,
191- #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]191+ #[knuffel(child, unwrap(argument))]
192- pub scroll_factor: FloatOrInt<0, 100>,192+ pub scroll_factor: Option<FloatOrInt<0, 100>>,
193 }193 }
194 194
195 #[derive(knuffel::Decode, Debug, Default, PartialEq)]195 #[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -210,8 +210,8 @@ pub struct Mouse {
210 pub left_handed: bool,210 pub left_handed: bool,
211 #[knuffel(child)]211 #[knuffel(child)]
212 pub middle_emulation: bool,212 pub middle_emulation: bool,
213- #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]213+ #[knuffel(child, unwrap(argument))]
214- pub scroll_factor: FloatOrInt<0, 100>,214+ pub scroll_factor: Option<FloatOrInt<0, 100>>,
215 }215 }
216 216
217 #[derive(knuffel::Decode, Debug, Default, PartialEq)]217 #[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -3183,7 +3183,7 @@ mod tests {
3183 left_handed: false,3183 left_handed: false,
3184 disabled_on_external_mouse: true,3184 disabled_on_external_mouse: true,
3185 middle_emulation: false,3185 middle_emulation: false,
3186- scroll_factor: FloatOrInt(0.9),3186+ scroll_factor: Some(FloatOrInt(0.9)),
3187 },3187 },
3188 mouse: Mouse {3188 mouse: Mouse {
3189 off: false,3189 off: false,
@@ -3194,7 +3194,7 @@ mod tests {
3194 scroll_button: Some(273),3194 scroll_button: Some(273),
3195 left_handed: false,3195 left_handed: false,
3196 middle_emulation: true,3196 middle_emulation: true,
3197- scroll_factor: FloatOrInt(0.2),3197+ scroll_factor: Some(FloatOrInt(0.2)),
3198 },3198 },
3199 trackpoint: Trackpoint {3199 trackpoint: Trackpoint {
3200 off: true,3200 off: true,
src/input/mod.rsmodified+4 -3
@@ -1882,10 +1882,11 @@ impl State {
1882 }1882 }
1883 1883
1884 let scroll_factor = match source {1884 let scroll_factor = match source {
1885- AxisSource::Wheel => self.niri.config.borrow().input.mouse.scroll_factor.0,1885+ AxisSource::Wheel => self.niri.config.borrow().input.mouse.scroll_factor,
1886- AxisSource::Finger => self.niri.config.borrow().input.touchpad.scroll_factor.0,1886+ AxisSource::Finger => self.niri.config.borrow().input.touchpad.scroll_factor,
1887- _ => 1.0,1887+ _ => None,
1888 };1888 };
1889+ let scroll_factor = scroll_factor.map(|x| x.0).unwrap_or(1.);
1889 1890
1890 let horizontal_amount = horizontal_amount.unwrap_or_else(|| {1891 let horizontal_amount = horizontal_amount.unwrap_or_else(|| {
1891 // Winit backend, discrete scrolling.1892 // Winit backend, discrete scrolling.