diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index d4add81..daff037 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -13,6 +13,7 @@ import { MenuItemConstructorOptions, nativeImage, nativeTheme, + screen, Tray } from "electron"; import { rm } from "fs/promises"; @@ -278,7 +279,9 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions { height: height ?? DEFAULT_HEIGHT } as BrowserWindowConstructorOptions; - if (x != null && y != null) { + const storedDisplay = screen.getAllDisplays().find(display => display.id === State.store.displayid); + + if (x != null && y != null && storedDisplay) { options.x = x; options.y = y; } @@ -326,6 +329,7 @@ function initWindowBoundsListeners(win: BrowserWindow) { const saveBounds = () => { State.store.windowBounds = win.getBounds(); + State.store.displayid = screen.getDisplayMatching(State.store.windowBounds).id; }; win.on("resize", saveBounds); diff --git a/src/shared/settings.d.ts b/src/shared/settings.d.ts index 46c2253..9f4f3d1 100644 --- a/src/shared/settings.d.ts +++ b/src/shared/settings.d.ts @@ -37,6 +37,7 @@ export interface State { maximized?: boolean; minimized?: boolean; windowBounds?: Rectangle; + displayid: int; skippedUpdate?: string; firstLaunch?: boolean;