fix: restore window, on connection (#8129)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
parent
7da09f6296
commit
1efce51222
@ -1567,8 +1567,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
||||
late Offset position;
|
||||
late Size sz;
|
||||
late bool isMaximized;
|
||||
bool isFullscreen = stateGlobal.fullscreen.isTrue ||
|
||||
(isMacOS && stateGlobal.closeOnFullscreen == true);
|
||||
bool isFullscreen = stateGlobal.fullscreen.isTrue;
|
||||
setPreFrame() {
|
||||
final pos = bind.getLocalFlutterOption(k: windowFramePrefix + type.name);
|
||||
var lpos = LastWindowPosition.loadFromString(pos);
|
||||
@ -1890,7 +1889,6 @@ Future<bool> restoreWindowPosition(WindowType type,
|
||||
}
|
||||
if (lpos.isFullscreen == true) {
|
||||
if (!isMacOS) {
|
||||
stateGlobal.setFullscreen(false);
|
||||
await restoreFrame();
|
||||
}
|
||||
// An duration is needed to avoid the window being restored after fullscreen.
|
||||
@ -2906,10 +2904,10 @@ openMonitorInNewTabOrWindow(int i, String peerId, PeerInfo pi,
|
||||
|
||||
setNewConnectWindowFrame(int windowId, String peerId, Rect? screenRect) async {
|
||||
if (screenRect == null) {
|
||||
restoreWindowPosition(WindowType.RemoteDesktop,
|
||||
await restoreWindowPosition(WindowType.RemoteDesktop,
|
||||
windowId: windowId, peerId: peerId);
|
||||
} else {
|
||||
tryMoveToScreenAndSetFullscreen(screenRect);
|
||||
await tryMoveToScreenAndSetFullscreen(screenRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,15 +350,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
|
||||
void onRemoveId(String id) async {
|
||||
if (tabController.state.value.tabs.isEmpty) {
|
||||
if (stateGlobal.fullscreen.isTrue) {
|
||||
if (isLinux) {
|
||||
// If the window is left fullscreen and then reuse, the frame state will be incorrect when exit fullscreen the next time.
|
||||
// State `fullscreen -> hide -> show -> exit fullscreen`, then the window will be maximized and overlapped.
|
||||
// No idea how the strange state comes, just a **workaround**.
|
||||
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
||||
}
|
||||
stateGlobal.setFullscreen(false, procWnd: false);
|
||||
}
|
||||
// Keep calling until the window status is hidden.
|
||||
//
|
||||
// Workaround for Windows:
|
||||
@ -424,16 +415,16 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
final display = args['display'];
|
||||
final displays = args['displays'];
|
||||
final screenRect = parseParamScreenRect(args);
|
||||
windowOnTop(windowId());
|
||||
setNewConnectWindowFrame(windowId(), id!, screenRect);
|
||||
if (tabController.length == 0) {
|
||||
// Show the hidden window.
|
||||
if (isMacOS && stateGlobal.closeOnFullscreen == true) {
|
||||
stateGlobal.setFullscreen(true);
|
||||
Future.delayed(Duration.zero, () async {
|
||||
if (stateGlobal.fullscreen.isTrue) {
|
||||
await WindowController.fromWindowId(windowId()).setFullscreen(false);
|
||||
stateGlobal.setFullscreen(false, procWnd: false);
|
||||
}
|
||||
// Reset the state
|
||||
stateGlobal.closeOnFullscreen = null;
|
||||
}
|
||||
await setNewConnectWindowFrame(windowId(), id!, screenRect);
|
||||
Future.delayed(Duration(milliseconds: isWindows ? 100 : 0), () async {
|
||||
await windowOnTop(windowId());
|
||||
});
|
||||
});
|
||||
ConnectionTypeState.init(id);
|
||||
_toolbarState.setShow(
|
||||
bind.mainGetUserDefaultOption(key: kOptionCollapseToolbar) != 'Y');
|
||||
|
@ -641,14 +641,12 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
}
|
||||
// macOS specific workaround, the window is not hiding when in fullscreen.
|
||||
if (isMacOS && await windowManager.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen ??= true;
|
||||
await windowManager.setFullScreen(false);
|
||||
await macOSWindowClose(
|
||||
() async => await windowManager.isFullScreen(),
|
||||
mainWindowClose,
|
||||
);
|
||||
} else {
|
||||
stateGlobal.closeOnFullscreen ??= false;
|
||||
await mainWindowClose();
|
||||
}
|
||||
} else {
|
||||
@ -660,7 +658,6 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
|
||||
if (await widget.onClose?.call() ?? true) {
|
||||
if (await controller.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen ??= true;
|
||||
await controller.setFullscreen(false);
|
||||
stateGlobal.setFullscreen(false, procWnd: false);
|
||||
await macOSWindowClose(
|
||||
@ -668,7 +665,6 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
() async => await notMainWindowClose(controller),
|
||||
);
|
||||
} else {
|
||||
stateGlobal.closeOnFullscreen ??= false;
|
||||
await notMainWindowClose(controller);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ class StateGlobal {
|
||||
final RxDouble _windowBorderWidth = RxDouble(kWindowBorderWidth);
|
||||
final RxBool showRemoteToolBar = false.obs;
|
||||
final svcStatus = SvcStatus.notReady.obs;
|
||||
// Only used for macOS
|
||||
bool? closeOnFullscreen;
|
||||
final RxBool isFocused = false.obs;
|
||||
|
||||
String _inputSource = '';
|
||||
|
@ -174,7 +174,9 @@ class RustDeskMultiWindowManager {
|
||||
windowId: windowId, peerId: remoteId);
|
||||
}
|
||||
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
|
||||
WindowController.fromWindowId(windowId).show();
|
||||
if (methodName != kWindowEventNewRemoteDesktop) {
|
||||
WindowController.fromWindowId(windowId).show();
|
||||
}
|
||||
registerActiveWindow(windowId);
|
||||
return MultiWindowCallResult(windowId, null);
|
||||
}
|
||||
|
@ -203,12 +203,6 @@ class RustdeskImpl {
|
||||
]));
|
||||
}
|
||||
|
||||
Future<String?> sessionGetFlutterOptionByPeerId(
|
||||
{required String id, required String k, dynamic hint}) {
|
||||
return Future(
|
||||
() => js.context.callMethod('getByName', ['option:flutter:peer', k]));
|
||||
}
|
||||
|
||||
int getNextTextureKey({dynamic hint}) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: ef03db52a20a7899da135d694c071fa3866c8fb1
|
||||
resolved-ref: 965b6ceba095b120c37c368abc2e4dbc8a71e09c
|
||||
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
|
@ -278,15 +278,6 @@ pub fn session_set_flutter_option(session_id: SessionID, k: String, v: String) {
|
||||
}
|
||||
}
|
||||
|
||||
// This function is only used for the default connection session.
|
||||
pub fn session_get_flutter_option_by_peer_id(id: String, k: String) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session_by_peer_id(id, ConnType::DEFAULT_CONN) {
|
||||
Some(session.get_flutter_option(k))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_next_texture_key() -> SyncReturn<i32> {
|
||||
let k = TEXTURE_RENDER_KEY.fetch_add(1, Ordering::SeqCst) + 1;
|
||||
SyncReturn(k)
|
||||
|
Loading…
Reference in New Issue
Block a user