diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index ecaa1b29a..32faf08ae 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -28,7 +28,7 @@ import '../widgets/tabbar_widget.dart'; final SimpleWrapper _firstEnterImage = SimpleWrapper(false); -final Map noCloseSessionOnDispose = {}; +final Map closeSessionOnDispose = {}; class RemotePage extends StatefulWidget { RemotePage({ @@ -203,7 +203,7 @@ class _RemotePageState extends State @override Future dispose() async { - final closeSession = noCloseSessionOnDispose.remove(widget.id) ?? false; + final closeSession = closeSessionOnDispose.remove(widget.id) ?? true; // https://github.com/flutter/flutter/issues/64935 super.dispose(); diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart index 3e7f7f464..080895729 100644 --- a/flutter/lib/desktop/pages/remote_tab_page.dart +++ b/flutter/lib/desktop/pages/remote_tab_page.dart @@ -147,7 +147,7 @@ class _ConnectionTabPageState extends State { .join(';'); } else if (call.method == kWindowEventCloseForSeparateWindow) { final peerId = call.arguments; - noCloseSessionOnDispose[peerId] = true; + closeSessionOnDispose[peerId] = false; tabController.closeBy(peerId); } _update_remote_count(); diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 50457b195..2bf08c53f 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1702,6 +1702,10 @@ class FFI { }); // every instance will bind a stream this.id = id; + + if (isSessionAdded) { + bind.sessionHandlePeerInfo(sessionId: sessionId); + } } /// Login with [password], choose if the client should [remember] it. diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart index 974dfd9c4..2a7b89bf0 100644 --- a/flutter/lib/utils/multi_window_manager.dart +++ b/flutter/lib/utils/multi_window_manager.dart @@ -44,7 +44,7 @@ class RustDeskMultiWindowManager { final List _portForwardWindows = List.empty(growable: true); separateWindows() async { - for (final windowId in _remoteDesktopWindows) { + for (final windowId in _remoteDesktopWindows.toList()) { final String sessionIdList = await DesktopMultiWindow.invokeMethod( windowId, kWindowEventGetSessionIdList, null); final idList = sessionIdList.split(';'); @@ -56,7 +56,7 @@ class RustDeskMultiWindowManager { var params = { 'type': WindowType.RemoteDesktop.index, 'id': peerSession[0], - 'sessionId': peerSession[1], + 'session_id': peerSession[1], }; await _newSession( true, diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 82c3794bb..6236aa838 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -1008,6 +1008,10 @@ impl Remote { } } Some(login_response::Union::PeerInfo(pi)) => { + #[cfg(feature = "flutter")] + { + self.handler.pi = pi.clone(); + } self.handler.handle_peer_info(pi); #[cfg(not(feature = "flutter"))] self.check_clipboard_file_context(); @@ -1274,6 +1278,10 @@ impl Remote { } } Some(misc::Union::SwitchDisplay(s)) => { + #[cfg(feature = "flutter")] + { + self.handler.switch_display = s.clone(); + } self.handler.handle_peer_switch_display(&s); self.video_sender.send(MediaData::Reset).ok(); if s.width > 0 && s.height > 0 { diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 5df00c344..c3df147b9 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -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, + client::{file_trait::FileManager, Interface}, common::is_keyboard_mode_supported, common::make_fd_to_json, flutter::{self, SESSIONS}, @@ -601,6 +601,13 @@ pub fn session_change_resolution(session_id: SessionID, display: i32, width: i32 } } +pub fn session_handle_peer_info(session_id: SessionID) { + if let Some(session) = SESSIONS.write().unwrap().get_mut(&session_id) { + session.handle_peer_info(session.pi.clone()); + session.handle_peer_switch_display(&session.switch_display); + } +} + pub fn session_set_size(_session_id: SessionID, _width: usize, _height: usize) { #[cfg(feature = "flutter_texture_render")] if let Some(session) = SESSIONS.write().unwrap().get_mut(&_session_id) { diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 33cfa2ced..740929c39 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -62,6 +62,10 @@ pub struct Session { pub server_file_transfer_enabled: Arc>, pub server_clipboard_enabled: Arc>, pub last_change_display: Arc>, + #[cfg(feature = "flutter")] + pub pi: PeerInfo, + #[cfg(feature = "flutter")] + pub switch_display: SwitchDisplay, } #[derive(Clone)] @@ -1186,7 +1190,7 @@ impl Session { #[tokio::main(flavor = "current_thread")] pub async fn io_loop(handler: Session) { // It is ok to call this function multiple times. - #[cfg(target_os ="windows")] + #[cfg(target_os = "windows")] if !handler.is_file_transfer() && !handler.is_port_forward() { clipboard::ContextSend::enable(true); }