Add scroll-button property for Touchpad, Mouse, Trackpoint, Trackball (#744)

This commit is contained in:
chillinbythetree
2024-10-17 01:43:47 -04:00
committed by GitHub
parent 84655d3b26
commit a480087618
4 changed files with 87 additions and 1 deletions
+20
View File
@@ -176,6 +176,8 @@ pub struct Touchpad {
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
pub scroll_method: Option<ScrollMethod>,
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child, unwrap(argument, str))]
pub tap_button_map: Option<TapButtonMap>,
#[knuffel(child)]
@@ -198,6 +200,8 @@ pub struct Mouse {
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
pub scroll_method: Option<ScrollMethod>,
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
pub left_handed: bool,
#[knuffel(child)]
@@ -216,6 +220,8 @@ pub struct Trackpoint {
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
pub scroll_method: Option<ScrollMethod>,
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
pub middle_emulation: bool,
}
@@ -230,6 +236,10 @@ pub struct Trackball {
pub accel_speed: f64,
#[knuffel(child, unwrap(argument, str))]
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
pub scroll_method: Option<ScrollMethod>,
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
pub left_handed: bool,
#[knuffel(child)]
@@ -2902,6 +2912,7 @@ mod tests {
accel-speed 0.2
accel-profile "flat"
scroll-method "two-finger"
scroll-button 272
tap-button-map "left-middle-right"
disabled-on-external-mouse
}
@@ -2911,6 +2922,7 @@ mod tests {
accel-speed 0.4
accel-profile "flat"
scroll-method "no-scroll"
scroll-button 273
middle-emulation
}
@@ -2920,6 +2932,7 @@ mod tests {
accel-speed 0.0
accel-profile "flat"
scroll-method "on-button-down"
scroll-button 274
}
trackball {
@@ -2927,6 +2940,8 @@ mod tests {
natural-scroll
accel-speed 0.0
accel-profile "flat"
scroll-method "edge"
scroll-button 275
left-handed
middle-emulation
}
@@ -3096,6 +3111,7 @@ mod tests {
accel_speed: 0.2,
accel_profile: Some(AccelProfile::Flat),
scroll_method: Some(ScrollMethod::TwoFinger),
scroll_button: Some(272),
tap_button_map: Some(TapButtonMap::LeftMiddleRight),
left_handed: false,
disabled_on_external_mouse: true,
@@ -3107,6 +3123,7 @@ mod tests {
accel_speed: 0.4,
accel_profile: Some(AccelProfile::Flat),
scroll_method: Some(ScrollMethod::NoScroll),
scroll_button: Some(273),
left_handed: false,
middle_emulation: true,
},
@@ -3116,6 +3133,7 @@ mod tests {
accel_speed: 0.0,
accel_profile: Some(AccelProfile::Flat),
scroll_method: Some(ScrollMethod::OnButtonDown),
scroll_button: Some(274),
middle_emulation: false,
},
trackball: Trackball {
@@ -3123,6 +3141,8 @@ mod tests {
natural_scroll: true,
accel_speed: 0.0,
accel_profile: Some(AccelProfile::Flat),
scroll_method: Some(ScrollMethod::Edge),
scroll_button: Some(275),
left_handed: true,
middle_emulation: true,
},
+10
View File
@@ -40,6 +40,16 @@ input {
// scroll-method "no-scroll"
}
trackpoint {
// off
// natural-scroll
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
// middle-emulation
}
// Uncomment this to make the mouse warp to the center of newly focused windows.
// warp-mouse-to-focus
+54
View File
@@ -2657,8 +2657,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(method) = c.scroll_method {
let _ = device.config_scroll_set_method(method.into());
if method == niri_config::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
if default == input::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
}
if let Some(tap_button_map) = c.tap_button_map {
@@ -2713,8 +2725,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(method) = c.scroll_method {
let _ = device.config_scroll_set_method(method.into());
if method == niri_config::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
if default == input::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
}
}
@@ -2735,6 +2759,24 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
} else if let Some(default) = device.config_accel_default_profile() {
let _ = device.config_accel_set_profile(default);
}
if let Some(method) = c.scroll_method {
let _ = device.config_scroll_set_method(method.into());
if method == niri_config::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
if default == input::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
}
}
if is_trackpoint {
@@ -2756,8 +2798,20 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(method) = c.scroll_method {
let _ = device.config_scroll_set_method(method.into());
if method == niri_config::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
if default == input::ScrollMethod::OnButtonDown {
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
}
}
}
+3 -1
View File
@@ -56,6 +56,7 @@ input {
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
// middle-emulation
}
@@ -134,13 +135,14 @@ A few settings are common between input devices:
- `off`: if set, no events will be sent from this device.
A few settings are common between `touchpad`, `mouse` and `trackpoint`:
A few settings are common between `touchpad`, `mouse`, `trackpoint`, and `trackball`:
- `natural-scroll`: if set, inverts the scrolling direction.
- `accel-speed`: pointer acceleration speed, valid values are from `-1.0` to `1.0` where the default is `0.0`.
- `accel-profile`: can be `adaptive` (the default) or `flat` (disables pointer acceleration).
- `scroll-method`: when to generate scroll events instead of pointer motion events, can be `no-scroll`, `two-finger`, `edge`, or `on-button-down`.
The default and supported methods vary depending on the device type.
- `scroll-button`: the button code used for the `on-button-down` scroll method. You can find it in `libinput debug-events`.
- `middle-emulation`: emulate a middle mouse click by pressing left and right mouse buttons at once.
Settings specific to `touchpad`s: