diff --git a/lib/main.dart b/lib/main.dart index 20533b4..d21b6da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,8 +47,7 @@ void main(args) async { final port = await findAvailablePort(8000, 9000); final Directory appDocumentsDir = await getApplicationSupportDirectory(); final Version currentVersion = Version.parse(packageInfo.version); - homeDir = - path.join(appDocumentsDir.path, '${currentVersion.major}.0'); + homeDir = path.join(appDocumentsDir.path, '${currentVersion.major}.0'); var corePath = path.join(Paths.assetsBin.path, LuxCoreName.name); if (Platform.isMacOS) { var owner = await getFileOwner(corePath); @@ -84,7 +83,9 @@ void main(args) async { } }); - initSystemTray(openDashboard, exitApp, isWebviewSupported); + initSystemTray(openDashboard, exitApp, () { + windowManager.focus(); + }, isWebviewSupported); if (!isWebviewSupported) { openDashboard(); diff --git a/lib/tray.dart b/lib/tray.dart index 2ea61cf..c7bd09a 100644 --- a/lib/tray.dart +++ b/lib/tray.dart @@ -2,8 +2,8 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:system_tray/system_tray.dart'; -Future initSystemTray( - void Function() openDashboard, exitApp, bool isWebviewSupported) async { +Future initSystemTray(void Function() openDashboard, exitApp, focusWindow, + bool isWebviewSupported) async { String path = Platform.isWindows ? 'assets/app_icon.ico' : 'assets/tray.icns'; final SystemTray systemTray = SystemTray(); @@ -35,9 +35,25 @@ Future initSystemTray( systemTray.registerSystemTrayEventHandler((eventName) { debugPrint("eventName: $eventName"); if (eventName == kSystemTrayEventClick) { - Platform.isWindows ? openDashboard() : systemTray.popUpContextMenu(); + if (Platform.isWindows) { + if (isWebviewSupported) { + focusWindow(); + } else { + openDashboard(); + } + } else { + systemTray.popUpContextMenu(); + } } else if (eventName == kSystemTrayEventRightClick) { - Platform.isWindows ? systemTray.popUpContextMenu() : openDashboard(); + if (!Platform.isWindows) { + if (isWebviewSupported) { + focusWindow(); + } else { + openDashboard(); + } + } else { + systemTray.popUpContextMenu(); + } } }); } diff --git a/pubspec.yaml b/pubspec.yaml index 80b93bd..13ad228 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.20.0-beat.2 +version: 1.20.1 environment: sdk: '>=3.0.6 <4.0.0'