mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-07 14:01:28 +03:00
fix: Center the main window on first run. (#13003)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -1949,8 +1949,24 @@ Future<bool> restoreWindowPosition(WindowType type,
|
|||||||
|
|
||||||
var lpos = LastWindowPosition.loadFromString(pos);
|
var lpos = LastWindowPosition.loadFromString(pos);
|
||||||
if (lpos == null) {
|
if (lpos == null) {
|
||||||
debugPrint("no window position saved, ignoring position restoration");
|
debugPrint("No window position saved, trying to center the window.");
|
||||||
return false;
|
switch (type) {
|
||||||
|
case WindowType.Main:
|
||||||
|
// Center the main window only if no position is saved (on first run).
|
||||||
|
if (isWindows || isLinux) {
|
||||||
|
await windowManager.center();
|
||||||
|
}
|
||||||
|
// For MacOS, the window is already centered by default.
|
||||||
|
// See https://github.com/rustdesk/rustdesk/blob/9b9276e7524523d7f667fefcd0694d981443df0e/flutter/macos/Runner/Base.lproj/MainMenu.xib#L333
|
||||||
|
// If `<windowPositionMask>` in `<window>` is not set, the window will be centered.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// No need to change the position of a sub window if no position is saved,
|
||||||
|
// since the default position is already centered.
|
||||||
|
// https://github.com/rustdesk/rustdesk/blob/317639169359936f7f9f85ef445ec9774218772d/flutter/lib/utils/multi_window_manager.dart#L163
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (type == WindowType.RemoteDesktop || type == WindowType.ViewCamera) {
|
if (type == WindowType.RemoteDesktop || type == WindowType.ViewCamera) {
|
||||||
if (!isRemotePeerPos && windowId != null) {
|
if (!isRemotePeerPos && windowId != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user