mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-06 02:41:29 +03:00
opt: hide window
This commit is contained in:
@@ -44,20 +44,9 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
@override
|
||||
void onWindowClose() async {
|
||||
super.onWindowClose();
|
||||
// close all sub windows
|
||||
if (await windowManager.isPreventClose()) {
|
||||
try {
|
||||
await Future.wait([
|
||||
saveWindowPosition(WindowType.Main),
|
||||
rustDeskWinManager.closeAllSubWindows()
|
||||
]);
|
||||
} catch (err) {
|
||||
debugPrint("$err");
|
||||
} finally {
|
||||
await windowManager.setPreventClose(false);
|
||||
await windowManager.close();
|
||||
}
|
||||
}
|
||||
// hide window on close
|
||||
await windowManager.hide();
|
||||
rustDeskWinManager.unregisterActiveWindow(0);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -437,9 +426,11 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
// initTray();
|
||||
trayManager.addListener(this);
|
||||
windowManager.addListener(this);
|
||||
rustDeskWinManager.registerActiveWindowListener(onActiveWindowChanged);
|
||||
rustDeskWinManager.registerActiveWindow(0);
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
debugPrint(
|
||||
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
"[Main] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
if (call.method == "main_window_on_top") {
|
||||
window_on_top(null);
|
||||
} else if (call.method == "get_window_info") {
|
||||
@@ -465,6 +456,10 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
}
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
reloadCurrentWindow();
|
||||
} else if (call.method == kWindowEventShow) {
|
||||
rustDeskWinManager.registerActiveWindow(call.arguments["id"]);
|
||||
} else if (call.method == kWindowEventHide) {
|
||||
rustDeskWinManager.unregisterActiveWindow(call.arguments["id"]);
|
||||
}
|
||||
});
|
||||
Future.delayed(Duration.zero, () {
|
||||
@@ -475,7 +470,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
destoryTray();
|
||||
// destoryTray();
|
||||
rustDeskWinManager.unregisterActiveWindowListener(onActiveWindowChanged);
|
||||
trayManager.removeListener(this);
|
||||
windowManager.removeListener(this);
|
||||
_uniLinksSubscription?.cancel();
|
||||
|
||||
@@ -97,6 +97,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
void onRemoveId(String id) {
|
||||
if (tabController.state.value.tabs.isEmpty) {
|
||||
WindowController.fromWindowId(windowId()).hide();
|
||||
rustDeskWinManager.call(WindowType.Main, kWindowEventHide, {"id": windowId()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
debugPrint(
|
||||
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
"[Port Forward] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_port_forward") {
|
||||
final args = jsonDecode(call.arguments);
|
||||
@@ -108,6 +108,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
void onRemoveId(String id) {
|
||||
if (tabController.state.value.tabs.isEmpty) {
|
||||
WindowController.fromWindowId(windowId()).hide();
|
||||
rustDeskWinManager.call(WindowType.Main, kWindowEventHide, {"id": windowId()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
|
||||
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
|
||||
print(
|
||||
"call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
"[Remote Page] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_remote_desktop") {
|
||||
@@ -324,6 +324,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
void onRemoveId(String id) {
|
||||
if (tabController.state.value.tabs.isEmpty) {
|
||||
WindowController.fromWindowId(windowId()).hide();
|
||||
rustDeskWinManager.call(WindowType.Main, kWindowEventHide, {"id": windowId()});
|
||||
}
|
||||
ConnectionTypeState.delete(id);
|
||||
_update_remote_count();
|
||||
|
||||
@@ -541,8 +541,11 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
Future.delayed(Duration.zero, () async {
|
||||
if (widget.isMainWindow) {
|
||||
await windowManager.hide();
|
||||
rustDeskWinManager.unregisterActiveWindow(0);
|
||||
} else {
|
||||
await WindowController.fromWindowId(windowId!).hide();
|
||||
rustDeskWinManager.call(
|
||||
WindowType.Main, kWindowEventHide, {"id": windowId!});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user