From eb097012b3431c08e9edc879f44fc46863db7425 Mon Sep 17 00:00:00 2001 From: fufesou Date: Thu, 7 May 2026 13:29:34 +0800 Subject: [PATCH] feat(keyboard): shortcuts, release keys before shortcut callback Signed-off-by: fufesou --- src/keyboard.rs | 4 ++-- src/keyboard/shortcuts.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/keyboard.rs b/src/keyboard.rs index ec089b4bd..ede3d4a70 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -344,7 +344,7 @@ pub mod client { // `flutter::get_cur_session_id()` — the rdev grab loop is process-wide // and has no per-event session context to thread. #[cfg(feature = "flutter")] - if crate::keyboard::shortcuts::try_dispatch(None, event) { + if crate::keyboard::shortcuts::try_dispatch(None, event, keyboard_mode) { return; } @@ -371,7 +371,7 @@ pub mod client { // through, so dispatch targets the exact tab the keystroke originated // from — no dependency on the global focus tracker. #[cfg(feature = "flutter")] - if crate::keyboard::shortcuts::try_dispatch(Some(&session_id), event) { + if crate::keyboard::shortcuts::try_dispatch(Some(&session_id), event, keyboard_mode) { return; } #[cfg(not(feature = "flutter"))] diff --git a/src/keyboard/shortcuts.rs b/src/keyboard/shortcuts.rs index 1677062a1..b0449cb5c 100644 --- a/src/keyboard/shortcuts.rs +++ b/src/keyboard/shortcuts.rs @@ -360,7 +360,11 @@ pub fn match_event(event: &rdev::Event) -> Option { /// which Flutter session id the keystroke was meant for, so route to the /// globally-current session via `flutter::get_cur_session_id()`. #[cfg(feature = "flutter")] -pub fn try_dispatch(session_id: Option<&hbb_common::SessionID>, event: &rdev::Event) -> bool { +pub fn try_dispatch( + session_id: Option<&hbb_common::SessionID>, + event: &rdev::Event, + keyboard_mode: &str, +) -> bool { let Some(action_id) = match_event(event) else { return false; }; @@ -372,6 +376,7 @@ pub fn try_dispatch(session_id: Option<&hbb_common::SessionID>, event: &rdev::Ev &resolved } }; + crate::keyboard::release_remote_keys(keyboard_mode); crate::flutter::push_session_event(sid, "shortcut_triggered", vec![("action", &action_id)]); true }