Set some touchpad input settings
Browse files at this commit20b75f5f4031ae2a1c6f902313d023cadecd4ab4Parent: 30879ed2 changed files +15 -1
- src/input.rs +13 -0
- src/tty.rs +2 -1
src/input.rsmodified+13 -0
| @@ -5,6 +5,7 @@ use smithay::backend::input::{ | |||
| 5 | KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, | 5 | KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, |
| 6 | TabletToolEvent, TabletToolTipEvent, TabletToolTipState, | 6 | TabletToolEvent, TabletToolTipEvent, TabletToolTipState, |
| 7 | }; | 7 | }; |
| 8 | +use smithay::backend::libinput::LibinputInputBackend; | ||
| 8 | use smithay::input::keyboard::{keysyms, FilterResult, KeysymHandle, ModifiersState}; | 9 | use smithay::input::keyboard::{keysyms, FilterResult, KeysymHandle, ModifiersState}; |
| 9 | use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent}; | 10 | use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent}; |
| 10 | use smithay::utils::SERIAL_COUNTER; | 11 | use smithay::utils::SERIAL_COUNTER; |
| @@ -414,4 +415,16 @@ impl Niri { | |||
| 414 | _ => {} | 415 | _ => {} |
| 415 | } | 416 | } |
| 416 | } | 417 | } |
| 418 | + | ||
| 419 | + pub fn process_libinput_event(&mut self, event: &mut InputEvent<LibinputInputBackend>) { | ||
| 420 | + if let InputEvent::DeviceAdded { device } = event { | ||
| 421 | + // According to Mutter code, this setting is specific to touchpads. | ||
| 422 | + let is_touchpad = device.config_tap_finger_count() > 0; | ||
| 423 | + if is_touchpad { | ||
| 424 | + let _ = device.config_tap_set_enabled(true); | ||
| 425 | + let _ = device.config_scroll_set_natural_scroll_enabled(true); | ||
| 426 | + let _ = device.config_accel_set_speed(0.2); | ||
| 427 | + } | ||
| 428 | + } | ||
| 429 | + } | ||
| 417 | } | 430 | } |
src/tty.rsmodified+2 -1
| @@ -122,9 +122,10 @@ impl Tty { | |||
| 122 | 122 | ||
| 123 | let input_backend = LibinputInputBackend::new(libinput.clone()); | 123 | let input_backend = LibinputInputBackend::new(libinput.clone()); |
| 124 | event_loop | 124 | event_loop |
| 125 | - .insert_source(input_backend, |event, _, data| { | 125 | + .insert_source(input_backend, |mut event, _, data| { |
| 126 | let tty = data.tty.as_mut().unwrap(); | 126 | let tty = data.tty.as_mut().unwrap(); |
| 127 | let mut change_vt = |vt| tty.change_vt(vt); | 127 | let mut change_vt = |vt| tty.change_vt(vt); |
| 128 | + data.niri.process_libinput_event(&mut event); | ||
| 128 | data.niri | 129 | data.niri |
| 129 | .process_input_event(&mut change_vt, CompositorMod::Super, event); | 130 | .process_input_event(&mut change_vt, CompositorMod::Super, event); |
| 130 | }) | 131 | }) |