mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Add a few mouse libinput settings
This commit is contained in:
@@ -48,6 +48,8 @@ pub struct Input {
|
|||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub touchpad: Touchpad,
|
pub touchpad: Touchpad,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
|
pub mouse: Mouse,
|
||||||
|
#[knuffel(child, default)]
|
||||||
pub tablet: Tablet,
|
pub tablet: Tablet,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub disable_power_key_handling: bool,
|
pub disable_power_key_handling: bool,
|
||||||
@@ -118,6 +120,16 @@ pub struct Touchpad {
|
|||||||
pub tap_button_map: Option<TapButtonMap>,
|
pub tap_button_map: Option<TapButtonMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
|
||||||
|
pub struct Mouse {
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub natural_scroll: bool,
|
||||||
|
#[knuffel(child, unwrap(argument), default)]
|
||||||
|
pub accel_speed: f64,
|
||||||
|
#[knuffel(child, unwrap(argument, str))]
|
||||||
|
pub accel_profile: Option<AccelProfile>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum AccelProfile {
|
pub enum AccelProfile {
|
||||||
Adaptive,
|
Adaptive,
|
||||||
@@ -679,6 +691,12 @@ mod tests {
|
|||||||
tap-button-map "left-middle-right"
|
tap-button-map "left-middle-right"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse {
|
||||||
|
natural-scroll
|
||||||
|
accel-speed 0.4
|
||||||
|
accel-profile "flat"
|
||||||
|
}
|
||||||
|
|
||||||
tablet {
|
tablet {
|
||||||
map-to-output "eDP-1"
|
map-to-output "eDP-1"
|
||||||
}
|
}
|
||||||
@@ -768,6 +786,11 @@ mod tests {
|
|||||||
accel_profile: Some(AccelProfile::Flat),
|
accel_profile: Some(AccelProfile::Flat),
|
||||||
tap_button_map: Some(TapButtonMap::LeftMiddleRight),
|
tap_button_map: Some(TapButtonMap::LeftMiddleRight),
|
||||||
},
|
},
|
||||||
|
mouse: Mouse {
|
||||||
|
natural_scroll: true,
|
||||||
|
accel_speed: 0.4,
|
||||||
|
accel_profile: Some(AccelProfile::Flat),
|
||||||
|
},
|
||||||
tablet: Tablet {
|
tablet: Tablet {
|
||||||
map_to_output: Some("eDP-1".to_owned()),
|
map_to_output: Some("eDP-1".to_owned()),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ input {
|
|||||||
// tap-button-map "left-middle-right"
|
// tap-button-map "left-middle-right"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse {
|
||||||
|
// natural-scroll
|
||||||
|
// accel-speed 0.2
|
||||||
|
// accel-profile "flat"
|
||||||
|
}
|
||||||
|
|
||||||
tablet {
|
tablet {
|
||||||
// Set the name of the output (see below) which the tablet will map to.
|
// Set the name of the output (see below) which the tablet will map to.
|
||||||
// If this is unset or the output doesn't exist, the tablet maps to one of the
|
// If this is unset or the output doesn't exist, the tablet maps to one of the
|
||||||
|
|||||||
@@ -119,6 +119,35 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is how Mutter tells apart mice.
|
||||||
|
let mut is_trackball = false;
|
||||||
|
let mut is_trackpoint = false;
|
||||||
|
if let Some(udev_device) = unsafe { device.udev_device() } {
|
||||||
|
if udev_device.property_value("ID_INPUT_TRACKBALL").is_some() {
|
||||||
|
is_trackball = true;
|
||||||
|
}
|
||||||
|
if udev_device
|
||||||
|
.property_value("ID_INPUT_POINTINGSTICK")
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
|
is_trackpoint = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let is_mouse = device.has_capability(input::DeviceCapability::Pointer)
|
||||||
|
&& !is_touchpad
|
||||||
|
&& !is_trackball
|
||||||
|
&& !is_trackpoint;
|
||||||
|
if is_mouse {
|
||||||
|
let c = &self.niri.config.borrow().input.mouse;
|
||||||
|
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
|
||||||
|
let _ = device.config_accel_set_speed(c.accel_speed);
|
||||||
|
|
||||||
|
if let Some(accel_profile) = c.accel_profile {
|
||||||
|
let _ = device.config_accel_set_profile(accel_profile.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InputEvent::DeviceRemoved { device } => {
|
InputEvent::DeviceRemoved { device } => {
|
||||||
self.niri.tablets.remove(device);
|
self.niri.tablets.remove(device);
|
||||||
|
|||||||
Reference in New Issue
Block a user