remember the damn window position
Build check / build-windows (pull_request) Has been cancelled
Build check / build-linux (pull_request) Has been cancelled

This commit is contained in:
2026-07-29 23:46:54 -04:00
committed by Patrick Begley
parent 275166559a
commit 60cdad4e31
+14 -4
View File
@@ -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 createWindow = async () => {
const saved = // Always restore last geometry when it still intersects a display so the
Preferences.data.rememberPosition && // launcher stays on the monitor the user left it on.
isOnScreen(Preferences.data.windowPosition) const saved = isOnScreen(Preferences.data.windowPosition)
? Preferences.data.windowPosition ? Preferences.data.windowPosition
: undefined; : undefined;
const position = saved ?? { width: 1000, height: 700 }; const position = saved ?? centerOnPrimary(1000, 700);
const appIcon = loadAppIcon(); const appIcon = loadAppIcon();
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({