feat: tray logic in windows
This commit is contained in:
parent
5c8639c603
commit
892869c014
@ -399,7 +399,15 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
@override
|
||||
void onTrayIconMouseDown() {
|
||||
windowManager.show();
|
||||
windowManager.focus();
|
||||
}
|
||||
|
||||
@override
|
||||
void onTrayIconRightMouseDown() {
|
||||
// linux does not support popup menu manually.
|
||||
// linux will handle popup action ifself.
|
||||
if (Platform.isMacOS || Platform.isWindows) {
|
||||
trayManager.popUpContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -511,11 +511,11 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
if (res) {
|
||||
// hide for all window
|
||||
// note: the main window can be restored by tray icon
|
||||
Future.delayed(Duration.zero, () {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
if (widget.isMainWindow) {
|
||||
windowManager.hide();
|
||||
await windowManager.hide();
|
||||
} else {
|
||||
WindowController.fromWindowId(windowId!).hide();
|
||||
await WindowController.fromWindowId(windowId!).hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,15 +16,15 @@ Future<void> initTray({List<MenuItem>? extra_item}) async {
|
||||
if (extra_item != null) {
|
||||
items.insertAll(0, extra_item);
|
||||
}
|
||||
await Future.wait([
|
||||
trayManager
|
||||
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png"),
|
||||
trayManager.setContextMenu(Menu(items: items)),
|
||||
trayManager.setTitle("rustdesk")
|
||||
]);
|
||||
if (Platform.isMacOS || Platform.isWindows) {
|
||||
await trayManager.setToolTip("rustdesk");
|
||||
}
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
await trayManager.setTitle("rustdesk");
|
||||
}
|
||||
await trayManager
|
||||
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png");
|
||||
await trayManager.setContextMenu(Menu(items: items));
|
||||
}
|
||||
|
||||
Future<void> destoryTray() async {
|
||||
|
Loading…
x
Reference in New Issue
Block a user