1
0
Fork 0
forked from wry/wry

input: add click method and middle button emulation

This commit is contained in:
Stipe Kotarac 2025-05-12 17:52:36 +02:00 committed by Julian Orth
parent 0524e01a3c
commit b20153550e
24 changed files with 598 additions and 21 deletions

View file

@ -3,7 +3,7 @@ use {
async_engine::SpawnedFuture,
backend::{
self, BackendColorSpace, BackendTransferFunction, ConnectorId, DrmDeviceId,
InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId,
InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod, InputDeviceId,
},
client::{Client, ClientId},
cmm::cmm_transfer_function::TransferFunction,
@ -56,6 +56,9 @@ use {
CAP_GESTURE, CAP_KEYBOARD, CAP_POINTER, CAP_SWITCH, CAP_TABLET_PAD,
CAP_TABLET_TOOL, CAP_TOUCH, Capability,
},
clickmethod::{
CLICK_METHOD_BUTTON_AREAS, CLICK_METHOD_CLICKFINGER, CLICK_METHOD_NONE, ClickMethod,
},
},
keyboard::{Keymap, mods::Modifiers, syms::KeySym},
logging::LogLevel,
@ -828,6 +831,32 @@ impl ConfigProxyHandler {
Ok(())
}
fn handle_set_click_method(
&self,
device: InputDevice,
click_method: ClickMethod,
) -> Result<(), CphError> {
let dev = self.get_device_handler_data(device)?;
let method = match click_method {
CLICK_METHOD_NONE => InputDeviceClickMethod::None,
CLICK_METHOD_BUTTON_AREAS => InputDeviceClickMethod::ButtonAreas,
CLICK_METHOD_CLICKFINGER => InputDeviceClickMethod::Clickfinger,
_ => return Err(CphError::UnknownClickMethod(click_method)),
};
dev.device.set_click_method(method);
Ok(())
}
fn handle_set_middle_button_emulation_enabled(
&self,
device: InputDevice,
enabled: bool,
) -> Result<(), CphError> {
let dev = self.get_device_handler_data(device)?;
dev.device.set_middle_button_emulation_enabled(enabled);
Ok(())
}
fn handle_set_ei_socket_enabled(&self, enabled: bool) {
self.state.enable_ei_acceptor.set(enabled);
self.state.update_ei_acceptor();
@ -2916,6 +2945,12 @@ impl ConfigProxyHandler {
ClientMessage::SetPointerRevertKey { seat, key } => self
.handle_set_pointer_revert_key(seat, key)
.wrn("set_pointer_revert_key")?,
ClientMessage::SetClickMethod { device, method } => self
.handle_set_click_method(device, method)
.wrn("set_click_method")?,
ClientMessage::SetMiddleButtonEmulationEnabled { device, enabled } => self
.handle_set_middle_button_emulation_enabled(device, enabled)
.wrn("set_middle_button_emulation_enabled")?,
}
Ok(())
}
@ -2945,6 +2980,8 @@ enum CphError {
UnknownAccelProfile(AccelProfile),
#[error("Queried unknown capability: {}", (.0).0)]
UnknownCapability(Capability),
#[error("Tried to set an unknown click method: {}", (.0).0)]
UnknownClickMethod(ClickMethod),
#[error("The sized {} is outside the valid range [{}, {}] for component {}", .0, .1.min(), .1.max(), .1.name())]
InvalidSize(i32, ThemeSized),
#[error("The ol' forker is not available")]