mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge pull request #3854 from chiehw/release
Release modifier when multi conn
This commit is contained in:
@@ -39,6 +39,7 @@ use sha2::{Digest, Sha256};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
num::NonZeroI64,
|
||||
sync::{atomic::AtomicI64, mpsc as std_mpsc},
|
||||
};
|
||||
@@ -132,6 +133,7 @@ pub struct Connection {
|
||||
voice_call_request_timestamp: Option<NonZeroI64>,
|
||||
audio_input_device_before_voice_call: Option<String>,
|
||||
options_in_login: Option<OptionMessage>,
|
||||
pressed_modifiers: HashSet<rdev::Key>,
|
||||
}
|
||||
|
||||
impl ConnInner {
|
||||
@@ -243,6 +245,7 @@ impl Connection {
|
||||
voice_call_request_timestamp: None,
|
||||
audio_input_device_before_voice_call: None,
|
||||
options_in_login: None,
|
||||
pressed_modifiers: Default::default(),
|
||||
};
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
tokio::spawn(async move {
|
||||
@@ -618,7 +621,6 @@ impl Connection {
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
clear_remapped_keycode();
|
||||
release_modifiers();
|
||||
log::info!("Input thread exited");
|
||||
}
|
||||
|
||||
@@ -1357,6 +1359,30 @@ impl Connection {
|
||||
} else {
|
||||
me.press
|
||||
};
|
||||
|
||||
let key = match me.mode.enum_value_or_default() {
|
||||
KeyboardMode::Map => {
|
||||
Some(crate::keyboard::keycode_to_rdev_key(me.chr()))
|
||||
}
|
||||
KeyboardMode::Translate => {
|
||||
if let Some(key_event::Union::Chr(code)) = me.union {
|
||||
Some(crate::keyboard::keycode_to_rdev_key(code & 0x0000FFFF))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
.filter(crate::keyboard::is_modifier);
|
||||
|
||||
if let Some(key) = key {
|
||||
if is_press {
|
||||
self.pressed_modifiers.insert(key);
|
||||
} else {
|
||||
self.pressed_modifiers.remove(&key);
|
||||
}
|
||||
}
|
||||
|
||||
if is_press {
|
||||
match me.union {
|
||||
Some(key_event::Union::Unicode(_))
|
||||
@@ -2011,6 +2037,14 @@ impl Connection {
|
||||
})
|
||||
.count();
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
fn release_pressed_modifiers(&mut self) {
|
||||
for modifier in self.pressed_modifiers.iter() {
|
||||
rdev::simulate(&rdev::EventType::KeyRelease(*modifier)).ok();
|
||||
}
|
||||
self.pressed_modifiers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_switch_sides_uuid(id: String, uuid: uuid::Uuid) {
|
||||
@@ -2208,3 +2242,10 @@ impl Default for PortableState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Connection {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
self.release_pressed_modifiers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ fn record_key_to_key(record_key: u64) -> Option<Key> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn release_modifiers() {
|
||||
pub fn release_device_modifiers() {
|
||||
let mut en = ENIGO.lock().unwrap();
|
||||
for modifier in [
|
||||
Key::Shift,
|
||||
|
||||
Reference in New Issue
Block a user