input: add click method and middle button emulation
This commit is contained in:
parent
0524e01a3c
commit
b20153550e
24 changed files with 598 additions and 21 deletions
|
|
@ -16,7 +16,7 @@ use {
|
|||
exec::Command,
|
||||
input::{
|
||||
FocusFollowsMouseMode, InputDevice, Seat, SwitchEvent, acceleration::AccelProfile,
|
||||
capability::Capability,
|
||||
capability::Capability, clickmethod::ClickMethod,
|
||||
},
|
||||
keyboard::{
|
||||
Keymap,
|
||||
|
|
@ -1174,6 +1174,14 @@ impl ConfigClient {
|
|||
self.send(&ClientMessage::SetDragLockEnabled { device, enabled })
|
||||
}
|
||||
|
||||
pub fn set_input_click_method(&self, device: InputDevice, method: ClickMethod) {
|
||||
self.send(&ClientMessage::SetClickMethod { device, method })
|
||||
}
|
||||
|
||||
pub fn set_input_middle_button_emulation_enabled(&self, device: InputDevice, enabled: bool) {
|
||||
self.send(&ClientMessage::SetMiddleButtonEmulationEnabled { device, enabled })
|
||||
}
|
||||
|
||||
pub fn device_name(&self, device: InputDevice) -> String {
|
||||
let res = self.send_with_response(&ClientMessage::GetDeviceName { device });
|
||||
get_response!(res, String::new(), GetDeviceName { name });
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
client::{Client, ClientMatcher},
|
||||
input::{
|
||||
FocusFollowsMouseMode, InputDevice, Seat, SwitchEvent, acceleration::AccelProfile,
|
||||
capability::Capability,
|
||||
capability::Capability, clickmethod::ClickMethod,
|
||||
},
|
||||
keyboard::{Keymap, mods::Modifiers, syms::KeySym},
|
||||
logging::LogLevel,
|
||||
|
|
@ -710,6 +710,14 @@ pub enum ClientMessage<'a> {
|
|||
seat: Seat,
|
||||
key: KeySym,
|
||||
},
|
||||
SetClickMethod {
|
||||
device: InputDevice,
|
||||
method: ClickMethod,
|
||||
},
|
||||
SetMiddleButtonEmulationEnabled {
|
||||
device: InputDevice,
|
||||
enabled: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
pub mod acceleration;
|
||||
pub mod capability;
|
||||
pub mod clickmethod;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
_private::{DEFAULT_SEAT_NAME, ipc::WorkspaceSource},
|
||||
Axis, Direction, ModifiedKeySym, Workspace,
|
||||
input::{acceleration::AccelProfile, capability::Capability},
|
||||
input::{acceleration::AccelProfile, capability::Capability, clickmethod::ClickMethod},
|
||||
keyboard::{Keymap, mods::Modifiers, syms::KeySym},
|
||||
video::Connector,
|
||||
window::Window,
|
||||
|
|
@ -133,6 +134,20 @@ impl InputDevice {
|
|||
get!().set_input_natural_scrolling_enabled(self, enabled);
|
||||
}
|
||||
|
||||
/// Sets the click method of the device.
|
||||
///
|
||||
/// See <https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#click-method>
|
||||
pub fn set_click_method(self, method: ClickMethod) {
|
||||
get!().set_input_click_method(self, method);
|
||||
}
|
||||
|
||||
/// Sets whether middle button emulation is enabled for this device.
|
||||
///
|
||||
/// See <https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#middle-button-emulation>
|
||||
pub fn set_middle_button_emulation_enabled(self, enabled: bool) {
|
||||
get!().set_input_middle_button_emulation_enabled(self, enabled);
|
||||
}
|
||||
|
||||
/// Returns the syspath of this device.
|
||||
///
|
||||
/// E.g. `/sys/devices/pci0000:00/0000:00:08.1/0000:14:00.4/usb5/5-1/5-1.1/5-1.1.3/5-1.1.3:1.0`.
|
||||
|
|
|
|||
18
jay-config/src/input/clickmethod.rs
Normal file
18
jay-config/src/input/clickmethod.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//! Constants determining the click method of a device.
|
||||
//!
|
||||
//! See the libinput documentation for details.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The click method of a device.
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct ClickMethod(pub u32);
|
||||
|
||||
/// No click method handling
|
||||
pub const CLICK_METHOD_NONE: ClickMethod = ClickMethod(0);
|
||||
|
||||
/// Button area
|
||||
pub const CLICK_METHOD_BUTTON_AREAS: ClickMethod = ClickMethod(1 << 0);
|
||||
|
||||
/// Clickfinger
|
||||
pub const CLICK_METHOD_CLICKFINGER: ClickMethod = ClickMethod(1 << 1);
|
||||
Loading…
Add table
Add a link
Reference in a new issue