| 1 | use ::input as libinput; |
| 2 | use smithay::backend::input; |
| 3 | use smithay::backend::winit::WinitVirtualDevice; |
| 4 | use smithay::output::Output; |
| 5 | use smithay::wayland::virtual_keyboard::VirtualKeyboardDevice; |
| 6 | use smithay::wayland::virtual_pointer::VirtualPointerDevice; |
| 7 | |
| 8 | use crate::niri::State; |
| 9 | |
| 10 | pub trait NiriInputBackend: input::InputBackend<Device = Self::NiriDevice> { |
| 11 | type NiriDevice: NiriInputDevice; |
| 12 | } |
| 13 | impl<T: input::InputBackend> NiriInputBackend for T |
| 14 | where |
| 15 | Self::Device: NiriInputDevice, |
| 16 | { |
| 17 | type NiriDevice = Self::Device; |
| 18 | } |
| 19 | |
| 20 | pub trait NiriInputDevice: input::Device { |
| 21 | |
| 22 | |
| 23 | |
| 24 | fn output(&self, state: &State) -> Option<Output>; |
| 25 | } |
| 26 | |
| 27 | impl NiriInputDevice for libinput::Device { |
| 28 | fn output(&self, _state: &State) -> Option<Output> { |
| 29 | |
| 30 | None |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | impl NiriInputDevice for WinitVirtualDevice { |
| 35 | fn output(&self, _state: &State) -> Option<Output> { |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | None |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | impl NiriInputDevice for VirtualPointerDevice { |
| 49 | fn output(&self, _: &State) -> Option<Output> { |
| 50 | self.output() |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | impl NiriInputDevice for VirtualKeyboardDevice { |
| 55 | fn output(&self, _: &State) -> Option<Output> { |
| 56 | None |
| 57 | } |
| 58 | } |