diff options
| author | sodiboo <37938646+sodiboo@users.noreply.github.com> | 2025-01-18 15:26:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-18 17:26:42 +0300 |
| commit | 0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7 (patch) | |
| tree | 503168062d4b15245bdb1fdc940a7b3d748afa07 /src/input/backend_ext.rs | |
| parent | bd559a26602874f4104e342e2ce02317ae1ae605 (diff) | |
| download | niri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.tar.gz niri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.tar.bz2 niri-0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7.zip | |
implement `keyboard-shortcuts-inhibit` and `wlr-virtual-pointer` (#630)
* stub keyboard-shortcuts-inhibit and virtual-pointer impls
* implement keyboard-shortcuts-inhibit
* implement virtual-pointer
* deal with supressed key release edge-case; add allow-inhibiting property
* add toggle-keyboard-shortcuts-inhibit bind
* add InputBackend extensions; use Device::output() for absolute pos events
* add a `State` parameter to the backend exts and better document future intent
* Add some tests for is_inhibiting_shortcuts
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'src/input/backend_ext.rs')
| -rw-r--r-- | src/input/backend_ext.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/input/backend_ext.rs b/src/input/backend_ext.rs new file mode 100644 index 00000000..99f4a904 --- /dev/null +++ b/src/input/backend_ext.rs @@ -0,0 +1,51 @@ +use ::input as libinput; +use smithay::backend::input; +use smithay::backend::winit::WinitVirtualDevice; +use smithay::output::Output; + +use crate::niri::State; +use crate::protocols::virtual_pointer::VirtualPointer; + +pub trait NiriInputBackend: input::InputBackend<Device = Self::NiriDevice> { + type NiriDevice: NiriInputDevice; +} +impl<T: input::InputBackend> NiriInputBackend for T +where + Self::Device: NiriInputDevice, +{ + type NiriDevice = Self::Device; +} + +pub trait NiriInputDevice: input::Device { + // FIXME: this should maybe be per-event, not per-device, + // but it's not clear that this matters in practice? + // it might be more obvious once we implement it for libinput + fn output(&self, state: &State) -> Option<Output>; +} + +impl NiriInputDevice for libinput::Device { + fn output(&self, _state: &State) -> Option<Output> { + // FIXME: Allow specifying the output per-device? + None + } +} + +impl NiriInputDevice for WinitVirtualDevice { + fn output(&self, _state: &State) -> Option<Output> { + // FIXME: we should be returning the single output that the winit backend creates, + // but for now, that will cause issues because the output is normally upside down, + // so we apply Transform::Flipped180 to it and that would also cause + // the cursor position to be flipped, which is not what we want. + // + // instead, we just return None and rely on the fact that it has only one output. + // doing so causes the cursor to be placed in *global* output coordinates, + // which are not flipped, and happen to be what we want. + None + } +} + +impl NiriInputDevice for VirtualPointer { + fn output(&self, _: &State) -> Option<Output> { + self.output().cloned() + } +} |
