Ensure window stays on screen after external monitor removed.

This commit is contained in:
Patrick FIc
2025-05-15 15:19:15 -07:00
parent cd5ddc4fa1
commit eab52bf8c1
4 changed files with 118 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ import {
isKeepAliveTaskInstalled,
setupKeepAliveTask,
} from "./setup-keep-alive-task";
import ensureWindowOnScreen from "./util/ensureWindowOnScreen";
Sentry.init({
dsn: "https://ba41d22656999a8c1fd63bcb7df98650@o492140.ingest.us.sentry.io/4509074139447296",
@@ -56,11 +57,14 @@ function createWindow(): void {
y: number | undefined;
};
// Validate window position is on screen
const { validX, validY } = ensureWindowOnScreen(x, y, width, height);
const mainWindow = new BrowserWindow({
width,
height,
x,
y,
x: validX,
y: validY,
show: false, // Start hidden, show later if not keep-alive
minWidth: 600,
minHeight: 400,