forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiBd8a511bKirill Chibisov3 years ago243 commits

input.rs750 lines, 31.3 KiBHistoryRawDownload
1use smithay::backend::input::{
2 AbsolutePositionEvent, Axis, AxisSource, ButtonState, Device, DeviceCapability, Event,
3 GestureBeginEvent, GestureEndEvent, GesturePinchUpdateEvent as _, GestureSwipeUpdateEvent as _,
4 InputBackend, InputEvent, KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent,
5 PointerMotionEvent, ProximityState, TabletToolButtonEvent, TabletToolEvent,
6 TabletToolProximityEvent, TabletToolTipEvent, TabletToolTipState,
7};
8use smithay::backend::libinput::LibinputInputBackend;
9use smithay::input::keyboard::{keysyms, FilterResult, KeysymHandle, ModifiersState};
10use smithay::input::pointer::{
11 AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent,
12 GesturePinchEndEvent, GesturePinchUpdateEvent, GestureSwipeBeginEvent, GestureSwipeEndEvent,
13 GestureSwipeUpdateEvent, MotionEvent, RelativeMotionEvent,
14};
15use smithay::utils::SERIAL_COUNTER;
16use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait};
17
18use crate::config::{Action, Config, Modifiers};
19use crate::niri::State;
20use crate::utils::{center, get_monotonic_time, spawn};
21
22pub enum CompositorMod {
23 Super,
24 Alt,
25}
26
27impl From<Action> for FilterResult<Action> {
28 fn from(value: Action) -> Self {
29 match value {
30 Action::None => FilterResult::Forward,
31 action => FilterResult::Intercept(action),
32 }
33 }
34}
35
36fn action(
37 config: &Config,
38 comp_mod: CompositorMod,
39 keysym: KeysymHandle,
40 mods: ModifiersState,
41) -> Action {
42 use keysyms::*;
43
44 // Handle hardcoded binds.
45 #[allow(non_upper_case_globals)] // wat
46 match keysym.modified_sym().raw() {
47 modified @ KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12 => {
48 let vt = (modified - KEY_XF86Switch_VT_1 + 1) as i32;
49 return Action::ChangeVt(vt);
50 }
51 KEY_XF86PowerOff => return Action::Suspend,
52 _ => (),
53 }
54
55 // Handle configured binds.
56 let mut modifiers = Modifiers::empty();
57 if mods.ctrl {
58 modifiers |= Modifiers::CTRL;
59 }
60 if mods.shift {
61 modifiers |= Modifiers::SHIFT;
62 }
63 if mods.alt {
64 modifiers |= Modifiers::ALT;
65 }
66 if mods.logo {
67 modifiers |= Modifiers::SUPER;
68 }
69
70 let (mod_down, mut comp_mod) = match comp_mod {
71 CompositorMod::Super => (mods.logo, Modifiers::SUPER),
72 CompositorMod::Alt => (mods.alt, Modifiers::ALT),
73 };
74 if mod_down {
75 modifiers |= Modifiers::COMPOSITOR;
76 } else {
77 comp_mod = Modifiers::empty();
78 }
79
80 let Some(&raw) = keysym.raw_syms().first() else {
81 return Action::None;
82 };
83 for bind in &config.binds.0 {
84 if bind.key.keysym != raw {
85 continue;
86 }
87
88 if bind.key.modifiers | comp_mod == modifiers {
89 return bind.actions.first().cloned().unwrap_or(Action::None);
90 }
91 }
92
93 Action::None
94}
95
96impl State {
97 pub fn process_input_event<I: InputBackend>(&mut self, event: InputEvent<I>) {
98 let _span = tracy_client::span!("process_input_event");
99 trace!("process_input_event");
100
101 // A bit of a hack, but animation end runs some logic (i.e. workspace clean-up) and it
102 // doesn't always trigger due to damage, etc. So run it here right before it might prove
103 // important. Besides, animations affect the input, so it's best to have up-to-date values
104 // here.
105 self.niri
106 .monitor_set
107 .advance_animations(get_monotonic_time());
108
109 let comp_mod = self.backend.mod_key();
110
111 match event {
112 InputEvent::Keyboard { event, .. } => {
113 let serial = SERIAL_COUNTER.next_serial();
114 let time = Event::time_msec(&event);
115
116 let action = self.niri.seat.get_keyboard().unwrap().input(
117 self,
118 event.key_code(),
119 event.state(),
120 serial,
121 time,
122 |self_, mods, keysym| {
123 if event.state() == KeyState::Pressed {
124 let config = self_.niri.config.borrow();
125 action(&config, comp_mod, keysym, *mods).into()
126 } else {
127 FilterResult::Forward
128 }
129 },
130 );
131
132 if let Some(action) = action {
133 match action {
134 Action::None => unreachable!(),
135 Action::Quit => {
136 info!("quitting because quit bind was pressed");
137 self.niri.stop_signal.stop()
138 }
139 Action::ChangeVt(vt) => {
140 self.backend.change_vt(vt);
141 }
142 Action::Suspend => {
143 self.backend.suspend();
144 }
145 Action::ToggleDebugTint => {
146 self.backend.toggle_debug_tint();
147 }
148 Action::Spawn(command) => {
149 if let Some((command, args)) = command.split_first() {
150 spawn(command, args);
151 }
152 }
153 Action::Screenshot => {
154 let active = self.niri.monitor_set.active_output().cloned();
155 if let Some(active) = active {
156 if let Some(renderer) = self.backend.renderer() {
157 if let Err(err) = self.niri.screenshot(renderer, &active) {
158 warn!("error taking screenshot: {err:?}");
159 }
160 }
161 }
162 }
163 Action::CloseWindow => {
164 if let Some(window) = self.niri.monitor_set.focus() {
165 window.toplevel().send_close();
166 }
167 }
168 Action::FullscreenWindow => {
169 let focus = self.niri.monitor_set.focus().cloned();
170 if let Some(window) = focus {
171 self.niri.monitor_set.toggle_fullscreen(&window);
172 }
173 }
174 Action::MoveColumnLeft => {
175 self.niri.monitor_set.move_left();
176 // FIXME: granular
177 self.niri.queue_redraw_all();
178 }
179 Action::MoveColumnRight => {
180 self.niri.monitor_set.move_right();
181 // FIXME: granular
182 self.niri.queue_redraw_all();
183 }
184 Action::MoveWindowDown => {
185 self.niri.monitor_set.move_down();
186 // FIXME: granular
187 self.niri.queue_redraw_all();
188 }
189 Action::MoveWindowUp => {
190 self.niri.monitor_set.move_up();
191 // FIXME: granular
192 self.niri.queue_redraw_all();
193 }
194 Action::FocusColumnLeft => {
195 self.niri.monitor_set.focus_left();
196 }
197 Action::FocusColumnRight => {
198 self.niri.monitor_set.focus_right();
199 }
200 Action::FocusWindowDown => {
201 self.niri.monitor_set.focus_down();
202 }
203 Action::FocusWindowUp => {
204 self.niri.monitor_set.focus_up();
205 }
206 Action::MoveWindowToWorkspaceDown => {
207 self.niri.monitor_set.move_to_workspace_down();
208 // FIXME: granular
209 self.niri.queue_redraw_all();
210 }
211 Action::MoveWindowToWorkspaceUp => {
212 self.niri.monitor_set.move_to_workspace_up();
213 // FIXME: granular
214 self.niri.queue_redraw_all();
215 }
216 Action::MoveWindowToWorkspace(idx) => {
217 self.niri.monitor_set.move_to_workspace(idx);
218 // FIXME: granular
219 self.niri.queue_redraw_all();
220 }
221 Action::FocusWorkspaceDown => {
222 self.niri.monitor_set.switch_workspace_down();
223 // FIXME: granular
224 self.niri.queue_redraw_all();
225 }
226 Action::FocusWorkspaceUp => {
227 self.niri.monitor_set.switch_workspace_up();
228 // FIXME: granular
229 self.niri.queue_redraw_all();
230 }
231 Action::FocusWorkspace(idx) => {
232 self.niri.monitor_set.switch_workspace(idx);
233 // FIXME: granular
234 self.niri.queue_redraw_all();
235 }
236 Action::ConsumeWindowIntoColumn => {
237 self.niri.monitor_set.consume_into_column();
238 // FIXME: granular
239 self.niri.queue_redraw_all();
240 }
241 Action::ExpelWindowFromColumn => {
242 self.niri.monitor_set.expel_from_column();
243 // FIXME: granular
244 self.niri.queue_redraw_all();
245 }
246 Action::SwitchPresetColumnWidth => {
247 self.niri.monitor_set.toggle_width();
248 }
249 Action::MaximizeColumn => {
250 self.niri.monitor_set.toggle_full_width();
251 }
252 Action::FocusMonitorLeft => {
253 if let Some(output) = self.niri.output_left() {
254 self.niri.monitor_set.focus_output(&output);
255 self.move_cursor_to_output(&output);
256 }
257 }
258 Action::FocusMonitorRight => {
259 if let Some(output) = self.niri.output_right() {
260 self.niri.monitor_set.focus_output(&output);
261 self.move_cursor_to_output(&output);
262 }
263 }
264 Action::FocusMonitorDown => {
265 if let Some(output) = self.niri.output_down() {
266 self.niri.monitor_set.focus_output(&output);
267 self.move_cursor_to_output(&output);
268 }
269 }
270 Action::FocusMonitorUp => {
271 if let Some(output) = self.niri.output_up() {
272 self.niri.monitor_set.focus_output(&output);
273 self.move_cursor_to_output(&output);
274 }
275 }
276 Action::MoveWindowToMonitorLeft => {
277 if let Some(output) = self.niri.output_left() {
278 self.niri.monitor_set.move_to_output(&output);
279 self.move_cursor_to_output(&output);
280 }
281 }
282 Action::MoveWindowToMonitorRight => {
283 if let Some(output) = self.niri.output_right() {
284 self.niri.monitor_set.move_to_output(&output);
285 self.move_cursor_to_output(&output);
286 }
287 }
288 Action::MoveWindowToMonitorDown => {
289 if let Some(output) = self.niri.output_down() {
290 self.niri.monitor_set.move_to_output(&output);
291 self.move_cursor_to_output(&output);
292 }
293 }
294 Action::MoveWindowToMonitorUp => {
295 if let Some(output) = self.niri.output_up() {
296 self.niri.monitor_set.move_to_output(&output);
297 self.move_cursor_to_output(&output);
298 }
299 }
300 }
301 }
302 }
303 InputEvent::PointerMotion { event, .. } => {
304 // We need an output to be able to move the pointer.
305 if self.niri.global_space.outputs().next().is_none() {
306 return;
307 }
308
309 let serial = SERIAL_COUNTER.next_serial();
310
311 let pointer = self.niri.seat.get_pointer().unwrap();
312
313 let pos = pointer.current_location();
314
315 // We have an output, so we can compute the new location and focus.
316 let mut new_pos = pos + event.delta();
317
318 if self
319 .niri
320 .global_space
321 .output_under(new_pos)
322 .next()
323 .is_none()
324 {
325 // We ended up outside the outputs and need to clip the movement.
326 if let Some(output) = self.niri.global_space.output_under(pos).next() {
327 // The pointer was previously on some output. Clip the movement against its
328 // boundaries.
329 let geom = self.niri.global_space.output_geometry(output).unwrap();
330 new_pos.x = new_pos
331 .x
332 .clamp(geom.loc.x as f64, (geom.loc.x + geom.size.w - 1) as f64);
333 new_pos.y = new_pos
334 .y
335 .clamp(geom.loc.y as f64, (geom.loc.y + geom.size.h - 1) as f64);
336 } else {
337 // The pointer was not on any output in the first place. Find one for it.
338 // Let's do the simple thing and just put it on the first output.
339 let output = self.niri.global_space.outputs().next().unwrap();
340 let geom = self.niri.global_space.output_geometry(output).unwrap();
341 new_pos = center(geom).to_f64();
342 }
343 }
344
345 let under = self.niri.surface_under_and_global_space(new_pos);
346
347 pointer.motion(
348 self,
349 under.clone(),
350 &MotionEvent {
351 location: new_pos,
352 serial,
353 time: event.time_msec(),
354 },
355 );
356
357 pointer.relative_motion(
358 self,
359 under,
360 &RelativeMotionEvent {
361 delta: event.delta(),
362 delta_unaccel: event.delta_unaccel(),
363 utime: event.time(),
364 },
365 );
366
367 pointer.frame(self);
368
369 // Redraw to update the cursor position.
370 // FIXME: redraw only outputs overlapping the cursor.
371 self.niri.queue_redraw_all();
372 }
373 InputEvent::PointerMotionAbsolute { event, .. } => {
374 let Some(output) = self.niri.global_space.outputs().next() else {
375 return;
376 };
377
378 let output_geo = self.niri.global_space.output_geometry(output).unwrap();
379
380 let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64();
381
382 let serial = SERIAL_COUNTER.next_serial();
383
384 let pointer = self.niri.seat.get_pointer().unwrap();
385
386 let under = self.niri.surface_under_and_global_space(pos);
387
388 pointer.motion(
389 self,
390 under,
391 &MotionEvent {
392 location: pos,
393 serial,
394 time: event.time_msec(),
395 },
396 );
397
398 pointer.frame(self);
399
400 // Redraw to update the cursor position.
401 // FIXME: redraw only outputs overlapping the cursor.
402 self.niri.queue_redraw_all();
403 }
404 InputEvent::PointerButton { event, .. } => {
405 let pointer = self.niri.seat.get_pointer().unwrap();
406
407 let serial = SERIAL_COUNTER.next_serial();
408
409 let button = event.button_code();
410
411 let button_state = event.state();
412
413 if ButtonState::Pressed == button_state && !pointer.is_grabbed() {
414 if let Some(window) = self.niri.window_under_cursor() {
415 let window = window.clone();
416 self.niri.monitor_set.activate_window(&window);
417 } else if let Some(output) = self.niri.output_under_cursor() {
418 self.niri.monitor_set.activate_output(&output);
419 }
420 };
421
422 pointer.button(
423 self,
424 &ButtonEvent {
425 button,
426 state: button_state,
427 serial,
428 time: event.time_msec(),
429 },
430 );
431 pointer.frame(self);
432 }
433 InputEvent::PointerAxis { event, .. } => {
434 let source = event.source();
435
436 let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| {
437 event.amount_discrete(Axis::Horizontal).unwrap_or(0.0) * 3.0
438 });
439 let vertical_amount = event
440 .amount(Axis::Vertical)
441 .unwrap_or_else(|| event.amount_discrete(Axis::Vertical).unwrap_or(0.0) * 3.0);
442 let horizontal_amount_discrete = event.amount_discrete(Axis::Horizontal);
443 let vertical_amount_discrete = event.amount_discrete(Axis::Vertical);
444
445 let mut frame = AxisFrame::new(event.time_msec()).source(source);
446 if horizontal_amount != 0.0 {
447 frame = frame.value(Axis::Horizontal, horizontal_amount);
448 if let Some(discrete) = horizontal_amount_discrete {
449 frame = frame.discrete(Axis::Horizontal, discrete as i32);
450 }
451 }
452 if vertical_amount != 0.0 {
453 frame = frame.value(Axis::Vertical, vertical_amount);
454 if let Some(discrete) = vertical_amount_discrete {
455 frame = frame.discrete(Axis::Vertical, discrete as i32);
456 }
457 }
458
459 if source == AxisSource::Finger {
460 if event.amount(Axis::Horizontal) == Some(0.0) {
461 frame = frame.stop(Axis::Horizontal);
462 }
463 if event.amount(Axis::Vertical) == Some(0.0) {
464 frame = frame.stop(Axis::Vertical);
465 }
466 }
467
468 let pointer = &self.niri.seat.get_pointer().unwrap();
469 pointer.axis(self, frame);
470 pointer.frame(self);
471 }
472 InputEvent::TabletToolAxis { event, .. } => {
473 // FIXME: allow mapping tablet to different outputs.
474 let Some(output) = self.niri.global_space.outputs().next() else {
475 return;
476 };
477
478 let output_geo = self.niri.global_space.output_geometry(output).unwrap();
479
480 let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64();
481
482 let serial = SERIAL_COUNTER.next_serial();
483
484 let pointer = self.niri.seat.get_pointer().unwrap();
485
486 let under = self.niri.surface_under_and_global_space(pos);
487
488 pointer.motion(
489 self,
490 under.clone(),
491 &MotionEvent {
492 location: pos,
493 serial,
494 time: event.time_msec(),
495 },
496 );
497 pointer.frame(self);
498
499 let tablet_seat = self.niri.seat.tablet_seat();
500 let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
501 let tool = tablet_seat.get_tool(&event.tool());
502 if let (Some(tablet), Some(tool)) = (tablet, tool) {
503 if event.pressure_has_changed() {
504 tool.pressure(event.pressure());
505 }
506 if event.distance_has_changed() {
507 tool.distance(event.distance());
508 }
509 if event.tilt_has_changed() {
510 tool.tilt(event.tilt());
511 }
512 if event.slider_has_changed() {
513 tool.slider_position(event.slider_position());
514 }
515 if event.rotation_has_changed() {
516 tool.rotation(event.rotation());
517 }
518 if event.wheel_has_changed() {
519 tool.wheel(event.wheel_delta(), event.wheel_delta_discrete());
520 }
521
522 tool.motion(
523 pos,
524 under,
525 &tablet,
526 SERIAL_COUNTER.next_serial(),
527 event.time_msec(),
528 );
529 }
530
531 // Redraw to update the cursor position.
532 // FIXME: redraw only outputs overlapping the cursor.
533 self.niri.queue_redraw_all();
534 }
535 InputEvent::TabletToolTip { event, .. } => {
536 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
537
538 if let Some(tool) = tool {
539 match event.tip_state() {
540 TabletToolTipState::Down => {
541 let serial = SERIAL_COUNTER.next_serial();
542 tool.tip_down(serial, event.time_msec());
543
544 let pointer = self.niri.seat.get_pointer().unwrap();
545 if !pointer.is_grabbed() {
546 if let Some(window) = self.niri.window_under_cursor() {
547 let window = window.clone();
548 self.niri.monitor_set.activate_window(&window);
549 } else if let Some(output) = self.niri.output_under_cursor() {
550 self.niri.monitor_set.activate_output(&output);
551 }
552 };
553 }
554 TabletToolTipState::Up => {
555 tool.tip_up(event.time_msec());
556 }
557 }
558 }
559 }
560 InputEvent::TabletToolProximity { event, .. } => {
561 // FIXME: allow mapping tablet to different outputs.
562 let Some(output) = self.niri.global_space.outputs().next() else {
563 return;
564 };
565
566 let output_geo = self.niri.global_space.output_geometry(output).unwrap();
567
568 let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64();
569
570 let serial = SERIAL_COUNTER.next_serial();
571
572 let pointer = self.niri.seat.get_pointer().unwrap();
573
574 let under = self.niri.surface_under_and_global_space(pos);
575
576 pointer.motion(
577 self,
578 under.clone(),
579 &MotionEvent {
580 location: pos,
581 serial,
582 time: event.time_msec(),
583 },
584 );
585 pointer.frame(self);
586
587 let tablet_seat = self.niri.seat.tablet_seat();
588 let tool = tablet_seat.add_tool::<Self>(&self.niri.display_handle, &event.tool());
589 let tablet = tablet_seat.get_tablet(&TabletDescriptor::from(&event.device()));
590 if let (Some(under), Some(tablet)) = (under, tablet) {
591 match event.state() {
592 ProximityState::In => tool.proximity_in(
593 pos,
594 under,
595 &tablet,
596 SERIAL_COUNTER.next_serial(),
597 event.time_msec(),
598 ),
599 ProximityState::Out => tool.proximity_out(event.time_msec()),
600 }
601 }
602 }
603 InputEvent::TabletToolButton { event, .. } => {
604 let tool = self.niri.seat.tablet_seat().get_tool(&event.tool());
605
606 if let Some(tool) = tool {
607 tool.button(
608 event.button(),
609 event.button_state(),
610 SERIAL_COUNTER.next_serial(),
611 event.time_msec(),
612 );
613 }
614 }
615 InputEvent::DeviceAdded { device } => {
616 if device.has_capability(DeviceCapability::TabletTool) {
617 self.niri.seat.tablet_seat().add_tablet::<Self>(
618 &self.niri.display_handle,
619 &TabletDescriptor::from(&device),
620 );
621 }
622 }
623 InputEvent::DeviceRemoved { device } => {
624 if device.has_capability(DeviceCapability::TabletTool) {
625 let tablet_seat = self.niri.seat.tablet_seat();
626
627 tablet_seat.remove_tablet(&TabletDescriptor::from(&device));
628
629 // If there are no tablets in seat we can remove all tools
630 if tablet_seat.count_tablets() == 0 {
631 tablet_seat.clear_tools();
632 }
633 }
634 }
635 InputEvent::GestureSwipeBegin { event } => {
636 let serial = SERIAL_COUNTER.next_serial();
637 let pointer = self.niri.seat.get_pointer().unwrap();
638 pointer.gesture_swipe_begin(
639 self,
640 &GestureSwipeBeginEvent {
641 serial,
642 time: event.time_msec(),
643 fingers: event.fingers(),
644 },
645 );
646 }
647 InputEvent::GestureSwipeUpdate { event } => {
648 let pointer = self.niri.seat.get_pointer().unwrap();
649 pointer.gesture_swipe_update(
650 self,
651 &GestureSwipeUpdateEvent {
652 time: event.time_msec(),
653 delta: event.delta(),
654 },
655 );
656 }
657 InputEvent::GestureSwipeEnd { event } => {
658 let serial = SERIAL_COUNTER.next_serial();
659 let pointer = self.niri.seat.get_pointer().unwrap();
660 pointer.gesture_swipe_end(
661 self,
662 &GestureSwipeEndEvent {
663 serial,
664 time: event.time_msec(),
665 cancelled: event.cancelled(),
666 },
667 );
668 }
669 InputEvent::GesturePinchBegin { event } => {
670 let serial = SERIAL_COUNTER.next_serial();
671 let pointer = self.niri.seat.get_pointer().unwrap();
672 pointer.gesture_pinch_begin(
673 self,
674 &GesturePinchBeginEvent {
675 serial,
676 time: event.time_msec(),
677 fingers: event.fingers(),
678 },
679 );
680 }
681 InputEvent::GesturePinchUpdate { event } => {
682 let pointer = self.niri.seat.get_pointer().unwrap();
683 pointer.gesture_pinch_update(
684 self,
685 &GesturePinchUpdateEvent {
686 time: event.time_msec(),
687 delta: event.delta(),
688 scale: event.scale(),
689 rotation: event.rotation(),
690 },
691 );
692 }
693 InputEvent::GesturePinchEnd { event } => {
694 let serial = SERIAL_COUNTER.next_serial();
695 let pointer = self.niri.seat.get_pointer().unwrap();
696 pointer.gesture_pinch_end(
697 self,
698 &GesturePinchEndEvent {
699 serial,
700 time: event.time_msec(),
701 cancelled: event.cancelled(),
702 },
703 );
704 }
705 InputEvent::GestureHoldBegin { event } => {
706 let serial = SERIAL_COUNTER.next_serial();
707 let pointer = self.niri.seat.get_pointer().unwrap();
708 pointer.gesture_hold_begin(
709 self,
710 &GestureHoldBeginEvent {
711 serial,
712 time: event.time_msec(),
713 fingers: event.fingers(),
714 },
715 );
716 }
717 InputEvent::GestureHoldEnd { event } => {
718 let serial = SERIAL_COUNTER.next_serial();
719 let pointer = self.niri.seat.get_pointer().unwrap();
720 pointer.gesture_hold_end(
721 self,
722 &GestureHoldEndEvent {
723 serial,
724 time: event.time_msec(),
725 cancelled: event.cancelled(),
726 },
727 );
728 }
729 InputEvent::TouchDown { .. } => (),
730 InputEvent::TouchMotion { .. } => (),
731 InputEvent::TouchUp { .. } => (),
732 InputEvent::TouchCancel { .. } => (),
733 InputEvent::TouchFrame { .. } => (),
734 InputEvent::Special(_) => (),
735 }
736 }
737
738 pub fn process_libinput_event(&mut self, event: &mut InputEvent<LibinputInputBackend>) {
739 if let InputEvent::DeviceAdded { device } = event {
740 // According to Mutter code, this setting is specific to touchpads.
741 let is_touchpad = device.config_tap_finger_count() > 0;
742 if is_touchpad {
743 let c = &self.niri.config.borrow().input.touchpad;
744 let _ = device.config_tap_set_enabled(c.tap);
745 let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
746 let _ = device.config_accel_set_speed(c.accel_speed);
747 }
748 }
749 }
750}