mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -1010,7 +1010,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
Some(login_response::Union::PeerInfo(pi)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
*self.handler.pi.write().unwrap() = pi.clone();
|
||||
self.handler.cache_flutter.write().unwrap().pi = pi.clone();
|
||||
}
|
||||
self.handler.handle_peer_info(pi);
|
||||
#[cfg(not(feature = "flutter"))]
|
||||
@@ -1059,9 +1059,20 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
_ => {}
|
||||
},
|
||||
Some(message::Union::CursorData(cd)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
let mut lock = self.handler.cache_flutter.write().unwrap();
|
||||
if !lock.cursor_data.contains_key(&cd.id) {
|
||||
lock.cursor_data.insert(cd.id, cd.clone());
|
||||
}
|
||||
}
|
||||
self.handler.set_cursor_data(cd);
|
||||
}
|
||||
Some(message::Union::CursorId(id)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
self.handler.cache_flutter.write().unwrap().cursor_id = id;
|
||||
}
|
||||
self.handler.set_cursor_id(id.to_string());
|
||||
}
|
||||
Some(message::Union::CursorPosition(cp)) => {
|
||||
@@ -1280,7 +1291,7 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
Some(misc::Union::SwitchDisplay(s)) => {
|
||||
#[cfg(feature = "flutter")]
|
||||
{
|
||||
*self.handler.switch_display.write().unwrap() = s.clone();
|
||||
self.handler.cache_flutter.write().unwrap().sp = s.clone();
|
||||
}
|
||||
self.handler.handle_peer_switch_display(&s);
|
||||
self.video_sender.send(MediaData::Reset).ok();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
use crate::common::get_default_sound_input;
|
||||
use crate::{
|
||||
client::{file_trait::FileManager, Interface},
|
||||
client::file_trait::FileManager,
|
||||
common::is_keyboard_mode_supported,
|
||||
common::make_fd_to_json,
|
||||
flutter::{self, SESSIONS},
|
||||
@@ -601,11 +601,9 @@ pub fn session_change_resolution(session_id: SessionID, display: i32, width: i32
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_handle_peer_info(session_id: SessionID) {
|
||||
pub fn session_restore_cache(session_id: SessionID) {
|
||||
if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) {
|
||||
let pi = session.pi.read().unwrap().clone();
|
||||
session.handle_peer_info(pi);
|
||||
session.handle_peer_switch_display(&session.switch_display.read().unwrap());
|
||||
session.restore_flutter_cache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,15 @@ pub static IS_IN: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
const CHANGE_RESOLUTION_VALID_TIMEOUT_SECS: u64 = 15;
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
#[derive(Default)]
|
||||
pub struct CacheFlutter {
|
||||
pub pi: PeerInfo,
|
||||
pub sp: SwitchDisplay,
|
||||
pub cursor_data: HashMap<u64, CursorData>,
|
||||
pub cursor_id: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Session<T: InvokeUiSession> {
|
||||
pub session_id: SessionID, // different from the one in LoginConfigHandler, used for flutter UI message pass
|
||||
@@ -63,9 +72,7 @@ pub struct Session<T: InvokeUiSession> {
|
||||
pub server_clipboard_enabled: Arc<RwLock<bool>>,
|
||||
pub last_change_display: Arc<Mutex<ChangeDisplayRecord>>,
|
||||
#[cfg(feature = "flutter")]
|
||||
pub pi: Arc<RwLock<PeerInfo>>,
|
||||
#[cfg(feature = "flutter")]
|
||||
pub switch_display: Arc<RwLock<SwitchDisplay>>,
|
||||
pub cache_flutter: Arc<RwLock<CacheFlutter>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -1185,6 +1192,17 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
pub fn ctrl_alt_del(&self) {
|
||||
self.send_key_event(&crate::keyboard::client::event_ctrl_alt_del());
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
pub fn restore_flutter_cache(&mut self) {
|
||||
let pi = self.cache_flutter.read().unwrap().pi.clone();
|
||||
self.handle_peer_info(pi);
|
||||
self.handle_peer_switch_display(&self.cache_flutter.read().unwrap().sp);
|
||||
for (_, cd) in self.cache_flutter.read().unwrap().cursor_data.iter() {
|
||||
self.set_cursor_data(cd.clone());
|
||||
}
|
||||
self.set_cursor_id(self.cache_flutter.read().unwrap().cursor_id.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
|
||||
Reference in New Issue
Block a user