more for right key

This commit is contained in:
rustdesk 2021-06-01 13:05:04 +08:00
parent 5c541179dc
commit ffcbc2abaa
2 changed files with 31 additions and 6 deletions

View File

@ -186,6 +186,19 @@ fn modifier_sleep() {
std::thread::sleep(std::time::Duration::from_nanos(1));
}
#[cfg(not(target_os = "macos"))]
#[inline]
fn get_modifier_state(key: enigo::Key, en: &mut Enigo) -> bool {
let x = en.get_key_state(key.clone());
match key {
enigo::Key::Shift => x || en.get_key_state(enigo::Key::RightShift),
enigo::Key::Control => x || en.get_key_state(enigo::Key::RightControl),
enigo::Key::Alt => x || en.get_key_state(enigo::Key::RightAlt),
enigo::Key::Meta => x || en.get_key_state(enigo::Key::RWin),
_ => x,
}
}
pub fn handle_mouse(evt: &MouseEvent, conn: i32) {
#[cfg(target_os = "macos")]
if !*IS_SERVER {
@ -220,7 +233,7 @@ fn handle_mouse_(evt: &MouseEvent, conn: i32) {
en.add_flag(key);
#[cfg(not(target_os = "macos"))]
if key != &enigo::Key::CapsLock && key != &enigo::Key::NumLock {
if !en.get_key_state(key.clone()) {
if !get_modifier_state(key.clone(), &mut en) {
en.key_down(key.clone()).ok();
modifier_sleep();
to_release.push(key);
@ -428,7 +441,7 @@ fn handle_key_(evt: &KeyEvent) {
has_numlock = true;
}
} else {
if !en.get_key_state(key.clone()) {
if !get_modifier_state(key.clone(), &mut en) {
en.key_down(key.clone()).ok();
modifier_sleep();
to_release.push(key);

View File

@ -899,16 +899,28 @@ impl Handler {
}
}
*/
if alt && !crate::is_control_key(&key_event, &ControlKey::Alt) {
if alt
&& !crate::is_control_key(&key_event, &ControlKey::Alt)
&& !crate::is_control_key(&key_event, &ControlKey::RAlt)
{
key_event.modifiers.push(ControlKey::Alt.into());
}
if shift && !crate::is_control_key(&key_event, &ControlKey::Shift) {
if shift
&& !crate::is_control_key(&key_event, &ControlKey::Shift)
&& !crate::is_control_key(&key_event, &ControlKey::RShift)
{
key_event.modifiers.push(ControlKey::Shift.into());
}
if ctrl && !crate::is_control_key(&key_event, &ControlKey::Control) {
if ctrl
&& !crate::is_control_key(&key_event, &ControlKey::Control)
&& !crate::is_control_key(&key_event, &ControlKey::RControl)
{
key_event.modifiers.push(ControlKey::Control.into());
}
if command && !crate::is_control_key(&key_event, &ControlKey::Meta) {
if command
&& !crate::is_control_key(&key_event, &ControlKey::Meta)
&& !crate::is_control_key(&key_event, &ControlKey::RWin)
{
key_event.modifiers.push(ControlKey::Meta.into());
}
if crate::is_control_key(&key_event, &ControlKey::CapsLock) {