mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-06 05:37:51 +08:00
remove unused logic
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
d916c54029
commit
aa5debe986
@ -12,7 +12,7 @@ use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
mpsc, Arc, Mutex,
|
||||
Arc, Mutex,
|
||||
},
|
||||
thread,
|
||||
time::SystemTime,
|
||||
@ -21,10 +21,6 @@ use std::{
|
||||
static mut IS_ALT_GR: bool = false;
|
||||
static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref GRAB_SENDER: Arc<Mutex<Option<mpsc::Sender<GrabState>>>> = Default::default();
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
lazy_static::lazy_static! {
|
||||
static ref CUR_SESSION: Arc<Mutex<Option<Session<FlutterHandler>>>> = Default::default();
|
||||
@ -67,20 +63,32 @@ pub mod client {
|
||||
}
|
||||
|
||||
pub fn start_grab_loop() {
|
||||
let (sender, receiver) = mpsc::channel::<GrabState>();
|
||||
|
||||
grab_loop(receiver);
|
||||
*GRAB_SENDER.lock().unwrap() = Some(sender);
|
||||
|
||||
change_grab_status(GrabState::Ready);
|
||||
thread::spawn(grab_loop);
|
||||
}
|
||||
|
||||
pub fn change_grab_status(state: GrabState) {
|
||||
if GrabState::Wait == state {
|
||||
release_remote_keys();
|
||||
match state {
|
||||
GrabState::Ready => {}
|
||||
GrabState::Run => {
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
KEYBOARD_HOOKED.swap(true, Ordering::SeqCst);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::enable_grab().ok();
|
||||
}
|
||||
GrabState::Wait => {
|
||||
release_remote_keys();
|
||||
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
KEYBOARD_HOOKED.swap(false, Ordering::SeqCst);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::disable_grab().ok();
|
||||
}
|
||||
GrabState::Exit => {
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::exit_grab_listen().ok();
|
||||
}
|
||||
if let Some(sender) = &*GRAB_SENDER.lock().unwrap() {
|
||||
sender.send(state).ok();
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,11 +179,7 @@ pub mod client {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn grab_loop(recv: mpsc::Receiver<GrabState>) {
|
||||
thread::spawn(move || loop {
|
||||
if let Some(state) = recv.recv().ok() {
|
||||
match state {
|
||||
GrabState::Ready => {
|
||||
pub fn grab_loop() {
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
std::thread::spawn(move || {
|
||||
let func = move |event: Event| match event.event_type {
|
||||
@ -210,28 +214,6 @@ pub fn grab_loop(recv: mpsc::Receiver<GrabState>) {
|
||||
}
|
||||
_ => Some(event),
|
||||
});
|
||||
}
|
||||
GrabState::Run => {
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
KEYBOARD_HOOKED.swap(true, Ordering::SeqCst);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::enable_grab().ok();
|
||||
}
|
||||
GrabState::Wait => {
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
KEYBOARD_HOOKED.swap(false, Ordering::SeqCst);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::disable_grab().ok();
|
||||
}
|
||||
GrabState::Exit => {
|
||||
#[cfg(target_os = "linux")]
|
||||
rdev::exit_grab_listen().ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn is_long_press(event: &Event) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user