mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 12:29:04 +08:00
Merge pull request #3966 from fufesou/fix/led_sync
Do not sync led, when Control, Shift, Alt, Tab, Enter are pressed
This commit is contained in:
commit
5a0f03eb0d
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731
|
||||||
//
|
//
|
||||||
// JP/KR mapping https://github.com/TigerVNC/tigervnc/blob/1a008c1380305648ab50f1d99e73439747e9d61d/vncviewer/win32.c#L267
|
// JP/KR mapping https://github.com/TigerVNC/tigervnc/blob/1a008c1380305648ab50f1d99e73439747e9d61d/vncviewer/win32.c#L267
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
use crate::platform::breakdown_callback;
|
use crate::platform::breakdown_callback;
|
||||||
use hbb_common::log;
|
use hbb_common::log;
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
|
@ -1372,32 +1372,48 @@ fn simulate_win2win_hotkey(code: u32, down: bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
|
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
|
||||||
fn is_win_linux_meta_key(_evt: &KeyEvent) -> bool {
|
fn skip_led_sync_control_key(_evt: &KeyEvent) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockModesHandler should not be created when single meta is pressing and releasing.
|
||||||
|
// Because the drop function may insert "CapsLock Click" and "NumLock Click", which breaks single meta click.
|
||||||
|
// https://github.com/rustdesk/rustdesk/issues/3928#issuecomment-1496936687
|
||||||
|
// https://github.com/rustdesk/rustdesk/issues/3928#issuecomment-1500415822
|
||||||
|
// https://github.com/rustdesk/rustdesk/issues/3928#issuecomment-1500773473
|
||||||
|
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||||
|
fn skip_led_sync_control_key(key: &ControlKey) -> bool {
|
||||||
|
[
|
||||||
|
ControlKey::Control,
|
||||||
|
ControlKey::Meta,
|
||||||
|
ControlKey::Shift,
|
||||||
|
ControlKey::Alt,
|
||||||
|
ControlKey::Tab,
|
||||||
|
ControlKey::Return,
|
||||||
|
]
|
||||||
|
.contains(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
|
||||||
|
fn skip_led_sync_rdev_key(_evt: &KeyEvent) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
#[cfg(any(target_os = "windows", target_os = "linux"))]
|
||||||
fn is_win_linux_meta_key(evt: &KeyEvent) -> bool {
|
fn skip_led_sync_rdev_key(key: &RdevKey) -> bool {
|
||||||
match evt.mode.unwrap() {
|
[
|
||||||
KeyboardMode::Map | KeyboardMode::Translate => match &evt.union {
|
RdevKey::ControlLeft,
|
||||||
Some(key_event::Union::ControlKey(ck)) => {
|
RdevKey::ControlRight,
|
||||||
return *ck == ControlKey::Meta.into();
|
RdevKey::MetaLeft,
|
||||||
}
|
RdevKey::MetaRight,
|
||||||
Some(key_event::Union::Chr(code)) => {
|
RdevKey::ShiftRight,
|
||||||
let key = crate::keycode_to_rdev_key(*code);
|
RdevKey::ShiftRight,
|
||||||
return key == RdevKey::MetaLeft || key == RdevKey::MetaRight;
|
RdevKey::Alt,
|
||||||
}
|
RdevKey::AltGr,
|
||||||
_ => {}
|
RdevKey::Tab,
|
||||||
},
|
RdevKey::Return,
|
||||||
KeyboardMode::Legacy => match &evt.union {
|
]
|
||||||
Some(key_event::Union::ControlKey(ck)) => {
|
.contains(key)
|
||||||
return *ck == ControlKey::Meta.into();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_key_(evt: &KeyEvent) {
|
pub fn handle_key_(evt: &KeyEvent) {
|
||||||
@ -1405,20 +1421,24 @@ pub fn handle_key_(evt: &KeyEvent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _lock_mode_handler = match &evt.union {
|
let mut _lock_mode_handler = None;
|
||||||
Some(key_event::Union::Unicode(..)) | Some(key_event::Union::Seq(..)) => {
|
match (&evt.union, evt.mode.enum_value_or(KeyboardMode::Legacy)) {
|
||||||
Some(LockModesHandler::new(&evt))
|
(Some(key_event::Union::Unicode(..)) | Some(key_event::Union::Seq(..)), _) => {
|
||||||
|
_lock_mode_handler = Some(LockModesHandler::new(&evt));
|
||||||
}
|
}
|
||||||
_ => {
|
(Some(key_event::Union::ControlKey(ck)), _) => {
|
||||||
// LockModesHandler should not be created when single meta is pressing and releasing.
|
let key = ck.enum_value_or(ControlKey::Unknown);
|
||||||
// Because the drop function may insert "CapsLock Click" and "NumLock Click", which breaks single meta click.
|
if !skip_led_sync_control_key(&key) {
|
||||||
// https://github.com/rustdesk/rustdesk/issues/3928#issuecomment-1496936687
|
_lock_mode_handler = Some(LockModesHandler::new(&evt));
|
||||||
if evt.down && !is_win_linux_meta_key(evt) {
|
|
||||||
Some(LockModesHandler::new(evt))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Some(key_event::Union::Chr(code)), KeyboardMode::Map | KeyboardMode::Translate) => {
|
||||||
|
let key = crate::keycode_to_rdev_key(*code);
|
||||||
|
if !skip_led_sync_rdev_key(&key) {
|
||||||
|
_lock_mode_handler = Some(LockModesHandler::new(evt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
match evt.mode.unwrap() {
|
match evt.mode.unwrap() {
|
||||||
|
Loading…
Reference in New Issue
Block a user