feat: tray logic in windows
This commit is contained in:
parent
5c8639c603
commit
892869c014
@ -399,7 +399,15 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
@override
|
@override
|
||||||
void onTrayIconMouseDown() {
|
void onTrayIconMouseDown() {
|
||||||
windowManager.show();
|
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
|
@override
|
||||||
|
@ -511,11 +511,11 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
|||||||
if (res) {
|
if (res) {
|
||||||
// hide for all window
|
// hide for all window
|
||||||
// note: the main window can be restored by tray icon
|
// note: the main window can be restored by tray icon
|
||||||
Future.delayed(Duration.zero, () {
|
Future.delayed(Duration.zero, () async {
|
||||||
if (widget.isMainWindow) {
|
if (widget.isMainWindow) {
|
||||||
windowManager.hide();
|
await windowManager.hide();
|
||||||
} else {
|
} 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) {
|
if (extra_item != null) {
|
||||||
items.insertAll(0, extra_item);
|
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) {
|
if (Platform.isMacOS || Platform.isWindows) {
|
||||||
await trayManager.setToolTip("rustdesk");
|
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 {
|
Future<void> destoryTray() async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user