diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 59d0576a..65e8611c 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -39,6 +39,7 @@ const String kWindowEventActiveSession = "active_session"; const String kWindowEventGetRemoteList = "get_remote_list"; const String kWindowEventGetSessionIdList = "get_session_id_list"; +const String kWindowEventSplit = "split"; const String kWindowEventCloseForSeparateWindow = "close_for_separate_window"; const String kOptionSeparateRemoteWindow = "enable-separate-remote-window"; diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 43c73b0b..34916481 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -570,6 +570,17 @@ class _DesktopHomePageState extends State forceRelay: call.arguments['forceRelay'], forceSeparateWindow: call.arguments['forceSeparateWindow'], ); + } else if (call.method == kWindowEventSplit) { + final args = call.arguments.split(','); + int? windowId; + try { + windowId = int.parse(args[0]); + } catch (e) { + debugPrint("Failed to parse window id '${call.arguments}': $e"); + } + if (windowId != null) { + await rustDeskWinManager.splitWindow(windowId, args[1], args[2]); + } } }); _uniLinksSubscription = listenUniLinks(); diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 9072643e..06555bc8 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -6,7 +6,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/consts.dart'; -import 'package:flutter_hbb/utils/multi_window_manager.dart'; import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart'; import 'package:flutter_hbb/desktop/pages/desktop_tab_page.dart'; import 'package:flutter_hbb/models/platform_model.dart'; @@ -323,13 +322,6 @@ class _GeneralState extends State<_General> { 'Separate remote window', kOptionSeparateRemoteWindow, isServer: false, - update: () { - final useSeparateWindow = - mainGetLocalBoolOptionSync(kOptionSeparateRemoteWindow); - if (useSeparateWindow) { - rustDeskWinManager.separateWindows(); - } - }, ), ]; // though this is related to GUI, but opengl problem affects all users, so put in config rather than local diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart index 08089572..e4bbeba9 100644 --- a/flutter/lib/desktop/pages/remote_tab_page.dart +++ b/flutter/lib/desktop/pages/remote_tab_page.dart @@ -329,6 +329,22 @@ class _ConnectionTabPageState extends State { )); } + if (tabController.state.value.tabs.length > 1) { + final splitAction = MenuEntryButton( + childBuilder: (TextStyle? style) => Text( + translate('Split'), + style: style, + ), + proc: () async { + await DesktopMultiWindow.invokeMethod( + kMainWindowId, kWindowEventSplit, '${windowId()},$key,$sessionId'); + cancelFunc(); + }, + padding: padding, + ); + menu.insert(1, splitAction); + } + if (perms['keyboard'] != false && !ffi.ffiModel.viewOnly) { if (perms['clipboard'] != false) { menu.add(RemoteMenuEntry.disableClipboard(sessionId, padding, diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart index b0959246..fb576e42 100644 --- a/flutter/lib/utils/multi_window_manager.dart +++ b/flutter/lib/utils/multi_window_manager.dart @@ -43,33 +43,22 @@ class RustDeskMultiWindowManager { final List _fileTransferWindows = List.empty(growable: true); final List _portForwardWindows = List.empty(growable: true); - separateWindows() async { - for (final windowId in _remoteDesktopWindows.toList()) { - final String sessionIdList = await DesktopMultiWindow.invokeMethod( - windowId, kWindowEventGetSessionIdList, null); - final idList = sessionIdList.split(';'); - if (idList.length <= 1) { - continue; - } - for (final idPair in idList.sublist(1)) { - final peerSession = idPair.split(','); - var params = { - 'type': WindowType.RemoteDesktop.index, - 'id': peerSession[0], - 'session_id': peerSession[1], - }; - await _newSession( - true, - WindowType.RemoteDesktop, - kWindowEventNewRemoteDesktop, - peerSession[0], - _remoteDesktopWindows, - jsonEncode(params), - ); - await DesktopMultiWindow.invokeMethod( - windowId, kWindowEventCloseForSeparateWindow, peerSession[0]); - } - } + splitWindow(int windowId, String peerId, String sessionId) async { + var params = { + 'type': WindowType.RemoteDesktop.index, + 'id': peerId, + 'session_id': sessionId, + }; + await _newSession( + true, + WindowType.RemoteDesktop, + kWindowEventNewRemoteDesktop, + peerId, + _remoteDesktopWindows, + jsonEncode(params), + ); + await DesktopMultiWindow.invokeMethod( + windowId, kWindowEventCloseForSeparateWindow, peerId); } newSessionWindow( @@ -214,7 +203,8 @@ class RustDeskMultiWindowManager { } for (final windowId in wnds) { if (_activeWindows.contains(windowId)) { - return await DesktopMultiWindow.invokeMethod(windowId, methodName, args); + return await DesktopMultiWindow.invokeMethod( + windowId, methodName, args); } } return await DesktopMultiWindow.invokeMethod(wnds[0], methodName, args); @@ -223,7 +213,7 @@ class RustDeskMultiWindowManager { List _findWindowsByType(WindowType type) { switch (type) { case WindowType.Main: - return [0]; + return [kMainWindowId]; case WindowType.RemoteDesktop: return _remoteDesktopWindows; case WindowType.FileTransfer: diff --git a/src/lang/ca.rs b/src/lang/ca.rs index 326ef5dd..d285805f 100644 --- a/src/lang/ca.rs +++ b/src/lang/ca.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index f52cb9b6..3e93a786 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "对标签进行排序"), ("Separate remote window", "使用独立远程窗口"), ("separate window", "独立窗口"), + ("Split", "拆分"), ].iter().cloned().collect(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index a61c4600..8bc165f4 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index c3f43b7f..c44973bb 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index e59eb63d..24a59d4f 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "Tags sortieren"), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/el.rs b/src/lang/el.rs index 83160cae..ccfd1c8e 100644 --- a/src/lang/el.rs +++ b/src/lang/el.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 47792961..9cc79a98 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index b5747479..2d33c575 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "Ordenar etiquetas"), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index 6f2531b4..f57687e5 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 679620a9..bab0ef06 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index 8eacb75d..02b0ed90 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index 2d12c31e..608b00cd 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index 5118adc1..d1c71c38 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "Ordina etichette"), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index ed09d613..e5328f33 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index d4834702..05f003f6 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index 1bcadec6..634654dc 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/lt.rs b/src/lang/lt.rs index accdf9a3..bdc8c9e2 100644 --- a/src/lang/lt.rs +++ b/src/lang/lt.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/nl.rs b/src/lang/nl.rs index b1bcd1d2..d4868b40 100644 --- a/src/lang/nl.rs +++ b/src/lang/nl.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "Labels sorteren"), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 1d813ef4..8aa9525a 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 6b32a1e4..196f1e5c 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index c732dd2a..53c91b3c 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ro.rs b/src/lang/ro.rs index 4db68ee5..f3cc6220 100644 --- a/src/lang/ro.rs +++ b/src/lang/ro.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index 9dcef1a4..c44335f6 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", "Сортировка меток"), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 3f8d5716..0c7e5f2d 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sl.rs b/src/lang/sl.rs index e3c17a65..ff0c0114 100755 --- a/src/lang/sl.rs +++ b/src/lang/sl.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sq.rs b/src/lang/sq.rs index 46db6857..261d5fa5 100644 --- a/src/lang/sq.rs +++ b/src/lang/sq.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sr.rs b/src/lang/sr.rs index 370865e0..9ce8e4c3 100644 --- a/src/lang/sr.rs +++ b/src/lang/sr.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sv.rs b/src/lang/sv.rs index 3ec8535e..72b3f324 100644 --- a/src/lang/sv.rs +++ b/src/lang/sv.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index 7eb168fd..82fcec79 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/th.rs b/src/lang/th.rs index f125384d..b17f432d 100644 --- a/src/lang/th.rs +++ b/src/lang/th.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index b4959b15..c2467ce5 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index cda76a15..c705665a 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index 8d46b61a..879dd9d9 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index c188e2d1..52fef05d 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -526,5 +526,6 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Sort tags", ""), ("Separate remote window", ""), ("separate window", ""), + ("Split", ""), ].iter().cloned().collect(); }