Trait smithay_client_toolkit::seat::keyboard::KeyboardHandler
source · 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<'_>,
) { ... }
}
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.