mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 16:33:01 +08:00
Merge pull request #5260 from dignow/refact/separate_remote_window
Refact/separate remote window
This commit is contained in:
commit
755353dc0b
@ -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";
|
||||
|
@ -570,6 +570,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
||||
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();
|
||||
|
@ -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
|
||||
|
@ -329,6 +329,22 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
||||
));
|
||||
}
|
||||
|
||||
if (tabController.state.value.tabs.length > 1) {
|
||||
final splitAction = MenuEntryButton<String>(
|
||||
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,
|
||||
|
@ -43,33 +43,22 @@ class RustDeskMultiWindowManager {
|
||||
final List<int> _fileTransferWindows = List.empty(growable: true);
|
||||
final List<int> _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<int> _findWindowsByType(WindowType type) {
|
||||
switch (type) {
|
||||
case WindowType.Main:
|
||||
return [0];
|
||||
return [kMainWindowId];
|
||||
case WindowType.RemoteDesktop:
|
||||
return _remoteDesktopWindows;
|
||||
case WindowType.FileTransfer:
|
||||
|
@ -125,7 +125,18 @@ impl<T: InvokeUiSession> Remote<T> {
|
||||
.await
|
||||
{
|
||||
Ok((mut peer, direct, pk)) => {
|
||||
self.handler.set_connection_type(peer.is_secured(), direct); // flutter -> connection_ready
|
||||
let is_secured = peer.is_secured();
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
self.handler
|
||||
.cache_flutter
|
||||
.write()
|
||||
.unwrap()
|
||||
.is_secured_direct
|
||||
.replace((is_secured, direct));
|
||||
}
|
||||
self.handler.set_connection_type(is_secured, direct); // flutter -> connection_ready
|
||||
self.handler.update_direct(Some(direct));
|
||||
if conn_type == ConnType::DEFAULT_CONN {
|
||||
self.handler
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ pub struct CacheFlutter {
|
||||
pub sp: Option<SwitchDisplay>,
|
||||
pub cursor_data: HashMap<u64, CursorData>,
|
||||
pub cursor_id: u64,
|
||||
pub is_secured_direct: Option<(bool, bool)>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
@ -1198,6 +1199,9 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
#[cfg(feature = "flutter")]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
pub fn restore_flutter_cache(&mut self) {
|
||||
if let Some((is_secured, direct)) = self.cache_flutter.read().unwrap().is_secured_direct {
|
||||
self.set_connection_type(is_secured, direct);
|
||||
}
|
||||
let pi = self.cache_flutter.read().unwrap().pi.clone();
|
||||
self.handle_peer_info(pi);
|
||||
if let Some(sp) = self.cache_flutter.read().unwrap().sp.as_ref() {
|
||||
|
Loading…
Reference in New Issue
Block a user