From 675e199b351c379f4cefc5aeccb51fd721ac0443 Mon Sep 17 00:00:00 2001 From: Asura Date: Tue, 13 Sep 2022 01:50:22 -0700 Subject: [PATCH] Disable keyboard listen --- src/client.rs | 6 +++++- src/flutter.rs | 1 + src/ui_session_interface.rs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index a625efb31..cc1f78b78 100644 --- a/src/client.rs +++ b/src/client.rs @@ -4,7 +4,7 @@ use std::{ ops::{Deref, Not}, sync::{atomic::AtomicBool, mpsc, Arc, Mutex, RwLock}, }; - +use std::sync::atomic::Ordering; pub use async_trait::async_trait; #[cfg(not(any(target_os = "android", target_os = "linux")))] use cpal::{ @@ -1891,3 +1891,7 @@ fn decode_id_pk(signed: &[u8], key: &sign::PublicKey) -> ResultType<(String, [u8 bail!("Wrong public length"); } } + +pub fn disable_keyboard_listening() { + crate::ui_session_interface::KEYBOARD_HOOKED.store(false, Ordering::SeqCst); +} \ No newline at end of file diff --git a/src/flutter.rs b/src/flutter.rs index eb66260c9..81b455b04 100644 --- a/src/flutter.rs +++ b/src/flutter.rs @@ -328,6 +328,7 @@ pub fn session_start_(id: &str, event_stream: StreamSink) -> ResultTy *session.event_stream.write().unwrap() = Some(event_stream); let session = session.clone(); std::thread::spawn(move || { + crate::client::disable_keyboard_listening(); io_loop(session); }); Ok(()) diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 43cd35754..7af3a2fbd 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -22,7 +22,7 @@ use std::sync::{Arc, Mutex, RwLock}; /// IS_IN KEYBOARD_HOOKED sciter only pub static IS_IN: AtomicBool = AtomicBool::new(false); -static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(false); +pub static KEYBOARD_HOOKED: AtomicBool = AtomicBool::new(true); #[cfg(windows)] static mut IS_ALT_GR: bool = false; @@ -1166,7 +1166,7 @@ impl Session { if self.is_port_forward() || self.is_file_transfer() { return; } - if KEYBOARD_HOOKED.swap(true, Ordering::SeqCst) { + if !KEYBOARD_HOOKED.load(Ordering::SeqCst){ return; } log::info!("keyboard hooked");