Skip to content

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

feat, remember remote window fullscreen state

dignow55fc0cb63bd2
diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart
index 672adca75..8b20214df 100644
--- a/flutter/lib/common.dart
+++ b/flutter/lib/common.dart
@@ -1392,9 +1392,10 @@ class LastWindowPosition {
double? offsetWidth;
double? offsetHeight;
bool? isMaximized;
+ bool? isFullscreen;
LastWindowPosition(this.width, this.height, this.offsetWidth,
- this.offsetHeight, this.isMaximized);
+ this.offsetHeight, this.isMaximized, this.isFullscreen);
Map<String, dynamic> toJson() {
return <String, dynamic>{
@@ -1403,6 +1404,7 @@ class LastWindowPosition {
"offsetWidth": offsetWidth,
"offsetHeight": offsetHeight,
"isMaximized": isMaximized,
+ "isFullscreen": isFullscreen,
};
}
@@ -1418,7 +1420,7 @@ class LastWindowPosition {
try {
final m = jsonDecode(content);
return LastWindowPosition(m["width"], m["height"], m["offsetWidth"],
- m["offsetHeight"], m["isMaximized"]);
+ m["offsetHeight"], m["isMaximized"], m["isFullscreen"]);
} catch (e) {
debugPrintStack(
label:
@@ -1484,20 +1486,21 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
}
final pos = LastWindowPosition(
- sz.width, sz.height, position.dx, position.dy, isMaximized);
+ sz.width, sz.height, position.dx, position.dy, isMaximized, stateGlobal.fullscreen);
debugPrint(
- "Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}, isMaximized:${pos.isMaximized}");
+ "Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}, isMaximized:${pos.isMaximized}, isFullscreen:${pos.isFullscreen}");
await bind.setLocalFlutterOption(
k: kWindowPrefix + type.name, v: pos.toString());
if (type == WindowType.RemoteDesktop && windowId != null) {
- await _saveSessionWindowPosition(type, windowId, isMaximized, pos);
+ await _saveSessionWindowPosition(
+ type, windowId, isMaximized, stateGlobal.fullscreen, pos);
}
}
Future _saveSessionWindowPosition(WindowType windowType, int windowId,
- bool isMaximized, LastWindowPosition pos) async {
+ bool isMaximized, bool isFullscreen, LastWindowPosition pos) async {
final remoteList = await DesktopMultiWindow.invokeMethod(
windowId, kWindowEventGetRemoteList, null);
getPeerPos(String peerId) {
@@ -1510,7 +1513,8 @@ Future _saveSessionWindowPosition(WindowType windowType, int windowId,
lpos?.height ?? pos.offsetHeight,
lpos?.offsetWidth ?? pos.offsetWidth,
lpos?.offsetHeight ?? pos.offsetHeight,
- isMaximized)
+ isMaximized,
+ isFullscreen)
.toString();
} else {
return pos.toString();
@@ -1700,7 +1704,13 @@ Future<bool> restoreWindowPosition(WindowType type,
await wc.setFrame(frame);
}
}
- if (lpos.isMaximized == true) {
+ if (lpos.isFullscreen == true) {
+ await restoreFrame();
+ // An duration is needed to avoid the window being restored after fullscreen.
+ Future.delayed(Duration(milliseconds: 300), () async {
+ stateGlobal.setFullscreen(true);
+ });
+ } else if (lpos.isMaximized == true) {
await restoreFrame();
// An duration is needed to avoid the window being restored after maximized.
Future.delayed(Duration(milliseconds: 300), () async {