Struct smithay::wayland::seat::KeyboardHandle
source · pub struct KeyboardHandle { /* private fields */ }
Expand description
An handle to a keyboard handler
It can be cloned and all clones manipulate the same internal state. Clones can also be sent across threads.
This handle gives you 2 main ways to interact with the keyboard handling:
- set the current focus for this keyboard: designing the surface that will receive the key inputs
using the
KeyboardHandle::set_focus
method. - process key inputs from the input backend, allowing them to be caught at the compositor-level
or forwarded to the client. See the documentation of the
KeyboardHandle::input
method for details.
Implementations§
source§impl KeyboardHandle
impl KeyboardHandle
sourcepub fn input<F>(
&self,
keycode: u32,
state: KeyState,
serial: u32,
time: u32,
filter: F
)where
F: FnOnce(&ModifiersState, Keysym) -> bool,
pub fn input<F>(
&self,
keycode: u32,
state: KeyState,
serial: u32,
time: u32,
filter: F
)where
F: FnOnce(&ModifiersState, Keysym) -> bool,
Handle a keystroke
All keystrokes from the input backend should be fed in order to this method of the keyboard handler. It will internally track the state of the keymap.
The filter
argument is expected to be a closure which will peek at the generated input
as interpreted by the keymap before it is forwarded to the focused client. If this closure
returns false, the input will not be sent to the client. This mechanism can be used to
implement compositor-level key bindings for example.
The module wayland::seat::keysyms
exposes definitions of all possible keysyms
to be compared against. This includes non-character keysyms, such as XF86 special keys.
sourcepub fn set_focus(&self, focus: Option<&Resource<WlSurface>>, serial: u32)
pub fn set_focus(&self, focus: Option<&Resource<WlSurface>>, serial: u32)
Set the current focus of this keyboard
If the new focus is different from the previous one, any previous focus
will be sent a wl_keyboard::Event::Leave
event, and if the new focus is not None
,
a wl_keyboard::Event::Enter
event will be sent.
sourcepub fn has_focus(&self, client: &Client) -> bool
pub fn has_focus(&self, client: &Client) -> bool
Check if given client currently has keyboard focus
sourcepub fn change_repeat_info(&self, rate: i32, delay: i32)
pub fn change_repeat_info(&self, rate: i32, delay: i32)
Change the repeat info configured for this keyboard
Trait Implementations§
source§impl Clone for KeyboardHandle
impl Clone for KeyboardHandle
source§fn clone(&self) -> KeyboardHandle
fn clone(&self) -> KeyboardHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more