fix: close all windows, obfuscated window id (#8237)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-06-01 21:28:03 +08:00 committed by GitHub
parent 18464ec570
commit d79efcedef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -336,10 +336,10 @@ class RustDeskMultiWindowManager {
}
Future<void> closeAllSubWindows() async {
await Future.wait(WindowType.values.map((e) => closeWindows(e)));
await Future.wait(WindowType.values.map((e) => _closeWindows(e)));
}
Future<void> closeWindows(WindowType type) async {
Future<void> _closeWindows(WindowType type) async {
if (type == WindowType.Main) {
// skip main window, use window manager instead
return;
@ -347,7 +347,7 @@ class RustDeskMultiWindowManager {
List<int> windows = [];
try {
windows = await DesktopMultiWindow.getAllSubWindowIds();
windows = _findWindowsByType(type);
} catch (e) {
debugPrint('Failed to getAllSubWindowIds of $type, $e');
return;
@ -357,14 +357,9 @@ class RustDeskMultiWindowManager {
return;
}
for (final wId in windows) {
debugPrint("closing multi window: ${type.toString()}");
debugPrint("closing multi window, type: ${type.toString()} id: $wId");
await saveWindowPosition(type, windowId: wId);
try {
// final ids = await DesktopMultiWindow.getAllSubWindowIds();
// if (!ids.contains(wId)) {
// // no such window already
// return;
// }
await WindowController.fromWindowId(wId).setPreventClose(false);
await WindowController.fromWindowId(wId).close();
_activeWindows.remove(wId);
@ -373,7 +368,6 @@ class RustDeskMultiWindowManager {
return;
}
}
await _notifyActiveWindow();
clearWindowType(type);
}
@ -406,14 +400,6 @@ class RustDeskMultiWindowManager {
await _notifyActiveWindow();
}
Future<void> destroyWindow(int windowId) async {
await WindowController.fromWindowId(windowId).setPreventClose(false);
await WindowController.fromWindowId(windowId).close();
_remoteDesktopWindows.remove(windowId);
_fileTransferWindows.remove(windowId);
_portForwardWindows.remove(windowId);
}
/// Remove active window which has [`windowId`]
///
/// [Availability]