diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 17206b8ce..7096c1589 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1542,8 +1542,13 @@ Future restoreWindowPosition(WindowType type, bool isRemotePeerPos = false; String? pos; if (type == WindowType.RemoteDesktop && windowId != null && peerId != null) { - pos = await bind.sessionGetFlutterConfigByPeerId( - id: peerId, k: kWindowPrefix); + if (desktopType == DesktopType.main) { + pos = bind.mainGetPeerFlutterConfigSync( + id: peerId, k: kWindowPrefix + type.name); + } else { + pos = await bind.sessionGetFlutterConfigByPeerId( + id: peerId, k: kWindowPrefix); + } isRemotePeerPos = pos != null; } pos ??= bind.getLocalFlutterConfig(k: kWindowPrefix + type.name); diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart index e87551d6b..187b03161 100644 --- a/flutter/lib/utils/multi_window_manager.dart +++ b/flutter/lib/utils/multi_window_manager.dart @@ -99,6 +99,8 @@ class RustDeskMultiWindowManager { for (final windowId in windows) { if (_inactiveWindows.contains(windowId)) { await DesktopMultiWindow.invokeMethod(windowId, methodName, msg); + await restoreWindowPosition(type, + windowId: windowId, peerId: remoteId); WindowController.fromWindowId(windowId).show(); registerActiveWindow(windowId); return; diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rs index 1287abf34..d0106ae54 100644 --- a/src/flutter_ffi.rs +++ b/src/flutter_ffi.rs @@ -806,6 +806,10 @@ pub fn main_get_peer_option_sync(id: String, key: String) -> SyncReturn SyncReturn(get_peer_option(id, key)) } +pub fn main_get_peer_flutter_config_sync(id: String, k: String) -> SyncReturn { + SyncReturn(get_peer_flutter_config(id, k)) +} + pub fn main_set_peer_option(id: String, key: String, value: String) { set_peer_option(id, key, value) } diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 2979f4ceb..246e3aaff 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -201,6 +201,13 @@ pub fn get_peer_option(id: String, name: String) -> String { c.options.get(&name).unwrap_or(&"".to_owned()).to_owned() } +#[inline] +#[cfg(feature = "flutter")] +pub fn get_peer_flutter_config(id: String, name: String) -> String { + let c = PeerConfig::load(&id); + c.ui_flutter.get(&name).unwrap_or(&"".to_owned()).to_owned() +} + #[inline] pub fn set_peer_option(id: String, name: String, value: String) { let mut c = PeerConfig::load(&id); diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 10e8978c9..7ffcaac6d 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -202,7 +202,7 @@ impl Session { } pub fn get_flutter_config(&self, k: String) -> String { - self.lc.write().unwrap().get_ui_flutter(&k) + self.lc.read().unwrap().get_ui_flutter(&k) } pub fn toggle_option(&mut self, name: String) {