Skip to content

Commit 2d1a037

Browse files
authored
macos: fix duplicated key release event (#340)
1 parent 057f6e2 commit 2d1a037

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

input-emulation/src/macos.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ impl MacOSEmulation {
104104
// there can only be one repeating key and it's
105105
// always the last to be pressed
106106
self.cancel_repeat_task().await;
107+
// initial key event
108+
key_event(self.event_source.clone(), key, 1, self.modifier_state.get());
109+
// repeat task
107110
let event_source = self.event_source.clone();
108111
let notify = self.notify_repeat_task.clone();
109112
let modifiers = self.modifier_state.clone();
@@ -239,6 +242,7 @@ impl Emulation for MacOSEmulation {
239242
event: Event,
240243
_handle: EmulationHandle,
241244
) -> Result<(), EmulationError> {
245+
log::trace!("{event:?}");
242246
match event {
243247
Event::Pointer(pointer_event) => match pointer_event {
244248
PointerEvent::Motion { time: _, dx, dy } => {
@@ -405,18 +409,12 @@ impl Emulation for MacOSEmulation {
405409
return Ok(());
406410
}
407411
};
412+
update_modifiers(&self.modifier_state, key, state);
408413
match state {
409414
// pressed
410415
1 => self.spawn_repeat_task(code).await,
411416
_ => self.cancel_repeat_task().await,
412417
}
413-
update_modifiers(&self.modifier_state, key, state);
414-
key_event(
415-
self.event_source.clone(),
416-
code,
417-
state,
418-
self.modifier_state.get(),
419-
);
420418
}
421419
KeyboardEvent::Modifiers {
422420
depressed,

0 commit comments

Comments
 (0)