opt: hide main window when using shortcut

This commit is contained in:
Kingtous
2022-11-26 11:40:13 +08:00
parent 03c1395565
commit f343478016
5 changed files with 52 additions and 27 deletions

View File

@@ -420,7 +420,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
// initTray();
trayManager.addListener(this);
rustDeskWinManager.registerActiveWindowListener(onActiveWindowChanged);
rustDeskWinManager.registerActiveWindow(0);
// main window may be hidden because of the initial uni link or arguments.
// note that we must wrap this active window registration in future because
// we must ensure the execution is after `windowManager.hide/show()`.
Future.delayed(Duration.zero, () {
windowManager.isVisible().then((visibility) {
if (visibility) {
rustDeskWinManager.registerActiveWindow(kWindowMainId);
}
});
});
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
debugPrint(
"[Main] call ${call.method} with args ${call.arguments} from window $fromWindowId");
@@ -455,9 +465,6 @@ class _DesktopHomePageState extends State<DesktopHomePage>
rustDeskWinManager.unregisterActiveWindow(call.arguments["id"]);
}
});
Future.delayed(Duration.zero, () {
checkArguments();
});
_uniLinksSubscription = listenUniLinks();
}