Skip to content

Commit

Permalink
WIP: link gsettings click-method to sway click_method. Address regoli…
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilmer committed Feb 12, 2025
1 parent 1dcd742 commit 4c654ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ impl PointerMethods for MouseHandler {
self.sway_connection().run_command(cmd)?;
Ok(())
}

fn apply_click_method(&mut self) -> Result<(), Box<dyn Error>> {
Ok(())
}
}

impl InputHandler for MouseHandler {
Expand Down
24 changes: 24 additions & 0 deletions src/touchpad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ impl PointerMethods for TouchpadHandler {
self.sway_connection().run_command(cmd)?;
Ok(())
}

/**
* See https://manpages.debian.org/experimental/sway/sway-input.5.en.html
*
* How to generate software-emulated buttons, either disabled (“none”),
* through specific areas (“areas”), number of fingers (“fingers”) or
* left as hardware default (“default”).
*/
fn apply_click_method(&mut self) -> Result<(), Box<dyn Error>> {
let click_method: String = self.settings().get("click-method");

let click_method: &str = match click_method.as_ref() {
"areas" => "button_areas",
"fingers" => "clickfinger",
_ => "none",
};

let pointer_type = self.pointer_type();
let cmd = format!("input type:{pointer_type} click_method {click_method}");
info!("{cmd}");
self.sway_connection().run_command(cmd)?;
Ok(())
}
}

impl InputHandler for TouchpadHandler {
Expand All @@ -136,6 +159,7 @@ impl InputHandler for TouchpadHandler {
"tap-and-drag" => self.use_drag()?,
"tap-and-drag-lock" => self.use_drag_lock()?,
"middle-click-emulation" => self.emulate_middle_click()?,
"click_method" => self.apply_click_method()?,
_ => (),
};
Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub trait PointerMethods: InputHandler {
}
Ok(())
}
fn apply_click_method(&mut self) -> Result<(), Box<dyn Error>>;
}

pub trait SwayTypeToPrimitive<T> {
Expand Down

0 comments on commit 4c654ef

Please sign in to comment.