pub trait KeyboardHandler: Sized {
// Required methods
fn enter(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
surface: &WlSurface,
serial: u32,
raw: &[u32],
keysyms: &[Keysym],
);
fn leave(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
surface: &WlSurface,
serial: u32,
);
fn press_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
event: KeyEvent,
);
fn release_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
event: KeyEvent,
);
fn update_modifiers(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
modifiers: Modifiers,
layout: u32,
);
// Provided methods
fn update_repeat_info(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &WlKeyboard,
_info: RepeatInfo,
) { ... }
fn update_keymap(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &WlKeyboard,
_keymap: Keymap<'_>,
) { ... }
}
xkbcommon
only.Expand description
Handler trait for keyboard input.
The functions defined in this trait are called as keyboard events are received from the compositor.
Required Methods§
Sourcefn enter(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
surface: &WlSurface,
serial: u32,
raw: &[u32],
keysyms: &[Keysym],
)
fn enter( &mut self, conn: &Connection, qh: &QueueHandle<Self>, keyboard: &WlKeyboard, surface: &WlSurface, serial: u32, raw: &[u32], keysyms: &[Keysym], )
The keyboard has entered a surface.
When called, you may assume the specified surface has keyboard focus.
When a keyboard enters a surface, the raw
and keysym
fields indicate which keys are currently
pressed.
Sourcefn leave(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
surface: &WlSurface,
serial: u32,
)
fn leave( &mut self, conn: &Connection, qh: &QueueHandle<Self>, keyboard: &WlKeyboard, surface: &WlSurface, serial: u32, )
The keyboard has left a surface.
When called, keyboard focus leaves the specified surface.
All currently held down keys are released when this event occurs.
Sourcefn press_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
event: KeyEvent,
)
fn press_key( &mut self, conn: &Connection, qh: &QueueHandle<Self>, keyboard: &WlKeyboard, serial: u32, event: KeyEvent, )
A key has been pressed on the keyboard.
The key will repeat if there is no other press event afterwards or the key is released.
Sourcefn release_key(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
event: KeyEvent,
)
fn release_key( &mut self, conn: &Connection, qh: &QueueHandle<Self>, keyboard: &WlKeyboard, serial: u32, event: KeyEvent, )
A key has been released.
This stops the key from being repeated if the key is the last key which was pressed.
Sourcefn update_modifiers(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
keyboard: &WlKeyboard,
serial: u32,
modifiers: Modifiers,
layout: u32,
)
fn update_modifiers( &mut self, conn: &Connection, qh: &QueueHandle<Self>, keyboard: &WlKeyboard, serial: u32, modifiers: Modifiers, layout: u32, )
Keyboard modifiers have been updated.
This happens when one of the modifier keys, such as “Shift”, “Control” or “Alt” is pressed or released.
Provided Methods§
Sourcefn update_repeat_info(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &WlKeyboard,
_info: RepeatInfo,
)
fn update_repeat_info( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _info: RepeatInfo, )
The keyboard has updated the rate and delay between repeating key inputs.
This function does nothing by default but is provided if a repeat mechanism outside of calloop is
used.
Sourcefn update_keymap(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &WlKeyboard,
_keymap: Keymap<'_>,
)
fn update_keymap( &mut self, _conn: &Connection, _qh: &QueueHandle<Self>, _keyboard: &WlKeyboard, _keymap: Keymap<'_>, )
Keyboard keymap has been updated.
keymap.as_string()
can be used get the keymap as a string. It cannot be exposed directly
as an xkbcommon::xkb::Keymap
due to the fact xkbcommon uses non-thread-safe reference
counting. But can be used to create an independent Keymap
.
This is called after the default handler for keymap changes and does nothing by default.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.