input: drive key repeat off a calloop timer

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ic249e3ed4742ad5bc3c12eade720a7f26a6a6964
This commit is contained in:
raf 2026-06-24 14:35:40 +03:00
commit ba8f8d7144
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -431,7 +431,17 @@ impl SeatHandler for App {
capability: Capability, capability: Capability,
) { ) {
if capability == Capability::Keyboard && self.keyboard.is_none() { if capability == Capability::Keyboard && self.keyboard.is_none() {
match self.seat_state.get_keyboard(qh, &seat, None) { // get_keyboard_with_repeat drives key repeat off a calloop timer and
// delivers each repeat through the callback.
let loop_handle = self.loop_handle.clone();
let keyboard = self.seat_state.get_keyboard_with_repeat(
qh,
&seat,
None,
loop_handle,
Box::new(|app: &mut App, _kbd, event| app.send_key(&event)),
);
match keyboard {
Ok(keyboard) => self.keyboard = Some(keyboard), Ok(keyboard) => self.keyboard = Some(keyboard),
Err(err) => tracing::warn!("get keyboard: {err}"), Err(err) => tracing::warn!("get keyboard: {err}"),
} }
@ -499,9 +509,10 @@ impl KeyboardHandler for App {
_: &QueueHandle<Self>, _: &QueueHandle<Self>,
_: &wl_keyboard::WlKeyboard, _: &wl_keyboard::WlKeyboard,
_: u32, _: u32,
event: KeyEvent, _: KeyEvent,
) { ) {
self.send_key(&event); // Repeats are delivered through the get_keyboard_with_repeat callback;
// this non-calloop hook is unused.
} }
fn release_key( fn release_key(