mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Add touchpad accel-profile setting
This commit is contained in:
@@ -10,6 +10,7 @@ use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler};
|
||||
use smithay::input::keyboard::keysyms::KEY_NoSymbol;
|
||||
use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
|
||||
use smithay::input::keyboard::{Keysym, XkbConfig};
|
||||
use smithay::reexports::input;
|
||||
|
||||
#[derive(knuffel::Decode, Debug, PartialEq)]
|
||||
pub struct Config {
|
||||
@@ -109,6 +110,23 @@ pub struct Touchpad {
|
||||
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)]
|
||||
pub enum AccelProfile {
|
||||
Adaptive,
|
||||
Flat,
|
||||
}
|
||||
|
||||
impl From<AccelProfile> for input::AccelProfile {
|
||||
fn from(value: AccelProfile) -> Self {
|
||||
match value {
|
||||
AccelProfile::Adaptive => Self::Adaptive,
|
||||
AccelProfile::Flat => Self::Flat,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, PartialEq)]
|
||||
@@ -571,6 +589,20 @@ impl FromStr for SizeChange {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for AccelProfile {
|
||||
type Err = miette::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"adaptive" => Ok(Self::Adaptive),
|
||||
"flat" => Ok(Self::Flat),
|
||||
_ => Err(miette!(
|
||||
r#"invalid accel profile, can be "adaptive" or "flat""#
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_miette_hook() -> Result<(), miette::InstallError> {
|
||||
miette::set_hook(Box::new(|_| Box::new(NarratableReportHandler::new())))
|
||||
}
|
||||
@@ -609,6 +641,7 @@ mod tests {
|
||||
touchpad {
|
||||
tap
|
||||
accel-speed 0.2
|
||||
accel-profile "flat"
|
||||
}
|
||||
|
||||
tablet {
|
||||
@@ -696,6 +729,7 @@ mod tests {
|
||||
tap: true,
|
||||
natural_scroll: false,
|
||||
accel_speed: 0.2,
|
||||
accel_profile: Some(AccelProfile::Flat),
|
||||
},
|
||||
tablet: Tablet {
|
||||
map_to_output: Some("eDP-1".to_owned()),
|
||||
|
||||
@@ -29,6 +29,7 @@ input {
|
||||
tap
|
||||
natural-scroll
|
||||
// accel-speed 0.2
|
||||
// accel-profile "flat"
|
||||
}
|
||||
|
||||
tablet {
|
||||
|
||||
@@ -96,6 +96,10 @@ impl State {
|
||||
let _ = device.config_tap_set_enabled(c.tap);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
if device.has_capability(input::DeviceCapability::TabletTool) {
|
||||
|
||||
Reference in New Issue
Block a user