diff --git a/StabilityMatrix.Avalonia/App.axaml.cs b/StabilityMatrix.Avalonia/App.axaml.cs index ea643cb8..34ff5b7d 100644 --- a/StabilityMatrix.Avalonia/App.axaml.cs +++ b/StabilityMatrix.Avalonia/App.axaml.cs @@ -165,12 +165,16 @@ public sealed class App : Application mainWindow.Closing += (_, _) => { + var validWindowPosition = + mainWindow.Screens.All.Any(screen => screen.Bounds.Contains(mainWindow.Position)); + settingsManager.Transaction(s => - { - s.WindowSettings = new WindowSettings( - mainWindow.Width, mainWindow.Height, - mainWindow.Position.X, mainWindow.Position.Y); - }, ignoreMissingLibraryDir: true); + { + s.WindowSettings = new WindowSettings( + mainWindow.Width, mainWindow.Height, + validWindowPosition ? mainWindow.Position.X : 0, + validWindowPosition ? mainWindow.Position.Y : 0); + }, ignoreMissingLibraryDir: true); }; mainWindow.Closed += (_, _) => Shutdown();