tmp commit

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-08-04 00:17:11 +08:00
parent e4ac34da0d
commit e12d0ef4aa

View File

@ -45,10 +45,9 @@ class RustDeskMultiWindowManager {
separateWindows() async { separateWindows() async {
for (final windowId in _remoteDesktopWindows) { for (final windowId in _remoteDesktopWindows) {
final sessionIdList = await DesktopMultiWindow.invokeMethod( final String sessionIdList = await DesktopMultiWindow.invokeMethod(
windowId, kWindowEventGetSessionIdList, null); windowId, kWindowEventGetSessionIdList, null);
if (sessionIdList != null) { final idList = sessionIdList.split(';');
final idList = sessionIdList.split(';') as List<String>;
if (idList.length <= 1) { if (idList.length <= 1) {
continue; continue;
} }
@ -59,14 +58,19 @@ class RustDeskMultiWindowManager {
'id': peerSession[0], 'id': peerSession[0],
'sessionId': peerSession[1], 'sessionId': peerSession[1],
}; };
await newSessionWindow(WindowType.RemoteDesktop, peerSession[0], await _newSession(
jsonEncode(params), _remoteDesktopWindows); true,
WindowType.RemoteDesktop,
kWindowEventNewRemoteDesktop,
peerSession[0],
_remoteDesktopWindows,
jsonEncode(params),
);
await DesktopMultiWindow.invokeMethod( await DesktopMultiWindow.invokeMethod(
windowId, kWindowEventCloseForSeparateWindow, peerSession[0]); windowId, kWindowEventCloseForSeparateWindow, peerSession[0]);
} }
} }
} }
}
newSessionWindow( newSessionWindow(
WindowType type, String remoteId, String msg, List<int> windows) async { WindowType type, String remoteId, String msg, List<int> windows) async {
@ -87,6 +91,36 @@ class RustDeskMultiWindowManager {
windows.add(windowController.windowId); windows.add(windowController.windowId);
} }
_newSession(
bool separateWindow,
WindowType type,
String methodName,
String remoteId,
List<int> windows,
String msg,
) async {
if (separateWindow) {
if (kCloseMultiWindowByHide && _inactiveWindows.isNotEmpty) {
final windowId = _inactiveWindows.first;
final invokeRes =
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
final windowController = WindowController.fromWindowId(windowId);
windowController.show();
registerActiveWindow(windowController.windowId);
windows.add(windowController.windowId);
return invokeRes;
} else {
await newSessionWindow(type, remoteId, msg, windows);
}
} else {
if (windows.isEmpty) {
await newSessionWindow(type, remoteId, msg, windows);
} else {
return call(type, methodName, msg);
}
}
}
Future<dynamic> newSession( Future<dynamic> newSession(
WindowType type, WindowType type,
String methodName, String methodName,
@ -126,26 +160,7 @@ class RustDeskMultiWindowManager {
} }
} }
if (separateWindow) { await _newSession(separateWindow, type, methodName, remoteId, windows, msg);
if (kCloseMultiWindowByHide && _inactiveWindows.isNotEmpty) {
final windowId = _inactiveWindows.first;
final invokeRes =
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
final windowController = WindowController.fromWindowId(windowId);
windowController.show();
registerActiveWindow(windowController.windowId);
windows.add(windowController.windowId);
return invokeRes;
} else {
await newSessionWindow(type, remoteId, msg, windows);
}
} else {
if (windows.isEmpty) {
await newSessionWindow(type, remoteId, msg, windows);
} else {
return call(type, methodName, msg);
}
}
} }
Future<dynamic> newRemoteDesktop( Future<dynamic> newRemoteDesktop(