diff --git a/src/client/gui/lib/main.dart b/src/client/gui/lib/main.dart index da5807d68b..b13c3d7b0d 100644 --- a/src/client/gui/lib/main.dart +++ b/src/client/gui/lib/main.dart @@ -129,7 +129,7 @@ class _AppState extends ConsumerState with WindowListener { final primary = ref.read(clientSettingProvider(primaryNameKey)); if (vms.contains(primary)) { ref.read(sidebarKeyProvider.notifier).set('vm-$primary'); - windowManager.show(); + windowManager.showAndRestore(); } } diff --git a/src/client/gui/lib/tray_menu.dart b/src/client/gui/lib/tray_menu.dart index c676c018c2..ad43cb347f 100644 --- a/src/client/gui/lib/tray_menu.dart +++ b/src/client/gui/lib/tray_menu.dart @@ -19,6 +19,13 @@ import 'vm_action.dart'; import 'vm_details/terminal_tabs.dart'; import 'vm_details/vm_details.dart'; +extension WindowManagerExtensions on WindowManager { + Future showAndRestore() async { + await show(); + await restore(); + } +} + final trayMenuDataProvider = Provider.autoDispose((ref) { return ref.watch(daemonAvailableProvider) ? ref.watch(vmStatusesProvider) @@ -55,9 +62,7 @@ Future setupTrayMenu(ProviderContainer providerContainer) async { await TrayMenu.instance.addLabel( 'toggle-window', label: 'Toggle window', - callback: (_, __) async => await windowManager.isVisible() - ? windowManager.hide() - : windowManager.show(), + callback: (_, __) async => await windowManager.showAndRestore(), ); } @@ -207,7 +212,7 @@ Future _updateTrayMenu( if (providerContainer.exists(provider)) { providerContainer.read(provider.notifier).start(); } - windowManager.show(); + windowManager.showAndRestore(); }, ); } else {