fix: macos, terminate, close main then remote windows (#8240)

* fix: macos, terminate, close main then remote windows

Signed-off-by: fufesou <linlong1266@gmail.com>

* comments

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-06-02 10:35:54 +08:00 committed by GitHub
parent b6ebf61d6c
commit 32346c23e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -893,7 +893,7 @@ class OverlayDialogManager {
makeMobileActionsOverlayEntry(VoidCallback? onHide, {FFI? ffi}) {
final position = SimpleWrapper(Offset(0, 0));
makeMobileActions(BuildContext context, double s) {
final scale = s < 0.85 ? 0.85 : s;
final scale = s < 0.85 ? 0.85 : s;
final session = ffi ?? gFFI;
// compute overlay position
final screenW = MediaQuery.of(context).size.width;
@ -2384,7 +2384,13 @@ Future<void> onActiveWindowChanged() async {
await windowManager.setPreventClose(false);
await windowManager.close();
if (isMacOS) {
RdPlatformChannel.instance.terminate();
// If we call without delay, `flutter/macos/Runner/MainFlutterWindow.swift` can handle the "terminate" event.
// But the app will not close.
//
// No idea why we need to delay here, `terminate()` itself is also an async function.
Future.delayed(Duration.zero, () {
RdPlatformChannel.instance.terminate();
});
}
}
}