mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 19:17:58 +00:00
fix, macos, close sessions, confirm dialog and then hide
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -581,18 +581,14 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
mainWindowClose() async => await windowManager.hide();
|
||||
notMainWindowClose(WindowController controller) async {
|
||||
await controller.hide();
|
||||
await Future.wait([
|
||||
rustDeskWinManager
|
||||
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!}),
|
||||
widget.onClose?.call() ?? Future.microtask(() => null)
|
||||
]);
|
||||
await rustDeskWinManager
|
||||
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!});
|
||||
}
|
||||
|
||||
macOSWindowClose(
|
||||
Future<void> Function() restoreFunc,
|
||||
Future<bool> Function() checkFullscreen,
|
||||
Future<void> Function() closeFunc) async {
|
||||
await restoreFunc();
|
||||
Future<bool> Function() checkFullscreen,
|
||||
Future<void> Function() closeFunc,
|
||||
) async {
|
||||
_macOSCheckRestoreCounter = 0;
|
||||
_macOSCheckRestoreTimer =
|
||||
Timer.periodic(Duration(milliseconds: 30), (timer) async {
|
||||
@@ -612,26 +608,38 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
}
|
||||
// macOS specific workaround, the window is not hiding when in fullscreen.
|
||||
if (Platform.isMacOS && await windowManager.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen = true;
|
||||
stateGlobal.closeOnFullscreen ??= true;
|
||||
await windowManager.setFullScreen(false);
|
||||
await macOSWindowClose(
|
||||
() async => await windowManager.setFullScreen(false),
|
||||
() async => await windowManager.isFullScreen(),
|
||||
mainWindowClose);
|
||||
() async => await windowManager.isFullScreen(),
|
||||
mainWindowClose,
|
||||
);
|
||||
} else {
|
||||
stateGlobal.closeOnFullscreen = false;
|
||||
stateGlobal.closeOnFullscreen ??= false;
|
||||
await mainWindowClose();
|
||||
}
|
||||
} else {
|
||||
// it's safe to hide the subwindow
|
||||
final controller = WindowController.fromWindowId(kWindowId!);
|
||||
if (Platform.isMacOS && await controller.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen = true;
|
||||
await macOSWindowClose(
|
||||
() async => await controller.setFullscreen(false),
|
||||
() async => await controller.isFullScreen(),
|
||||
() async => await notMainWindowClose(controller));
|
||||
if (Platform.isMacOS) {
|
||||
// onWindowClose() maybe called multiple times as loopCloseWindow() in remote_tab_page.dart.
|
||||
// use ??= to make sure the value is set on first call.
|
||||
|
||||
if (await widget.onClose?.call() ?? true) {
|
||||
if (await controller.isFullScreen()) {
|
||||
stateGlobal.closeOnFullscreen ??= true;
|
||||
await controller.setFullscreen(false);
|
||||
stateGlobal.setFullscreen(false, procWnd: false);
|
||||
await macOSWindowClose(
|
||||
() async => await controller.isFullScreen(),
|
||||
() async => await notMainWindowClose(controller),
|
||||
);
|
||||
} else {
|
||||
stateGlobal.closeOnFullscreen ??= false;
|
||||
await notMainWindowClose(controller);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stateGlobal.closeOnFullscreen = false;
|
||||
await notMainWindowClose(controller);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user