restore window pos

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-08-08 18:14:01 +08:00
parent 4d3f5373d4
commit 32fe330946
5 changed files with 21 additions and 3 deletions

View File

@ -1542,8 +1542,13 @@ Future<bool> restoreWindowPosition(WindowType type,
bool isRemotePeerPos = false; bool isRemotePeerPos = false;
String? pos; String? pos;
if (type == WindowType.RemoteDesktop && windowId != null && peerId != null) { if (type == WindowType.RemoteDesktop && windowId != null && peerId != null) {
pos = await bind.sessionGetFlutterConfigByPeerId( if (desktopType == DesktopType.main) {
id: peerId, k: kWindowPrefix); pos = bind.mainGetPeerFlutterConfigSync(
id: peerId, k: kWindowPrefix + type.name);
} else {
pos = await bind.sessionGetFlutterConfigByPeerId(
id: peerId, k: kWindowPrefix);
}
isRemotePeerPos = pos != null; isRemotePeerPos = pos != null;
} }
pos ??= bind.getLocalFlutterConfig(k: kWindowPrefix + type.name); pos ??= bind.getLocalFlutterConfig(k: kWindowPrefix + type.name);

View File

@ -99,6 +99,8 @@ class RustDeskMultiWindowManager {
for (final windowId in windows) { for (final windowId in windows) {
if (_inactiveWindows.contains(windowId)) { if (_inactiveWindows.contains(windowId)) {
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg); await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
await restoreWindowPosition(type,
windowId: windowId, peerId: remoteId);
WindowController.fromWindowId(windowId).show(); WindowController.fromWindowId(windowId).show();
registerActiveWindow(windowId); registerActiveWindow(windowId);
return; return;

View File

@ -806,6 +806,10 @@ pub fn main_get_peer_option_sync(id: String, key: String) -> SyncReturn<String>
SyncReturn(get_peer_option(id, key)) SyncReturn(get_peer_option(id, key))
} }
pub fn main_get_peer_flutter_config_sync(id: String, k: String) -> SyncReturn<String> {
SyncReturn(get_peer_flutter_config(id, k))
}
pub fn main_set_peer_option(id: String, key: String, value: String) { pub fn main_set_peer_option(id: String, key: String, value: String) {
set_peer_option(id, key, value) set_peer_option(id, key, value)
} }

View File

@ -201,6 +201,13 @@ pub fn get_peer_option(id: String, name: String) -> String {
c.options.get(&name).unwrap_or(&"".to_owned()).to_owned() 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] #[inline]
pub fn set_peer_option(id: String, name: String, value: String) { pub fn set_peer_option(id: String, name: String, value: String) {
let mut c = PeerConfig::load(&id); let mut c = PeerConfig::load(&id);

View File

@ -202,7 +202,7 @@ impl<T: InvokeUiSession> Session<T> {
} }
pub fn get_flutter_config(&self, k: String) -> String { 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) { pub fn toggle_option(&mut self, name: String) {