Add barebones tablet support
Browse files at this commit7c96c3ea63691fb9dfb24edfb4dda3d402c7621aParent: 0da94d71 changed file +43 -1
- src/input.rs +43 -1
src/input.rsmodified+43 -1
| @@ -3,6 +3,7 @@ use std::process::Command; | |||
| 3 | use smithay::backend::input::{ | 3 | use smithay::backend::input::{ |
| 4 | AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, | 4 | AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event, InputBackend, InputEvent, |
| 5 | KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, | 5 | KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionEvent, |
| 6 | + TabletToolEvent, TabletToolTipEvent, TabletToolTipState, | ||
| 6 | }; | 7 | }; |
| 7 | use smithay::input::keyboard::{keysyms, FilterResult, KeysymHandle, ModifiersState}; | 8 | use smithay::input::keyboard::{keysyms, FilterResult, KeysymHandle, ModifiersState}; |
| 8 | use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent}; | 9 | use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent}; |
| @@ -281,7 +282,6 @@ impl Niri { | |||
| 281 | self.queue_redraw_all(); | 282 | self.queue_redraw_all(); |
| 282 | } | 283 | } |
| 283 | InputEvent::PointerMotionAbsolute { event, .. } => { | 284 | InputEvent::PointerMotionAbsolute { event, .. } => { |
| 284 | - // FIXME: allow mapping tablet to different outputs. | ||
| 285 | let output = self.global_space.outputs().next().unwrap(); | 285 | let output = self.global_space.outputs().next().unwrap(); |
| 286 | 286 | ||
| 287 | let output_geo = self.global_space.output_geometry(output).unwrap(); | 287 | let output_geo = self.global_space.output_geometry(output).unwrap(); |
| @@ -369,6 +369,48 @@ impl Niri { | |||
| 369 | 369 | ||
| 370 | self.seat.get_pointer().unwrap().axis(self, frame); | 370 | self.seat.get_pointer().unwrap().axis(self, frame); |
| 371 | } | 371 | } |
| 372 | + // FIXME: tablet_tool protocol | ||
| 373 | + InputEvent::TabletToolAxis { event, .. } => { | ||
| 374 | + // FIXME: allow mapping tablet to different outputs. | ||
| 375 | + let output = self.global_space.outputs().next().unwrap(); | ||
| 376 | + | ||
| 377 | + let output_geo = self.global_space.output_geometry(output).unwrap(); | ||
| 378 | + | ||
| 379 | + let pos = event.position_transformed(output_geo.size) + output_geo.loc.to_f64(); | ||
| 380 | + | ||
| 381 | + let serial = SERIAL_COUNTER.next_serial(); | ||
| 382 | + | ||
| 383 | + let pointer = self.seat.get_pointer().unwrap(); | ||
| 384 | + | ||
| 385 | + let under = self.surface_under_and_global_space(pos); | ||
| 386 | + | ||
| 387 | + pointer.motion( | ||
| 388 | + self, | ||
| 389 | + under, | ||
| 390 | + &MotionEvent { | ||
| 391 | + location: pos, | ||
| 392 | + serial, | ||
| 393 | + time: event.time_msec(), | ||
| 394 | + }, | ||
| 395 | + ); | ||
| 396 | + | ||
| 397 | + // Redraw to update the cursor position. | ||
| 398 | + // FIXME: redraw only outputs overlapping the cursor. | ||
| 399 | + self.queue_redraw_all(); | ||
| 400 | + } | ||
| 401 | + InputEvent::TabletToolTip { event, .. } => { | ||
| 402 | + let pointer = self.seat.get_pointer().unwrap(); | ||
| 403 | + | ||
| 404 | + if event.tip_state() == TabletToolTipState::Down && !pointer.is_grabbed() { | ||
| 405 | + if let Some(window) = self.window_under_cursor() { | ||
| 406 | + let window = window.clone(); | ||
| 407 | + self.monitor_set.activate_window(&window); | ||
| 408 | + } else { | ||
| 409 | + let output = self.output_under_cursor().unwrap(); | ||
| 410 | + self.monitor_set.activate_output(&output); | ||
| 411 | + } | ||
| 412 | + }; | ||
| 413 | + } | ||
| 372 | _ => {} | 414 | _ => {} |
| 373 | } | 415 | } |
| 374 | } | 416 | } |