mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-12 13:21:30 +03:00
opt: add preventClose to handle close event manually
This commit is contained in:
@@ -33,7 +33,7 @@ class DesktopHomePage extends StatefulWidget {
|
||||
const borderColor = Color(0xFF2F65BA);
|
||||
|
||||
class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
with TrayListener, WindowListener, AutomaticKeepAliveClientMixin {
|
||||
with TrayListener, AutomaticKeepAliveClientMixin {
|
||||
final _leftPaneScrollController = ScrollController();
|
||||
|
||||
@override
|
||||
@@ -41,14 +41,6 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
var updateUrl = '';
|
||||
StreamSubscription? _uniLinksSubscription;
|
||||
|
||||
@override
|
||||
void onWindowClose() async {
|
||||
super.onWindowClose();
|
||||
// hide window on close
|
||||
await windowManager.hide();
|
||||
rustDeskWinManager.unregisterActiveWindow(0);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
@@ -425,7 +417,6 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
// disable this tray because we use tray function provided by rust now
|
||||
// initTray();
|
||||
trayManager.addListener(this);
|
||||
windowManager.addListener(this);
|
||||
rustDeskWinManager.registerActiveWindowListener(onActiveWindowChanged);
|
||||
rustDeskWinManager.registerActiveWindow(0);
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
@@ -471,9 +462,9 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
@override
|
||||
void dispose() {
|
||||
// destoryTray();
|
||||
rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged);
|
||||
// fix: disable unregister to prevent from receiving events from other windows
|
||||
// rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged);
|
||||
trayManager.removeListener(this);
|
||||
windowManager.removeListener(this);
|
||||
_uniLinksSubscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -498,6 +498,21 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
super.onWindowUnmaximize();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowClose() async {
|
||||
// hide window on close
|
||||
if (widget.isMainWindow) {
|
||||
await windowManager.hide();
|
||||
rustDeskWinManager.unregisterActiveWindow(0);
|
||||
} else {
|
||||
widget.onClose?.call();
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
rustDeskWinManager
|
||||
.call(WindowType.Main, kWindowEventHide, {"id": windowId!});
|
||||
}
|
||||
super.onWindowClose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
|
||||
Reference in New Issue
Block a user