Merge pull request #6185 from 21pages/taskbar_close

fix close on taskbar
This commit is contained in:
RustDesk 2023-10-26 17:25:22 +08:00 committed by GitHub
commit 65e3170cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -448,6 +448,7 @@ class DesktopTab extends StatelessWidget {
isMainWindow: isMainWindow, isMainWindow: isMainWindow,
tabType: tabType, tabType: tabType,
state: state, state: state,
tabController: controller,
tail: tail, tail: tail,
showMinimize: showMinimize, showMinimize: showMinimize,
showMaximize: showMaximize, showMaximize: showMaximize,
@ -463,6 +464,7 @@ class WindowActionPanel extends StatefulWidget {
final bool isMainWindow; final bool isMainWindow;
final DesktopTabType tabType; final DesktopTabType tabType;
final Rx<DesktopTabState> state; final Rx<DesktopTabState> state;
final DesktopTabController tabController;
final bool showMinimize; final bool showMinimize;
final bool showMaximize; final bool showMaximize;
@ -475,6 +477,7 @@ class WindowActionPanel extends StatefulWidget {
required this.isMainWindow, required this.isMainWindow,
required this.tabType, required this.tabType,
required this.state, required this.state,
required this.tabController,
this.tail, this.tail,
this.showMinimize = true, this.showMinimize = true,
this.showMaximize = true, this.showMaximize = true,
@ -580,9 +583,32 @@ class WindowActionPanelState extends State<WindowActionPanel>
void onWindowClose() async { void onWindowClose() async {
mainWindowClose() async => await windowManager.hide(); mainWindowClose() async => await windowManager.hide();
notMainWindowClose(WindowController controller) async { notMainWindowClose(WindowController controller) async {
await controller.hide(); if (widget.tabController.length == 0) {
await rustDeskWinManager debugPrint("close emtpy multiwindow, hide");
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!}); await controller.hide();
await rustDeskWinManager
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!});
} else {
debugPrint("close not emtpy multiwindow from taskbar");
if (Platform.isWindows) {
await controller.show();
await controller.focus();
final res = await widget.onClose?.call() ?? true;
if (res) {
Future.delayed(Duration.zero, () async {
// onWindowClose will be called again to hide
await WindowController.fromWindowId(kWindowId!).close();
});
}
} else {
// ubuntu22.04 windowOnTop not work from taskbar
widget.tabController.clear();
Future.delayed(Duration.zero, () async {
// onWindowClose will be called again to hide
await WindowController.fromWindowId(kWindowId!).close();
});
}
}
} }
macOSWindowClose( macOSWindowClose(