more on AltGr

This commit is contained in:
rustdesk 2022-03-07 20:16:28 +08:00
parent b8f7e347c3
commit dcad90e073
3 changed files with 31 additions and 2 deletions

View File

@ -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)
}

View File

@ -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);
}

View File

@ -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);
}
_ => {}
},