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