From 0584dd2f1e82417bdabcc0d8cb20fddc2e8cc5e7 Mon Sep 17 00:00:00 2001 From: sodiboo <37938646+sodiboo@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:26:42 +0100 Subject: 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 --- src/input/backend_ext.rs | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/input/backend_ext.rs (limited to 'src/input/backend_ext.rs') 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 { + type NiriDevice: NiriInputDevice; +} +impl 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; +} + +impl NiriInputDevice for libinput::Device { + fn output(&self, _state: &State) -> Option { + // FIXME: Allow specifying the output per-device? + None + } +} + +impl NiriInputDevice for WinitVirtualDevice { + fn output(&self, _state: &State) -> Option { + // 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 { + self.output().cloned() + } +} -- cgit