debug, open multi windows

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-10-17 09:36:08 +08:00
parent 19945df0b3
commit af906fac03
5 changed files with 40 additions and 35 deletions

View File

@ -2723,3 +2723,15 @@ tryMoveToScreenAndSetFullscreen(Rect? screenRect) async {
stateGlobal.setFullscreen(true); 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;
}

View File

@ -616,7 +616,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
final peerId = args['peer_id'] as String; final peerId = args['peer_id'] as String;
final display = args['display'] as int; final display = args['display'] as int;
final displayCount = args['display_count'] as int; final displayCount = args['display_count'] as int;
final screenRect = args['screen_rect']; final screenRect = parseParamScreenRect(args);
await rustDeskWinManager.openMonitorSession( await rustDeskWinManager.openMonitorSession(
windowId, peerId, display, displayCount, screenRect); windowId, peerId, display, displayCount, screenRect);
} }

View File

@ -60,7 +60,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = params['tab_window_id']; final tabWindowId = params['tab_window_id'];
final display = params['display']; final display = params['display'];
final displays = params['displays']; final displays = params['displays'];
final screenRect = parseScreenRect(params); final screenRect = parseParamScreenRect(params);
isScreenRectSet = screenRect != null; isScreenRectSet = screenRect != null;
tryMoveToScreenAndSetFullscreen(screenRect); tryMoveToScreenAndSetFullscreen(screenRect);
if (peerId != null) { 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 @override
void initState() { void initState() {
super.initState(); super.initState();
@ -131,7 +119,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
final tabWindowId = args['tab_window_id']; final tabWindowId = args['tab_window_id'];
final display = args['display']; final display = args['display'];
final displays = args['displays']; final displays = args['displays'];
final screenRect = parseScreenRect(args); final screenRect = parseParamScreenRect(args);
windowOnTop(windowId()); windowOnTop(windowId());
tryMoveToScreenAndSetFullscreen(screenRect); tryMoveToScreenAndSetFullscreen(screenRect);
if (tabController.length == 0) { if (tabController.length == 0) {

View File

@ -78,17 +78,15 @@ class StateGlobal {
"fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}"); "fullscreen: $fullscreen, resizeEdgeSize: ${_resizeEdgeSize.value}");
_windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth; _windowBorderWidth.value = fullscreen ? 0 : kWindowBorderWidth;
if (procWnd) { if (procWnd) {
WindowController.fromWindowId(windowId) final wc = WindowController.fromWindowId(windowId);
.setFullscreen(_fullscreen) wc.setFullscreen(_fullscreen).then((_) {
.then((_) {
// https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982 // https://github.com/leanflutter/window_manager/issues/131#issuecomment-1111587982
if (Platform.isWindows && !v) { if (Platform.isWindows && !v) {
Future.delayed(Duration.zero, () async { Future.delayed(Duration.zero, () async {
final frame = final frame = await wc.getFrame();
await WindowController.fromWindowId(windowId).getFrame();
final newRect = Rect.fromLTWH( final newRect = Rect.fromLTWH(
frame.left, frame.top, frame.width + 1, frame.height + 1); frame.left, frame.top, frame.width + 1, frame.height + 1);
await WindowController.fromWindowId(windowId).setFrame(newRect); await wc.setFrame(newRect);
}); });
} }
}); });

View File

@ -64,14 +64,13 @@ class RustDeskMultiWindowManager {
peerId, peerId,
_remoteDesktopWindows, _remoteDesktopWindows,
jsonEncode(params), jsonEncode(params),
false,
); );
} }
// This function must be called in the main window thread. // This function must be called in the main window thread.
// Because the _remoteDesktopWindows is managed in that thread. // Because the _remoteDesktopWindows is managed in that thread.
openMonitorSession(int windowId, String peerId, int display, int displayCount, openMonitorSession(int windowId, String peerId, int display, int displayCount,
dynamic screenRect) async { Rect? screenRect) async {
if (_remoteDesktopWindows.length > 1) { if (_remoteDesktopWindows.length > 1) {
for (final windowId in _remoteDesktopWindows) { for (final windowId in _remoteDesktopWindows) {
if (await DesktopMultiWindow.invokeMethod( if (await DesktopMultiWindow.invokeMethod(
@ -95,8 +94,15 @@ class RustDeskMultiWindowManager {
'tab_window_id': windowId, 'tab_window_id': windowId,
'display': display, 'display': display,
'displays': displays, '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( await _newSession(
false, false,
WindowType.RemoteDesktop, WindowType.RemoteDesktop,
@ -104,7 +110,7 @@ class RustDeskMultiWindowManager {
peerId, peerId,
_remoteDesktopWindows, _remoteDesktopWindows,
jsonEncode(params), jsonEncode(params),
screenRect != null, screenRect: screenRect,
); );
} }
@ -146,13 +152,13 @@ class RustDeskMultiWindowManager {
String methodName, String methodName,
String remoteId, String remoteId,
List<int> windows, List<int> windows,
String msg, String msg, {
bool withScreenRect, Rect? screenRect,
) async { }) async {
if (openInTabs) { if (openInTabs) {
if (windows.isEmpty) { if (windows.isEmpty) {
final windowId = await newSessionWindow( final windowId = await newSessionWindow(
type, remoteId, msg, windows, withScreenRect); type, remoteId, msg, windows, screenRect != null);
return MultiWindowCallResult(windowId, null); return MultiWindowCallResult(windowId, null);
} else { } else {
return call(type, methodName, msg); return call(type, methodName, msg);
@ -161,8 +167,10 @@ class RustDeskMultiWindowManager {
if (_inactiveWindows.isNotEmpty) { if (_inactiveWindows.isNotEmpty) {
for (final windowId in windows) { for (final windowId in windows) {
if (_inactiveWindows.contains(windowId)) { if (_inactiveWindows.contains(windowId)) {
await restoreWindowPosition(type, if (screenRect == null) {
windowId: windowId, peerId: remoteId); await restoreWindowPosition(type,
windowId: windowId, peerId: remoteId);
}
await DesktopMultiWindow.invokeMethod(windowId, methodName, msg); await DesktopMultiWindow.invokeMethod(windowId, methodName, msg);
WindowController.fromWindowId(windowId).show(); WindowController.fromWindowId(windowId).show();
registerActiveWindow(windowId); registerActiveWindow(windowId);
@ -170,8 +178,8 @@ class RustDeskMultiWindowManager {
} }
} }
} }
final windowId = final windowId = await newSessionWindow(
await newSessionWindow(type, remoteId, msg, windows, withScreenRect); type, remoteId, msg, windows, screenRect != null);
return MultiWindowCallResult(windowId, null); return MultiWindowCallResult(windowId, null);
} }
} }
@ -213,8 +221,7 @@ class RustDeskMultiWindowManager {
} }
} }
return _newSession( return _newSession(openInTabs, type, methodName, remoteId, windows, msg);
openInTabs, type, methodName, remoteId, windows, msg, false);
} }
Future<MultiWindowCallResult> newRemoteDesktop( Future<MultiWindowCallResult> newRemoteDesktop(