From c8e46b9d172dfa2ca89d82b87055b8e39622f80c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 23 May 2024 16:01:54 +0900 Subject: Add "off" and "disabled-on-external-mouse" properties to input devices This is called "events " in Sway, but we decided to use more abstracted form for consistency with the other config items. "disabled-on-external-mouse" is added only to touchpads, but there might be other devices that support this option. I think "off" also applies to keyboards, but I'm not going to add the one because we don't have libinput machinery for the keyboard config, and it's unlikely that user wants to disable _all_ keyboards. OTOH, pointer devices can be disabled per type. Perhaps, this should be revisited after implementing #371. --- src/input/mod.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/input/mod.rs b/src/input/mod.rs index a36ea62b..893fd7de 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -2219,6 +2219,13 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: let is_touchpad = device.config_tap_finger_count() > 0; if is_touchpad { let c = &config.touchpad; + let _ = device.config_send_events_set_mode(if c.off { + input::SendEventsMode::DISABLED + } else if c.disabled_on_external_mouse { + input::SendEventsMode::DISABLED_ON_EXTERNAL_MOUSE + } else { + input::SendEventsMode::ENABLED + }); let _ = device.config_tap_set_enabled(c.tap); let _ = device.config_dwt_set_enabled(c.dwt); let _ = device.config_dwtp_set_enabled(c.dwtp); @@ -2272,6 +2279,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: && !is_trackpoint; if is_mouse { let c = &config.mouse; + let _ = device.config_send_events_set_mode(if c.off { + input::SendEventsMode::DISABLED + } else { + input::SendEventsMode::ENABLED + }); let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll); let _ = device.config_accel_set_speed(c.accel_speed); let _ = device.config_left_handed_set(c.left_handed); @@ -2291,6 +2303,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: if is_trackpoint { let c = &config.trackpoint; + let _ = device.config_send_events_set_mode(if c.off { + input::SendEventsMode::DISABLED + } else { + input::SendEventsMode::ENABLED + }); let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll); let _ = device.config_accel_set_speed(c.accel_speed); @@ -2310,6 +2327,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input:: let is_tablet = device.has_capability(input::DeviceCapability::TabletTool); if is_tablet { let c = &config.tablet; + let _ = device.config_send_events_set_mode(if c.off { + input::SendEventsMode::DISABLED + } else { + input::SendEventsMode::ENABLED + }); let _ = device.config_left_handed_set(c.left_handed); } } -- cgit