From 60cdad4e318e87c9c7a4103aa094d34e4216e133 Mon Sep 17 00:00:00 2001 From: octocontr Date: Wed, 29 Jul 2026 23:46:54 -0400 Subject: [PATCH] remember the damn window position --- src/main/index.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index ff93cfa..de13eb7 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -46,13 +46,23 @@ const isOnScreen = ( }); }; +const centerOnPrimary = (width: number, height: number) => { + const { x, y, width: dw, height: dh } = screen.getPrimaryDisplay().workArea; + return { + x: Math.round(x + (dw - width) / 2), + y: Math.round(y + (dh - height) / 2), + width, + height + }; +}; + const createWindow = async () => { - const saved = - Preferences.data.rememberPosition && - isOnScreen(Preferences.data.windowPosition) - ? Preferences.data.windowPosition - : undefined; - const position = saved ?? { width: 1000, height: 700 }; + // Always restore last geometry when it still intersects a display so the + // launcher stays on the monitor the user left it on. + const saved = isOnScreen(Preferences.data.windowPosition) + ? Preferences.data.windowPosition + : undefined; + const position = saved ?? centerOnPrimary(1000, 700); const appIcon = loadAppIcon(); mainWindow = new BrowserWindow({