wl_keyboard: don't send key-up events for keys that are not logically down
This commit is contained in:
parent
abaeed4c01
commit
53c38bdd68
9 changed files with 68 additions and 27 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use {
|
||||
crate::{
|
||||
backend::KeyState,
|
||||
client::{Client, ClientError},
|
||||
ifs::wl_seat::{text_input::zwp_input_method_v2::ZwpInputMethodV2, wl_keyboard},
|
||||
keyboard::{KeyboardState, KeyboardStateId},
|
||||
|
|
@ -48,7 +49,7 @@ impl ZwpInputMethodKeyboardGrabV2 {
|
|||
self.kb_state_id.set(kb_state.id);
|
||||
}
|
||||
|
||||
pub fn on_key(&self, time_usec: u64, key: u32, state: u32, kb_state: &KeyboardState) {
|
||||
pub fn on_key(&self, time_usec: u64, key: u32, state: KeyState, kb_state: &KeyboardState) {
|
||||
let serial = self.client.next_serial();
|
||||
if self.kb_state_id.get() != kb_state.id {
|
||||
self.update_state(serial, kb_state);
|
||||
|
|
@ -56,13 +57,16 @@ impl ZwpInputMethodKeyboardGrabV2 {
|
|||
self.send_key(serial, time_usec, key, state);
|
||||
}
|
||||
|
||||
fn send_key(&self, serial: u64, time_usec: u64, key: u32, state: u32) {
|
||||
fn send_key(&self, serial: u64, time_usec: u64, key: u32, state: KeyState) {
|
||||
self.client.event(Key {
|
||||
self_id: self.id,
|
||||
serial: serial as _,
|
||||
time: (time_usec / 1000) as _,
|
||||
key,
|
||||
state,
|
||||
state: match state {
|
||||
KeyState::Released => wl_keyboard::RELEASED,
|
||||
KeyState::Pressed => wl_keyboard::PRESSED,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue