mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
refact, separate remote window, try active session
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
@@ -527,7 +527,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
debugPrint(
|
||||
"[Main] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
if (call.method == kWindowMainWindowOnTop) {
|
||||
window_on_top(null);
|
||||
windowOnTop(null);
|
||||
} else if (call.method == kWindowGetWindowInfo) {
|
||||
final screen = (await window_size.getWindowInfo()).screen;
|
||||
if (screen == null) {
|
||||
|
||||
@@ -60,10 +60,10 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
||||
print(
|
||||
"[FileTransfer] call ${call.method} with args ${call.arguments} from window $fromWindowId to ${windowId()}");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_file_transfer") {
|
||||
if (call.method == kWindowEventNewFileTransfer) {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
window_on_top(windowId());
|
||||
windowOnTop(windowId());
|
||||
tabController.add(TabInfo(
|
||||
key: id,
|
||||
label: id,
|
||||
|
||||
@@ -60,11 +60,11 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
||||
debugPrint(
|
||||
"[Port Forward] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_port_forward") {
|
||||
if (call.method == kWindowEventNewPortForward) {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
final isRDP = args['isRDP'];
|
||||
window_on_top(windowId());
|
||||
windowOnTop(windowId());
|
||||
if (tabController.state.value.tabs.indexWhere((e) => e.key == id) >=
|
||||
0) {
|
||||
debugPrint("port forward $id exists");
|
||||
|
||||
@@ -95,11 +95,11 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
"[Remote Page] call ${call.method} with args ${call.arguments} from window $fromWindowId");
|
||||
|
||||
// for simplify, just replace connectionId
|
||||
if (call.method == "new_remote_desktop") {
|
||||
if (call.method == kWindowEventNewRemoteDesktop) {
|
||||
final args = jsonDecode(call.arguments);
|
||||
final id = args['id'];
|
||||
final switchUuid = args['switch_uuid'];
|
||||
window_on_top(windowId());
|
||||
windowOnTop(windowId());
|
||||
ConnectionTypeState.init(id);
|
||||
_toolbarState.setShow(
|
||||
bind.mainGetUserDefaultOption(key: 'collapse_toolbar') != 'Y');
|
||||
@@ -125,6 +125,12 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
tabController.clear();
|
||||
} else if (call.method == kWindowActionRebuild) {
|
||||
reloadCurrentWindow();
|
||||
} else if (call.method == kWindowEventActiveSession) {
|
||||
final jumpOk = tabController.jumpToByKey(call.arguments);
|
||||
if (jumpOk) {
|
||||
windowOnTop(windowId());
|
||||
}
|
||||
return jumpOk;
|
||||
}
|
||||
_update_remote_count();
|
||||
});
|
||||
|
||||
@@ -147,8 +147,10 @@ class DesktopTabController {
|
||||
|
||||
/// For addTab, tabPage has not been initialized, set [callOnSelected] to false,
|
||||
/// and call [onSelected] at the end of initState
|
||||
void jumpTo(int index, {bool callOnSelected = true}) {
|
||||
if (!isDesktop || index < 0) return;
|
||||
bool jumpTo(int index, {bool callOnSelected = true}) {
|
||||
if (!isDesktop || index < 0) {
|
||||
return false;
|
||||
}
|
||||
state.update((val) {
|
||||
val!.selected = index;
|
||||
Future.delayed(Duration(milliseconds: 100), (() {
|
||||
@@ -169,8 +171,13 @@ class DesktopTabController {
|
||||
onSelected?.call(key);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool jumpToByKey(String key, {bool callOnSelected = true}) =>
|
||||
jumpTo(state.value.tabs.indexWhere((tab) => tab.key == key),
|
||||
callOnSelected: callOnSelected);
|
||||
|
||||
void closeBy(String? key) {
|
||||
if (!isDesktop) return;
|
||||
assert(onRemoved != null);
|
||||
|
||||
Reference in New Issue
Block a user