mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-07 14:17: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},
|
collections::{HashMap, HashSet},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
mpsc, Arc, Mutex,
|
Arc, Mutex,
|
||||||
},
|
},
|
||||||
thread,
|
thread,
|
||||||
time::SystemTime,
|
time::SystemTime,
|
||||||
@ -21,10 +21,6 @@ use std::{
|
|||||||
static mut IS_ALT_GR: bool = false;
|
static mut IS_ALT_GR: bool = false;
|
||||||
static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(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")]
|
#[cfg(feature = "flutter")]
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref CUR_SESSION: Arc<Mutex<Option<Session<FlutterHandler>>>> = Default::default();
|
static ref CUR_SESSION: Arc<Mutex<Option<Session<FlutterHandler>>>> = Default::default();
|
||||||
@ -67,20 +63,32 @@ pub mod client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_grab_loop() {
|
pub fn start_grab_loop() {
|
||||||
let (sender, receiver) = mpsc::channel::<GrabState>();
|
thread::spawn(grab_loop);
|
||||||
|
|
||||||
grab_loop(receiver);
|
|
||||||
*GRAB_SENDER.lock().unwrap() = Some(sender);
|
|
||||||
|
|
||||||
change_grab_status(GrabState::Ready);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_grab_status(state: GrabState) {
|
pub fn change_grab_status(state: GrabState) {
|
||||||
if GrabState::Wait == state {
|
match state {
|
||||||
release_remote_keys();
|
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>) {
|
pub fn grab_loop() {
|
||||||
thread::spawn(move || loop {
|
|
||||||
if let Some(state) = recv.recv().ok() {
|
|
||||||
match state {
|
|
||||||
GrabState::Ready => {
|
|
||||||
#[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 {
|
||||||
@ -210,28 +214,6 @@ pub fn grab_loop(recv: mpsc::Receiver<GrabState>) {
|
|||||||
}
|
}
|
||||||
_ => Some(event),
|
_ => 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 {
|
pub fn is_long_press(event: &Event) -> bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user