Skip to content

Commit

Permalink
ignore double press / release events (#71)
Browse files Browse the repository at this point in the history
This should fix most of the remaining issues with stuck keys in KDE
  • Loading branch information
feschber authored Jan 12, 2024
1 parent 767fc8b commit d54b3a0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ impl Server {
}
}
State::Receiving => {
let mut ignore_event = false;
if let Event::Keyboard(KeyboardEvent::Key {
time: _,
key,
Expand All @@ -735,15 +736,21 @@ impl Server {
return;
};
if state == 0 {
client_state.pressed_keys.remove(&key);
// ignore release event if key not pressed
ignore_event = !client_state.pressed_keys.remove(&key);
} else {
client_state.pressed_keys.insert(key);
// ignore press event if key not released
ignore_event = !client_state.pressed_keys.insert(key);
let _ = timer_tx.try_send(());
}
}
// consume event
consumer.consume(event, handle).await;
log::trace!("{event:?} => consumer");
// ignore double press / release events to
// workaround buggy rdp backend.
if !ignore_event {
// consume event
consumer.consume(event, handle).await;
log::trace!("{event:?} => consumer");
}
}
State::AwaitingLeave => {
// we just entered the deadzone of a client, so
Expand Down

0 comments on commit d54b3a0

Please sign in to comment.