fix, window save pos, debug
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
5e9841e7ab
commit
b7123c5be8
@ -1363,15 +1363,19 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
|||||||
debugPrint(
|
debugPrint(
|
||||||
"Error: windowId cannot be null when saving positions for sub window");
|
"Error: windowId cannot be null when saving positions for sub window");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
late Offset position;
|
||||||
|
late Size sz;
|
||||||
|
late bool isMaximized;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WindowType.Main:
|
case WindowType.Main:
|
||||||
final position = await windowManager.getPosition();
|
position = await windowManager.getPosition();
|
||||||
final sz = await windowManager.getSize();
|
if (position.dx < 0 || position.dy < 0) {
|
||||||
final isMaximized = await windowManager.isMaximized();
|
debugPrint("Main window is hidden, ignoring position restoration");
|
||||||
final pos = LastWindowPosition(
|
return;
|
||||||
sz.width, sz.height, position.dx, position.dy, isMaximized);
|
}
|
||||||
await bind.setLocalFlutterConfig(
|
sz = await windowManager.getSize();
|
||||||
k: kWindowPrefix + type.name, v: pos.toString());
|
isMaximized = await windowManager.isMaximized();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
final wc = WindowController.fromWindowId(windowId!);
|
final wc = WindowController.fromWindowId(windowId!);
|
||||||
@ -1382,22 +1386,22 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
|||||||
debugPrint("Failed to get frame of window $windowId, it may be hidden");
|
debugPrint("Failed to get frame of window $windowId, it may be hidden");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final position = frame.topLeft;
|
position = frame.topLeft;
|
||||||
if (position.dx < 0 || position.dy < 0) {
|
if (position.dx < 0 || position.dy < 0) {
|
||||||
debugPrint("Window $windowId is hidden, ignoring position restoration");
|
debugPrint("Window $windowId is hidden, ignoring position restoration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
sz = frame.size;
|
||||||
final sz = frame.size;
|
isMaximized = await wc.isMaximized();
|
||||||
final isMaximized = await wc.isMaximized();
|
|
||||||
final pos = LastWindowPosition(
|
|
||||||
sz.width, sz.height, position.dx, position.dy, isMaximized);
|
|
||||||
debugPrint(
|
|
||||||
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}");
|
|
||||||
await bind.setLocalFlutterConfig(
|
|
||||||
k: kWindowPrefix + type.name, v: pos.toString());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final pos = LastWindowPosition(
|
||||||
|
sz.width, sz.height, position.dx, position.dy, isMaximized);
|
||||||
|
debugPrint(
|
||||||
|
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}");
|
||||||
|
await bind.setLocalFlutterConfig(
|
||||||
|
k: kWindowPrefix + type.name, v: pos.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Size> _adjustRestoreMainWindowSize(double? width, double? height) async {
|
Future<Size> _adjustRestoreMainWindowSize(double? width, double? height) async {
|
||||||
@ -1869,7 +1873,14 @@ Future<void> onActiveWindowChanged() async {
|
|||||||
if (rustDeskWinManager.getActiveWindows().isEmpty) {
|
if (rustDeskWinManager.getActiveWindows().isEmpty) {
|
||||||
// close all sub windows
|
// close all sub windows
|
||||||
try {
|
try {
|
||||||
await rustDeskWinManager.closeAllSubWindows();
|
if (Platform.isLinux) {
|
||||||
|
await Future.wait([
|
||||||
|
saveWindowPosition(WindowType.Main),
|
||||||
|
rustDeskWinManager.closeAllSubWindows()
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
await rustDeskWinManager.closeAllSubWindows();
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugPrintStack(label: "$err");
|
debugPrintStack(label: "$err");
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user