mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
fix: multi window close issue
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// must keep the order
|
||||
@@ -114,6 +115,31 @@ class RustDeskMultiWindowManager {
|
||||
Future<dynamic> Function(MethodCall call, int fromWindowId)? handler) {
|
||||
DesktopMultiWindow.setMethodHandler(handler);
|
||||
}
|
||||
|
||||
Future<void> closeAllSubWindows() async {
|
||||
await Future.wait(WindowType.values.map((e) => closeWindows(e)));
|
||||
}
|
||||
|
||||
Future<void> closeWindows(WindowType type) async {
|
||||
if (type == WindowType.Main) {
|
||||
// skip main window, use window manager instead
|
||||
return;
|
||||
}
|
||||
int? wId = findWindowByType(type);
|
||||
if (wId != null) {
|
||||
debugPrint("closing multi window: ${type.toString()}");
|
||||
try {
|
||||
final ids = await DesktopMultiWindow.getAllSubWindowIds();
|
||||
if (!ids.contains(wId)) {
|
||||
// no such window already
|
||||
return;
|
||||
}
|
||||
await WindowController.fromWindowId(wId).close();
|
||||
} on Error {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final rustDeskWinManager = RustDeskMultiWindowManager.instance;
|
||||
|
||||
Reference in New Issue
Block a user