fix: keep window pos after new conn (#8834)
1. Keep window pos 2. Do some init in StatefulWidget constructor. If try init in its state class, it may be too late. Because I see the init function is called after building the widget tree. Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
bbdce8d57b
commit
3999d498be
@ -2981,11 +2981,15 @@ openMonitorInNewTabOrWindow(int i, String peerId, PeerInfo pi,
|
|||||||
kMainWindowId, kWindowEventOpenMonitorSession, jsonEncode(args));
|
kMainWindowId, kWindowEventOpenMonitorSession, jsonEncode(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewConnectWindowFrame(
|
setNewConnectWindowFrame(int windowId, String peerId, int preSessionCount,
|
||||||
int windowId, String peerId, int? display, Rect? screenRect) async {
|
int? display, Rect? screenRect) async {
|
||||||
if (screenRect == null) {
|
if (screenRect == null) {
|
||||||
await restoreWindowPosition(WindowType.RemoteDesktop,
|
// Do not restore window position to new connection if there's a pre-session.
|
||||||
windowId: windowId, display: display, peerId: peerId);
|
// https://github.com/rustdesk/rustdesk/discussions/8825
|
||||||
|
if (preSessionCount == 0) {
|
||||||
|
await restoreWindowPosition(WindowType.RemoteDesktop,
|
||||||
|
windowId: windowId, display: display, peerId: peerId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await tryMoveToScreenAndSetFullscreen(screenRect);
|
await tryMoveToScreenAndSetFullscreen(screenRect);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,9 @@ class RemotePage extends StatefulWidget {
|
|||||||
this.switchUuid,
|
this.switchUuid,
|
||||||
this.forceRelay,
|
this.forceRelay,
|
||||||
this.isSharedPassword,
|
this.isSharedPassword,
|
||||||
}) : super(key: key);
|
}) : super(key: key) {
|
||||||
|
initSharedStates(id);
|
||||||
|
}
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final SessionID? sessionId;
|
final SessionID? sessionId;
|
||||||
@ -99,7 +101,6 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _initStates(String id) {
|
void _initStates(String id) {
|
||||||
initSharedStates(id);
|
|
||||||
_zoomCursor = PeerBoolOption.find(id, kOptionZoomCursor);
|
_zoomCursor = PeerBoolOption.find(id, kOptionZoomCursor);
|
||||||
_showRemoteCursor = ShowRemoteCursorState.find(id);
|
_showRemoteCursor = ShowRemoteCursorState.find(id);
|
||||||
_keyboardEnabled = KeyboardEnabledState.find(id);
|
_keyboardEnabled = KeyboardEnabledState.find(id);
|
||||||
|
@ -407,12 +407,14 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
final display = args['display'];
|
final display = args['display'];
|
||||||
final displays = args['displays'];
|
final displays = args['displays'];
|
||||||
final screenRect = parseParamScreenRect(args);
|
final screenRect = parseParamScreenRect(args);
|
||||||
|
final prePeerCount = tabController.length;
|
||||||
Future.delayed(Duration.zero, () async {
|
Future.delayed(Duration.zero, () async {
|
||||||
if (stateGlobal.fullscreen.isTrue) {
|
if (stateGlobal.fullscreen.isTrue) {
|
||||||
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
||||||
stateGlobal.setFullscreen(false, procWnd: 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 {
|
Future.delayed(Duration(milliseconds: isWindows ? 100 : 0), () async {
|
||||||
await windowOnTop(windowId());
|
await windowOnTop(windowId());
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user