diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 8c6381672..246cba198 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -2981,11 +2981,15 @@ openMonitorInNewTabOrWindow(int i, String peerId, PeerInfo pi, kMainWindowId, kWindowEventOpenMonitorSession, jsonEncode(args)); } -setNewConnectWindowFrame( - int windowId, String peerId, int? display, Rect? screenRect) async { +setNewConnectWindowFrame(int windowId, String peerId, int preSessionCount, + int? display, Rect? screenRect) async { if (screenRect == null) { - await restoreWindowPosition(WindowType.RemoteDesktop, - windowId: windowId, display: display, peerId: peerId); + // Do not restore window position to new connection if there's a pre-session. + // https://github.com/rustdesk/rustdesk/discussions/8825 + if (preSessionCount == 0) { + await restoreWindowPosition(WindowType.RemoteDesktop, + windowId: windowId, display: display, peerId: peerId); + } } else { await tryMoveToScreenAndSetFullscreen(screenRect); } diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index d1c1056be..341025c5f 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -45,7 +45,9 @@ class RemotePage extends StatefulWidget { this.switchUuid, this.forceRelay, this.isSharedPassword, - }) : super(key: key); + }) : super(key: key) { + initSharedStates(id); + } final String id; final SessionID? sessionId; @@ -99,7 +101,6 @@ class _RemotePageState extends State } void _initStates(String id) { - initSharedStates(id); _zoomCursor = PeerBoolOption.find(id, kOptionZoomCursor); _showRemoteCursor = ShowRemoteCursorState.find(id); _keyboardEnabled = KeyboardEnabledState.find(id); diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart index f43008755..3ee23b9dd 100644 --- a/flutter/lib/desktop/pages/remote_tab_page.dart +++ b/flutter/lib/desktop/pages/remote_tab_page.dart @@ -407,12 +407,14 @@ class _ConnectionTabPageState extends State { final display = args['display']; final displays = args['displays']; final screenRect = parseParamScreenRect(args); + final prePeerCount = tabController.length; Future.delayed(Duration.zero, () async { if (stateGlobal.fullscreen.isTrue) { await WindowController.fromWindowId(windowId()).setFullscreen(false); stateGlobal.setFullscreen(false, procWnd: false); } - await setNewConnectWindowFrame(windowId(), id!, display, screenRect); + await setNewConnectWindowFrame( + windowId(), id!, prePeerCount, display, screenRect); Future.delayed(Duration(milliseconds: isWindows ? 100 : 0), () async { await windowOnTop(windowId()); });