diff --git a/examples/data_device.rs b/examples/data_device.rs index 99c32572b..154f636b9 100644 --- a/examples/data_device.rs +++ b/examples/data_device.rs @@ -448,6 +448,16 @@ impl KeyboardHandler for DataDeviceWindow { }; } + fn repeat_key( + &mut self, + _conn: &Connection, + _qh: &QueueHandle, + _keyboard: &wl_keyboard::WlKeyboard, + _serial: u32, + _event: KeyEvent, + ) { + } + fn release_key( &mut self, _: &Connection, diff --git a/examples/generic_simple_window.rs b/examples/generic_simple_window.rs index cd257bc99..d06a1d674 100644 --- a/examples/generic_simple_window.rs +++ b/examples/generic_simple_window.rs @@ -331,6 +331,17 @@ impl KeyboardHandler for SimpleWindow { println!("Key press: {event:?}"); } + fn repeat_key( + &mut self, + _: &Connection, + _: &QueueHandle, + _: &wl_keyboard::WlKeyboard, + _: u32, + event: KeyEvent, + ) { + println!("Key repeat: {event:?}"); + } + fn release_key( &mut self, _: &Connection, diff --git a/examples/simple_layer.rs b/examples/simple_layer.rs index 7bc64d580..8b5e6d228 100644 --- a/examples/simple_layer.rs +++ b/examples/simple_layer.rs @@ -321,6 +321,17 @@ impl KeyboardHandler for SimpleLayer { } } + fn repeat_key( + &mut self, + _conn: &Connection, + _qh: &QueueHandle, + _keyboard: &wl_keyboard::WlKeyboard, + _serial: u32, + event: KeyEvent, + ) { + println!("Key repeat: {event:?}"); + } + fn release_key( &mut self, _: &Connection, diff --git a/examples/simple_window.rs b/examples/simple_window.rs index 1986ef333..97aaba556 100644 --- a/examples/simple_window.rs +++ b/examples/simple_window.rs @@ -370,6 +370,17 @@ impl KeyboardHandler for SimpleWindow { println!("Key press: {event:?}"); } + fn repeat_key( + &mut self, + _: &Connection, + _: &QueueHandle, + _: &wl_keyboard::WlKeyboard, + _: u32, + event: KeyEvent, + ) { + println!("Key repeat: {event:?}"); + } + fn release_key( &mut self, _: &Connection, diff --git a/examples/themed_window.rs b/examples/themed_window.rs index 3a59f3aa5..10d6fd405 100644 --- a/examples/themed_window.rs +++ b/examples/themed_window.rs @@ -466,6 +466,16 @@ impl KeyboardHandler for SimpleWindow { } } + fn repeat_key( + &mut self, + _conn: &Connection, + _qh: &QueueHandle, + _keyboard: &wl_keyboard::WlKeyboard, + _serial: u32, + _event: KeyEvent, + ) { + } + fn release_key( &mut self, _: &Connection, diff --git a/src/seat/keyboard/mod.rs b/src/seat/keyboard/mod.rs index 3cb694a61..2c6384ace 100644 --- a/src/seat/keyboard/mod.rs +++ b/src/seat/keyboard/mod.rs @@ -52,6 +52,9 @@ impl SeatState { /// Typically the compositor will provide a keymap, but you may specify your own keymap using the `rmlvo` /// field. /// + /// This keyboard only sends key repeats if they are issued by the compositor. + /// See wl_keyboard version 10. + /// /// ## Errors /// /// This will return [`SeatError::UnsupportedCapability`] if the seat does not support a keyboard. @@ -165,6 +168,18 @@ pub trait KeyboardHandler: Sized { event: KeyEvent, ); + /// A key has been previously pressed and is now repeating. + /// + /// This is only called on supporting compositors. + fn repeat_key( + &mut self, + conn: &Connection, + qh: &QueueHandle, + keyboard: &wl_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. @@ -683,6 +698,10 @@ where data.release_key(conn, qh, keyboard, serial, event); } + wl_keyboard::KeyState::Repeated => { + data.repeat_key(conn, qh, keyboard, serial, event); + } + wl_keyboard::KeyState::Pressed => { data.press_key(conn, qh, keyboard, serial, event.clone()); #[cfg(feature = "calloop")] diff --git a/src/seat/mod.rs b/src/seat/mod.rs index 137250ca3..6bb6d0eb5 100644 --- a/src/seat/mod.rs +++ b/src/seat/mod.rs @@ -92,7 +92,7 @@ impl SeatState { .unwrap_or(CursorShapeManagerState::NotPresent); ( - crate::registry::bind_all(global_list.registry(), globals, qh, 1..=9, |id| { + crate::registry::bind_all(global_list.registry(), globals, qh, 1..=10, |id| { SeatData { has_keyboard: Arc::new(AtomicBool::new(false)), has_pointer: Arc::new(AtomicBool::new(false)),