Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux_wayland: do not send repeated keys events when focus is lost from the window #516

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
7 changes: 7 additions & 0 deletions src/native/linux_wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
}

enum WaylandEvent {
KeyboardLeave,
KeyboardKey(u32, bool),
PointerMotion(f32, f32),
PointerButton(MouseButton, bool),
Expand Down Expand Up @@ -184,16 +185,19 @@
_surface: *mut wl_surface,
_keys: *mut wl_array,
) {
// We can capture held keys when window is refocused.
// Ignore this for now.
}
unsafe extern "C" fn keyboard_handle_leave(
_data: *mut ::core::ffi::c_void,
_wl_keyboard: *mut wl_keyboard,
_serial: u32,
_surface: *mut wl_surface,
) {
EVENTS.push(WaylandEvent::KeyboardLeave);
}
unsafe extern "C" fn keyboard_handle_key(
data: *mut ::core::ffi::c_void,

Check warning on line 200 in src/native/linux_wayland.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, aarch64-unknown-linux-gnu)

unused variable: `data`

Check warning on line 200 in src/native/linux_wayland.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, armv7-unknown-linux-gnueabihf)

unused variable: `data`

Check warning on line 200 in src/native/linux_wayland.rs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, x86_64-unknown-linux-gnu)

unused variable: `data`
_wl_keyboard: *mut wl_keyboard,
_serial: u32,
_time: u32,
Expand Down Expand Up @@ -802,6 +806,9 @@

for event in EVENTS.drain(..) {
match event {
WaylandEvent::KeyboardLeave => {
repeated_keys.clear();
}
WaylandEvent::KeyboardKey(key, state) => {
// https://wayland-book.com/seat/keyboard.html
// To translate this to an XKB scancode, you must add 8 to the evdev scancode.
Expand Down
Loading