mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-14 11:39:04 +08:00
simplify logic
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
aa5debe986
commit
1e8e1700df
@ -14,7 +14,6 @@ use std::{
|
|||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex,
|
||||||
},
|
},
|
||||||
thread,
|
|
||||||
time::SystemTime,
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ pub mod client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_grab_loop() {
|
pub fn start_grab_loop() {
|
||||||
thread::spawn(grab_loop);
|
super::start_grab_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_grab_status(state: GrabState) {
|
pub fn change_grab_status(state: GrabState) {
|
||||||
@ -179,7 +178,7 @@ pub mod client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grab_loop() {
|
pub fn start_grab_loop() {
|
||||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let func = move |event: Event| match event.event_type {
|
let func = move |event: Event| match event.event_type {
|
||||||
@ -233,10 +232,9 @@ pub fn is_long_press(event: &Event) -> bool {
|
|||||||
|
|
||||||
pub fn release_remote_keys() {
|
pub fn release_remote_keys() {
|
||||||
// todo!: client quit suddenly, how to release keys?
|
// todo!: client quit suddenly, how to release keys?
|
||||||
let to_release = TO_RELEASE.lock().unwrap();
|
let to_release = TO_RELEASE.lock().unwrap().clone();
|
||||||
let keys = to_release.iter().map(|&key| key).collect::<Vec<Key>>();
|
TO_RELEASE.lock().unwrap().clear();
|
||||||
drop(to_release);
|
for key in to_release {
|
||||||
for key in keys {
|
|
||||||
let event_type = EventType::KeyRelease(key);
|
let event_type = EventType::KeyRelease(key);
|
||||||
let event = event_type_to_event(event_type);
|
let event = event_type_to_event(event_type);
|
||||||
client::process_event(event);
|
client::process_event(event);
|
||||||
@ -304,17 +302,15 @@ pub fn event_to_key_event(event: &Event) -> KeyEvent {
|
|||||||
let mut key_event = KeyEvent::new();
|
let mut key_event = KeyEvent::new();
|
||||||
update_modifiers_state(event);
|
update_modifiers_state(event);
|
||||||
|
|
||||||
let mut to_release = TO_RELEASE.lock().unwrap();
|
|
||||||
match event.event_type {
|
match event.event_type {
|
||||||
EventType::KeyPress(key) => {
|
EventType::KeyPress(key) => {
|
||||||
to_release.insert(key);
|
TO_RELEASE.lock().unwrap().insert(key);
|
||||||
}
|
}
|
||||||
EventType::KeyRelease(key) => {
|
EventType::KeyRelease(key) => {
|
||||||
to_release.remove(&key);
|
TO_RELEASE.lock().unwrap().remove(&key);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
drop(to_release);
|
|
||||||
|
|
||||||
let keyboard_mode = get_keyboard_mode_enum();
|
let keyboard_mode = get_keyboard_mode_enum();
|
||||||
key_event.mode = keyboard_mode.into();
|
key_event.mode = keyboard_mode.into();
|
||||||
|
Loading…
Reference in New Issue
Block a user