Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ impl KeyboardHandler for DataDeviceWindow {
};
}

fn repeat_key(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wl_keyboard::WlKeyboard,
_serial: u32,
_event: KeyEvent,
) {
}

fn release_key(
&mut self,
_: &Connection,
Expand Down
11 changes: 11 additions & 0 deletions examples/generic_simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,17 @@ impl<T: Test + 'static> KeyboardHandler for SimpleWindow<T> {
println!("Key press: {event:?}");
}

fn repeat_key(
&mut self,
_: &Connection,
_: &QueueHandle<Self>,
_: &wl_keyboard::WlKeyboard,
_: u32,
event: KeyEvent,
) {
println!("Key repeat: {event:?}");
}

fn release_key(
&mut self,
_: &Connection,
Expand Down
11 changes: 11 additions & 0 deletions examples/simple_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,17 @@ impl KeyboardHandler for SimpleLayer {
}
}

fn repeat_key(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wl_keyboard::WlKeyboard,
_serial: u32,
event: KeyEvent,
) {
println!("Key repeat: {event:?}");
}

fn release_key(
&mut self,
_: &Connection,
Expand Down
11 changes: 11 additions & 0 deletions examples/simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,17 @@ impl KeyboardHandler for SimpleWindow {
println!("Key press: {event:?}");
}

fn repeat_key(
&mut self,
_: &Connection,
_: &QueueHandle<Self>,
_: &wl_keyboard::WlKeyboard,
_: u32,
event: KeyEvent,
) {
println!("Key repeat: {event:?}");
}

fn release_key(
&mut self,
_: &Connection,
Expand Down
10 changes: 10 additions & 0 deletions examples/themed_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,16 @@ impl KeyboardHandler for SimpleWindow {
}
}

fn repeat_key(
&mut self,
_conn: &Connection,
_qh: &QueueHandle<Self>,
_keyboard: &wl_keyboard::WlKeyboard,
_serial: u32,
_event: KeyEvent,
) {
}

fn release_key(
&mut self,
_: &Connection,
Expand Down
19 changes: 19 additions & 0 deletions src/seat/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Self>,
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.
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion src/seat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
Loading