diff --git a/desktop/src/main.ts b/desktop/src/main.ts index d733ce69e6..f0f38fbf2d 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -233,6 +233,15 @@ const windowRect = () => { // return undefined; }; +/** + * Sibling of {@link windowRect}, see that function's documentation for more + * details. + */ +const saveWindowRect = (window: BrowserWindow) => { + if (window.isMaximized()) userPreferences.delete("windowRect"); + else userPreferences.set("windowRect", window.getBounds()); +}; + /** * On Linux the app does not show a dock icon by default, attempt to fix this by * returning the path to an icon as the "icon" property that can be passed to @@ -515,7 +524,10 @@ const main = () => { // app, e.g. by clicking on its dock icon. app.on("activate", () => mainWindow?.show()); - app.on("before-quit", allowWindowClose); + app.on("before-quit", () => { + if (mainWindow) saveWindowRect(mainWindow); + allowWindowClose(); + }); }; main();