From 61caaa336559f623e6b97dd5c4b0ec6a8b991a19 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Tue, 10 Aug 2021 16:01:39 +0800 Subject: [PATCH] refactor, will do with shared memory --- src/ipc.rs | 1 - src/server/connection.rs | 20 +------------------- src/ui/cm.rs | 11 ----------- src/ui/cm.tis | 17 +---------------- 4 files changed, 2 insertions(+), 47 deletions(-) diff --git a/src/ipc.rs b/src/ipc.rs index 694f53732..cd8abdb9b 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -80,7 +80,6 @@ pub enum Data { enabled: bool, }, SystemInfo(Option), - ClickTime(i64), Authorize, Close, SAS, diff --git a/src/server/connection.rs b/src/server/connection.rs index 8c366a604..0ed2338d5 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -19,7 +19,6 @@ use sha2::{Digest, Sha256}; pub type Sender = mpsc::UnboundedSender<(Instant, Arc)>; lazy_static::lazy_static! { - static ref CLICK_TIME: Arc::> = Default::default(); static ref LOGIN_FAILURES: Arc::>> = Default::default(); } @@ -637,9 +636,6 @@ impl Connection { Some(message::Union::mouse_event(me)) => { if self.keyboard { handle_mouse(&me, self.inner.id()); - if is_left_up(&me) { - *CLICK_TIME.lock().unwrap() = crate::get_time(); - } } } Some(message::Union::key_event(mut me)) => { @@ -666,9 +662,6 @@ impl Connection { } else { handle_key(&me); } - if is_enter(&me) { - *CLICK_TIME.lock().unwrap() = crate::get_time(); - } } } Some(message::Union::clipboard(cb)) => { @@ -945,18 +938,7 @@ async fn start_ipc( return Err(err.into()); } Ok(Some(data)) => { - match data { - ipc::Data::ClickTime(_)=> { - unsafe { - let ct = *CLICK_TIME.lock().unwrap(); - let data = ipc::Data::ClickTime(ct); - stream.send(&data).await?; - } - } - _ => { - tx_from_cm.send(data)?; - } - } + tx_from_cm.send(data)?; } _ => {} } diff --git a/src/ui/cm.rs b/src/ui/cm.rs index 6bfc8e4ab..368769a95 100644 --- a/src/ui/cm.rs +++ b/src/ui/cm.rs @@ -57,13 +57,6 @@ impl ConnectionManager { ICON.to_owned() } - fn check_click_time(&mut self, id: i32) { - let lock = self.read().unwrap(); - if let Some(s) = lock.senders.get(&id) { - allow_err!(s.send(Data::ClickTime(crate::get_time()))); - } - } - #[inline] fn call(&self, func: &str, args: &[Value]) { let r = self.read().unwrap(); @@ -118,9 +111,6 @@ impl ConnectionManager { Data::ChatMessage { text } => { self.call("newMessage", &make_args!(id, text)); } - Data::ClickTime(ms) => { - self.call("resetClickCallback", &make_args!(ms as f64)); - } Data::FS(v) => match v { ipc::FS::ReadDir { dir, @@ -318,7 +308,6 @@ impl sciter::EventHandler for ConnectionManager { } sciter::dispatch_script_call! { - fn check_click_time(i32); fn get_icon(); fn close(i32); fn authorize(i32); diff --git a/src/ui/cm.tis b/src/ui/cm.tis index d879ccaa0..5caefd78f 100644 --- a/src/ui/cm.tis +++ b/src/ui/cm.tis @@ -3,8 +3,6 @@ view.windowFrame = is_osx ? #extended : #solid; var body; var connections = []; var show_chat = false; -var click_callback; -var click_callback_time = 0; class Body: Reactor.Component { @@ -208,21 +206,8 @@ event click $(div.chaticon) { }); } -handler.resetClickCallback = function(ms) { - if (click_callback_time - ms < 120) - click_callback = null; -} - function checkClickTime(callback) { - click_callback_time = getTime(); - click_callback = callback; - handler.check_click_time(body.cid); - self.timer(120ms, function() { - if (click_callback) { - click_callback(); - click_callback = null; - } - }); + callback(); } function adaptSize() {