Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

debug, open multi windows

dignowaf906fac031e
diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart
index c7c11da96..7fd80d863 100644
--- a/flutter/lib/common.dart
+++ b/flutter/lib/common.dart
@@ -2723,3 +2723,15 @@ tryMoveToScreenAndSetFullscreen(Rect? screenRect) async {
stateGlobal.setFullscreen(true);
});
}
+
+parseParamScreenRect(Map<String, dynamic> params) {
+ Rect? screenRect;
+ if (params['screen_rect'] != null) {
+ double l = params['screen_rect']['l'];
+ double t = params['screen_rect']['t'];
+ double r = params['screen_rect']['r'];
+ double b = params['screen_rect']['b'];
+ screenRect = Rect.fromLTRB(l, t, r, b);
+ }
+ return screenRect;
+}
diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart
index a06c81ad2..8633af1d3 100644
--- a/flutter/lib/desktop/pages/desktop_home_page.dart
+++ b/flutter/lib/desktop/pages/desktop_home_page.dart
@@ -616,7 +616,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
final peerId = args['peer_id'] as String;
final display = args['display'] as int;
final displayCount = args['display_count'] as int;
- final screenRect = args['screen_rect'];
+ final screenRect = parseParamScreenRect(args);
await rustDeskWinManager.openMonitorSession(
windowId, peerId, display, displayCount, screenRect);
}
diff --git a/flutter/lib/desktop/pages/remote_tab_page.dart b/flutter/lib/desktop/pages/remote_tab_page.dart
index d2f117db5..6d28d967f 100644
--- a/flutter/lib/desktop/pages/remote_tab_page.dart
+++ b/flutter/lib/desktop/pages/remote_tab_page.dart
@@ -60,7 +60,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = params['tab_window_id'];
final display = params['display'];
final displays = params['displays'];
- final screenRect = parseScreenRect(params);
+ final screenRect = parseParamScreenRect(params);
isScreenRectSet = screenRect != null;
tryMoveToScreenAndSetFullscreen(screenRect);
if (peerId != null) {
@@ -99,18 +99,6 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
}
}
- parseScreenRect(Map<String, dynamic> params) {
- Rect? screenRect;
- if (params['screen_rect'] != null) {
- double l = params['screen_rect']['l'];
- double t = params['screen_rect']['t'];
- double r = params['screen_rect']['r'];
- double b = params['screen_rect']['b'];
- screenRect = Rect.fromLTRB(l, t, r, b);
- }
- return screenRect;
- }
-
@override
void initState() {
super.initState();
@@ -131,7 +119,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = args['tab_window_id'];
final display = args['display'];
final displays = args['displays'];
- final screenRect = parseScreenRect(args);
+ final screenRect = parseParamScreenRect(args);
windowOnTop(windowId());
tryMoveToScreenAndSetFullscreen(screenRect);
if (tabController.length == 0) {
diff --git a/flutter/lib/models/state_model.dart b/flutter/lib/models/state_model.dart
index 2403a794c..e6744ff77 100644
--- a/flutter/lib/models/state_model.dart
+++ b/flutter/lib/models/state_model.dart
@@ -78,17 +78,15 @@ class StateGlobal {
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
_windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth;
if (procWnd) {
- WindowController.fromWindowId(windowId)
- .setFullscreen(_fullscreen)
- .then((_) {
+ final wc = WindowController.fromWindowId(windowId);
+ wc.setFullscreen(_fullscreen).then((_) {
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
if (Platform.isWindows && !v) {
Future.delayed(Duration.zero, () async {
- final frame =
- await WindowController.fromWindowId(windowId).getFrame();
+ final frame = await wc.getFrame();
final newRect = Rect.fromLTWH(
frame.left, frame.top, frame.width + 1, frame.height + 1);
- await WindowController.fromWindowId(windowId).setFrame(newRect);
+ await wc.setFrame(newRect);
});
}
});
diff --git a/flutter/lib/utils/multi_window_manager.dart b/flutter/lib/utils/multi_window_manager.dart
index 3c3e03627..b8edeb3e4 100644
--- a/flutter/lib/utils/multi_window_manager.dart
+++ b/flutter/lib/utils/multi_window_manager.dart
@@ -64,14 +64,13 @@ class RustDeskMultiWindowManager {
peerId,
_remoteDesktopWindows,
jsonEncode(params),
- false,
);
}
// This function must be called in the main window thread.
// Because the _remoteDesktopWindows is managed in that thread.
openMonitorSession(int windowId, String peerId, int display, int displayCount,
- dynamic screenRect) async {
+ Rect? screenRect) async {
if (_remoteDesktopWindows.length > 1) {
for (final windowId in _remoteDesktopWindows) {
if (await DesktopMultiWindow.invokeMethod(
@@ -95,8 +94,15 @@ class RustDeskMultiWindowManager {
'tab_window_id': windowId,
'display': display,
'displays': displays,
- 'screen_rect': screenRect,
};
+ if (screenRect != null) {
+ params['screen_rect'] = {
+ 'l': screenRect.left,
+ 't': screenRect.top,
+ 'r': screenRect.right,
+ 'b': screenRect.bottom,
+ };
+ }
await _newSession(
false,
WindowType.RemoteDesktop,
@@ -104,7 +110,7 @@ class RustDeskMultiWindowManager {
peerId,
_remoteDesktopWindows,
jsonEncode(params),
- screenRect != null,
+ screenRect: screenRect,
);
}
@@ -146,13 +152,13 @@ class RustDeskMultiWindowManager {
String methodName,
String remoteId,
List<int> windows,
- String msg,
- bool withScreenRect,
- ) async {
+ String msg, {
+ Rect? screenRect,
+ }) async {
if (openInTabs) {
if (windows.isEmpty) {
final windowId = await newSessionWindow(
- type, remoteId, msg, windows, withScreenRect);
+ type, remoteId, msg, windows, screenRect != null);
return MultiWindowCallResult(windowId, null);
} else {
return call(type, methodName, msg);
@@ -161,8 +167,10 @@ class RustDeskMultiWindowManager {
if (_inactiveWindows.isNotEmpty) {
for (final windowId in windows) {
if (_inactiveWindows.contains(windowId)) {
- await restoreWindowPosition(type,
- windowId: windowId, peerId: remoteId);
+ if (screenRect == null) {
+ await restoreWindowPosition(type,
+ windowId: windowId, peerId: remoteId);
+ }
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
WindowController.fromWindowId(windowId).show();
registerActiveWindow(windowId);
@@ -170,8 +178,8 @@ class RustDeskMultiWindowManager {
}
}
}
- final windowId =
- await newSessionWindow(type, remoteId, msg, windows, withScreenRect);
+ final windowId = await newSessionWindow(
+ type, remoteId, msg, windows, screenRect != null);
return MultiWindowCallResult(windowId, null);
}
}
@@ -213,8 +221,7 @@ class RustDeskMultiWindowManager {
}
}
- return _newSession(
- openInTabs, type, methodName, remoteId, windows, msg, false);
+ return _newSession(openInTabs, type, methodName, remoteId, windows, msg);
}
Future<MultiWindowCallResult> newRemoteDesktop(