mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
fix window save pos, debug win
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
eb8b264b18
commit
5e9841e7ab
@ -1383,12 +1383,17 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
|
||||
return;
|
||||
}
|
||||
final position = frame.topLeft;
|
||||
if (position.dx < 0 || position.dy < 0) {
|
||||
debugPrint("Window $windowId is hidden, ignoring position restoration");
|
||||
return;
|
||||
}
|
||||
|
||||
final sz = frame.size;
|
||||
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}");
|
||||
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}");
|
||||
await bind.setLocalFlutterConfig(
|
||||
k: kWindowPrefix + type.name, v: pos.toString());
|
||||
break;
|
||||
@ -1864,10 +1869,7 @@ Future<void> onActiveWindowChanged() async {
|
||||
if (rustDeskWinManager.getActiveWindows().isEmpty) {
|
||||
// close all sub windows
|
||||
try {
|
||||
await Future.wait([
|
||||
saveWindowPosition(WindowType.Main),
|
||||
rustDeskWinManager.closeAllSubWindows()
|
||||
]);
|
||||
await rustDeskWinManager.closeAllSubWindows();
|
||||
} catch (err) {
|
||||
debugPrintStack(label: "$err");
|
||||
} finally {
|
||||
|
@ -478,6 +478,8 @@ class WindowActionPanel extends StatefulWidget {
|
||||
|
||||
class WindowActionPanelState extends State<WindowActionPanel>
|
||||
with MultiWindowListener, WindowListener {
|
||||
final _saveFrameDebounce = Debouncer(delay: Duration(seconds: 1));
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -537,6 +539,26 @@ class WindowActionPanelState extends State<WindowActionPanel>
|
||||
super.onWindowUnmaximize();
|
||||
}
|
||||
|
||||
_saveFrame() async {
|
||||
if (widget.tabType == DesktopTabType.main) {
|
||||
await saveWindowPosition(WindowType.Main);
|
||||
} else if (kWindowType != null && kWindowId != null) {
|
||||
await saveWindowPosition(kWindowType!, windowId: kWindowId);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowMoved() {
|
||||
_saveFrameDebounce.call(_saveFrame);
|
||||
super.onWindowMoved();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowResized() {
|
||||
_saveFrameDebounce.call(_saveFrame);
|
||||
super.onWindowMoved();
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowClose() async {
|
||||
// hide window on close
|
||||
|
Loading…
Reference in New Issue
Block a user