refactor, will do with shared memory

This commit is contained in:
rustdesk 2021-08-10 16:01:39 +08:00
parent c3a3c1a1c7
commit 61caaa3365
4 changed files with 2 additions and 47 deletions

View File

@ -80,7 +80,6 @@ pub enum Data {
enabled: bool,
},
SystemInfo(Option<String>),
ClickTime(i64),
Authorize,
Close,
SAS,

View File

@ -19,7 +19,6 @@ use sha2::{Digest, Sha256};
pub type Sender = mpsc::UnboundedSender<(Instant, Arc<Message>)>;
lazy_static::lazy_static! {
static ref CLICK_TIME: Arc::<Mutex<i64>> = Default::default();
static ref LOGIN_FAILURES: Arc::<Mutex<HashMap<String, (i32, i32, i32)>>> = 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)?;
}
_ => {}
}

View File

@ -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);

View File

@ -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() {