diff --git a/src/platform/mod.rs b/src/platform/mod.rs index c30083155..04a3feeee 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -35,7 +35,8 @@ pub fn is_xfce() -> bool { pub fn breakdown_callback() { #[cfg(target_os = "linux")] - crate::input_service::clear_remapped_keycode() + crate::input_service::clear_remapped_keycode(); + crate::input_service::release_modifiers(); } // Android diff --git a/src/server/connection.rs b/src/server/connection.rs index ed7476284..6b0cbefc3 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -618,6 +618,7 @@ impl Connection { } #[cfg(target_os = "linux")] clear_remapped_keycode(); + release_modifiers(); log::info!("Input thread exited"); } diff --git a/src/server/input_service.rs b/src/server/input_service.rs index b362c8d30..49fd1e188 100644 --- a/src/server/input_service.rs +++ b/src/server/input_service.rs @@ -551,6 +551,24 @@ fn record_key_to_key(record_key: u64) -> Option { } } +pub fn release_modifiers() { + let mut en = ENIGO.lock().unwrap(); + for modifier in [ + Key::Shift, + Key::Control, + Key::Alt, + Key::Meta, + Key::RightShift, + Key::RightControl, + Key::RightAlt, + Key::RWin, + ] { + if get_modifier_state(modifier, &mut en) { + en.key_up(modifier); + } + } +} + #[inline] fn release_record_key(record_key: KeysDown) { let func = move || match record_key {