diff --git a/src/lang.rs b/src/lang.rs index 1f5a24e82..1a903352f 100644 --- a/src/lang.rs +++ b/src/lang.rs @@ -13,7 +13,7 @@ mod eo; #[cfg(not(any(target_os = "android", target_os = "ios")))] pub fn translate(name: String) -> String { let locale = sys_locale::get_locale().unwrap_or_default().to_lowercase(); - log::debug!("The current locale is {}", locale); + log::trace!("The current locale is {}", locale); translate_locale(name, &locale) } diff --git a/src/server/input_service.rs b/src/server/input_service.rs index 82610f3ba..7dbe4105d 100644 --- a/src/server/input_service.rs +++ b/src/server/input_service.rs @@ -198,6 +198,7 @@ fn modifier_sleep() { #[inline] fn get_modifier_state(key: Key, en: &mut Enigo) -> bool { + // https://github.com/rustdesk/rustdesk/issues/332 // on Linux, if RightAlt is down, RightAlt status is false, Alt status is true // but on Windows, both are true let x = en.get_key_state(key.clone()); @@ -293,6 +294,11 @@ fn fix_modifier( en: &mut Enigo, ) { if get_modifier_state(key1, en) && !modifiers.contains(&ProtobufEnumOrUnknown::new(key0)) { + #[cfg(windows)] + if key0 == ControlKey::Control && get_modifier_state(Key::Alt, en) { + // AltGr case + return; + } en.key_up(key1); log::debug!("Fixed {:?}", key1); } diff --git a/src/ui/remote.rs b/src/ui/remote.rs index 91e9a2ecd..ac5c9cc77 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -60,6 +60,8 @@ static mut KEYBOARD_HOOKED: bool = false; static mut SERVER_KEYBOARD_ENABLED: bool = true; static mut SERVER_FILE_TRANSFER_ENABLED: bool = true; static mut SERVER_CLIPBOARD_ENABLED: bool = true; +#[cfg(windows)] +static mut IS_ALT_GR: bool = false; #[derive(Default)] pub struct HandlerInner { @@ -254,6 +256,23 @@ impl Handler { _ => return, }; let alt = get_key_state(enigo::Key::Alt); + #[cfg(windows)] + let ctrl = { + let mut tmp = get_key_state(enigo::Key::Control); + unsafe { + if IS_ALT_GR { + if alt || key == Key::Alt { + if tmp { + tmp = false; + } + } else { + IS_ALT_GR = false; + } + } + } + tmp + }; + #[cfg(not(windows))] let ctrl = get_key_state(enigo::Key::Control); let shift = get_key_state(enigo::Key::Shift); let command = get_key_state(enigo::Key::Meta); @@ -266,6 +285,9 @@ impl Handler { // scancode with bit 9 set is sent, let's ignore this. #[cfg(windows)] if evt.scan_code & 0x200 != 0 { + unsafe { + IS_ALT_GR = true; + } return; } Some(ControlKey::Control) @@ -1844,7 +1866,8 @@ impl Remote { return false; } Some(misc::Union::option_response(resp)) => { - self.handler.msgbox("warn", "Option Error", &resp.error); + self.handler + .msgbox("custom-error", "Option Error", &resp.error); } _ => {} },