fix: restore window, on connection (#8129)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-05-23 22:11:40 +08:00
committed by GitHub
parent 7da09f6296
commit 1efce51222
8 changed files with 16 additions and 46 deletions

View File

@@ -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');

View File

@@ -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);
}
}