Skip to content

Commit

Permalink
x11: Ignore key repetition
Browse files Browse the repository at this point in the history
This backend should avoid producing key press events for key repeat,
the libinput backend.

You can see in `wev` that this prevents repeated key press events on
held keys that don't happen with libinput.
  • Loading branch information
ids1024 committed Sep 16, 2024
1 parent c9791e5 commit 05fb5f1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/backend/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ use x11rb::{
protocol::{
self as x11,
dri3::ConnectionExt as _,
xinput,
xproto::{ColormapAlloc, ConnectionExt, CreateWindowAux, VisualClass, WindowClass, WindowWrapper},
ErrorKind,
},
Expand Down Expand Up @@ -792,6 +793,10 @@ impl X11Inner {
}

x11::Event::XinputKeyPress(key_press) => {
if key_press.flags.contains(xinput::KeyEventFlags::KEY_REPEAT) {
return;
}

if let Some(window) = X11Inner::window_ref_from_id(inner, &key_press.event) {
// Do not hold the lock.
let count = { inner.lock().unwrap().key_counter.fetch_add(1, Ordering::SeqCst) + 1 };
Expand Down

0 comments on commit 05fb5f1

Please sign in to comment.