opt: update remote alias/id on taskbar in remote window

https://github.com/rustdesk/rustdesk/discussions/2815#discussioncomment-4752398
This commit is contained in:
Kingtous
2023-01-23 22:07:50 +08:00
parent bb6501c3f5
commit 3cd93ba5b7
9 changed files with 85 additions and 45 deletions

View File

@@ -31,6 +31,10 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
_FileManagerTabPageState(Map<String, dynamic> params) {
Get.put(DesktopTabController(tabType: DesktopTabType.fileTransfer));
tabController.onSelected = (_, id) {
WindowController.fromWindowId(windowId())
.setTitle(getWindowNameWithId(id));
};
tabController.add(TabInfo(
key: params['id'],
label: params['id'],

View File

@@ -31,6 +31,10 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
isRDP = params['isRDP'];
tabController =
Get.put(DesktopTabController(tabType: DesktopTabType.portForward));
tabController.onSelected = (_, id) {
WindowController.fromWindowId(windowId())
.setTitle(getWindowNameWithId(id));
};
tabController.add(TabInfo(
key: params['id'],
label: params['id'],

View File

@@ -39,8 +39,7 @@ class ConnectionTabPage extends StatefulWidget {
class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabController = Get.put(DesktopTabController(
tabType: DesktopTabType.remoteScreen,
onSelected: (_, id) => bind.setCurSessionId(id: id)));
tabType: DesktopTabType.remoteScreen));
static const IconData selectedIcon = Icons.desktop_windows_sharp;
static const IconData unselectedIcon = Icons.desktop_windows_outlined;
@@ -54,6 +53,11 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final peerId = params['id'];
if (peerId != null) {
ConnectionTypeState.init(peerId);
tabController.onSelected = (_, id) {
bind.setCurSessionId(id: id);
WindowController.fromWindowId(windowId())
.setTitle(getWindowNameWithId(id));
};
tabController.add(TabInfo(
key: peerId,
label: peerId,
@@ -76,6 +80,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
super.initState();
tabController.onRemoved = (_, id) => onRemoveId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(

View File

@@ -30,7 +30,12 @@ class _DesktopServerPageState extends State<DesktopServerPage>
void initState() {
gFFI.ffiModel.updateEventListener("");
windowManager.addListener(this);
tabController.onRemoved = (_, id) => onRemoveId(id);
tabController.onRemoved = (_, id) {
onRemoveId(id);
};
tabController.onSelected = (_, id) {
windowManager.setTitle(getWindowNameWithId(id));
};
super.initState();
}

View File

@@ -26,7 +26,7 @@ class RefreshWrapperState extends State<RefreshWrapper> {
}
rebuild() {
debugPrint("=====Global State Rebuild (win-${windowId ?? 'main'})=====");
debugPrint("=====Global State Rebuild (win-${kWindowId ?? 'main'})=====");
if (Get.context != null) {
(context as Element).visitChildren(_rebuildElement);
}

View File

@@ -486,7 +486,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
}
});
} else {
final wc = WindowController.fromWindowId(windowId!);
final wc = WindowController.fromWindowId(kWindowId!);
wc.isMaximized().then((maximized) {
debugPrint("isMaximized $maximized");
if (widget.isMaximized.value != maximized) {
@@ -534,10 +534,10 @@ class WindowActionPanelState extends State<WindowActionPanel>
await windowManager.hide();
} else {
// it's safe to hide the subwindow
await WindowController.fromWindowId(windowId!).hide();
await WindowController.fromWindowId(kWindowId!).hide();
await Future.wait([
rustDeskWinManager
.call(WindowType.Main, kWindowEventHide, {"id": windowId!}),
.call(WindowType.Main, kWindowEventHide, {"id": kWindowId!}),
widget.onClose?.call() ?? Future.microtask(() => null)
]);
}
@@ -563,7 +563,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
if (widget.isMainWindow) {
windowManager.minimize();
} else {
WindowController.fromWindowId(windowId!).minimize();
WindowController.fromWindowId(kWindowId!).minimize();
}
},
isClose: false,
@@ -593,7 +593,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
if (widget.isMainWindow) {
await windowManager.close();
} else {
await WindowController.fromWindowId(windowId!)
await WindowController.fromWindowId(kWindowId!)
.close();
}
});
@@ -622,7 +622,7 @@ void startDragging(bool isMainWindow) {
if (isMainWindow) {
windowManager.startDragging();
} else {
WindowController.fromWindowId(windowId!).startDragging();
WindowController.fromWindowId(kWindowId!).startDragging();
}
}
@@ -638,7 +638,7 @@ Future<bool> toggleMaximize(bool isMainWindow) async {
return true;
}
} else {
final wc = WindowController.fromWindowId(windowId!);
final wc = WindowController.fromWindowId(kWindowId!);
if (await wc.isMaximized()) {
wc.unmaximize();
return false;