aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelipp <1861512+elipp@users.noreply.github.com>2024-11-03 20:43:03 +0200
committerGitHub <noreply@github.com>2024-11-03 18:43:03 +0000
commit8b39f986d9a2c99e87a9afc2e9d448a2c5280189 (patch)
tree16cd551ed048e754cd185967089548592ebe278c
parent354c365a0345787f6b98ee2d77d4516150a61254 (diff)
downloadniri-8b39f986d9a2c99e87a9afc2e9d448a2c5280189.tar.gz
niri-8b39f986d9a2c99e87a9afc2e9d448a2c5280189.tar.bz2
niri-8b39f986d9a2c99e87a9afc2e9d448a2c5280189.zip
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 <yalterz@gmail.com>
-rw-r--r--niri-config/src/lib.rs8
-rw-r--r--src/input/mod.rs13
-rw-r--r--wiki/Configuration:-Input.md6
3 files changed, 25 insertions, 2 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 042cf6ba..86e6510c 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -188,6 +188,8 @@ pub struct Touchpad {
pub disabled_on_external_mouse: bool,
#[knuffel(child)]
pub middle_emulation: bool,
+ #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]
+ pub scroll_factor: FloatOrInt<0, 100>,
}
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -208,6 +210,8 @@ pub struct Mouse {
pub left_handed: bool,
#[knuffel(child)]
pub middle_emulation: bool,
+ #[knuffel(child, unwrap(argument), default = FloatOrInt(1.0))]
+ pub scroll_factor: FloatOrInt<0, 100>,
}
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
@@ -2958,6 +2962,7 @@ mod tests {
scroll-button 272
tap-button-map "left-middle-right"
disabled-on-external-mouse
+ scroll-factor 0.9
}
mouse {
@@ -2967,6 +2972,7 @@ mod tests {
scroll-method "no-scroll"
scroll-button 273
middle-emulation
+ scroll-factor 0.2
}
trackpoint {
@@ -3169,6 +3175,7 @@ mod tests {
left_handed: false,
disabled_on_external_mouse: true,
middle_emulation: false,
+ scroll_factor: FloatOrInt(0.9),
},
mouse: Mouse {
off: false,
@@ -3179,6 +3186,7 @@ mod tests {
scroll_button: Some(273),
left_handed: false,
middle_emulation: true,
+ scroll_factor: FloatOrInt(0.2),
},
trackpoint: Trackpoint {
off: true,
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 {
diff --git a/wiki/Configuration:-Input.md b/wiki/Configuration:-Input.md
index 05636fa5..b47fa19a 100644
--- a/wiki/Configuration:-Input.md
+++ b/wiki/Configuration:-Input.md
@@ -32,6 +32,7 @@ input {
natural-scroll
// accel-speed 0.2
// accel-profile "flat"
+ // scroll-factor 1.0
// scroll-method "two-finger"
// tap-button-map "left-middle-right"
// click-method "clickfinger"
@@ -45,6 +46,7 @@ input {
// natural-scroll
// accel-speed 0.2
// accel-profile "flat"
+ // scroll-factor 1.0
// scroll-method "no-scroll"
// left-handed
// middle-emulation
@@ -154,6 +156,10 @@ Settings specific to `touchpad`s:
- `click-method`: can be `button-areas` or `clickfinger`, changes the [click method](https://wayland.freedesktop.org/libinput/doc/latest/clickpad-softbuttons.html).
- `disabled-on-external-mouse`: do not send events while external pointer device is plugged in.
+Settings specific to `touchpad` and `mouse`:
+
+- `scroll-factor`: scales the scrolling by this value.
+
Settings specific to `touchpad`, `mouse` and `tablet`:
- `left-handed`: if set, changes the device to left-handed mode.