The swiss army knife of lossless video/audio editing
store whether window is maximized
Mikael Finstad251024ba840c
diff --git a/src/main/index.ts b/src/main/index.tsindex fd3daa9b..cd486af1 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -112,7 +112,7 @@ async function sendApiAction(action: string, args?: unknown[]) {}// https://github.com/electron/electron/issues/526#issuecomment-563010533-function getSizeOptions() {+function getSavedBounds() {const bounds = configStore.get('windowBounds');const options: BrowserWindowConstructorOptions = {};if (bounds) {@@ -133,7 +133,10 @@ function getSizeOptions() {options.height = bounds.height;}}- return options;+ return {+ options,+ isMaximized: bounds != null ? bounds.isMaximized : false,+ };}function createWindow() {@@ -142,8 +145,10 @@ function createWindow() {// https://www.electronjs.org/docs/latest/tutorial/dark-modeif (darkMode) nativeTheme.themeSource = 'dark';+ const savedBounds = getSavedBounds();+mainWindow = new BrowserWindow({- ...getSizeOptions(),+ ...savedBounds.options,darkTheme: true,webPreferences: {contextIsolation: false,@@ -154,6 +159,8 @@ function createWindow() {backgroundColor: darkMode ? '#333' : '#fff',});+ if (savedBounds.isMaximized) mainWindow.maximize();+remote.enable(mainWindow.webContents);attachContextMenu(mainWindow);@@ -189,12 +196,16 @@ function createWindow() {}});+ // TODO replace with `windowStatePersistence` in the future? https://github.com/electron/rfcs/pull/16const debouncedSaveWindowState = debounce(() => {if (!mainWindow || !configStore.get('storeWindowBounds')) return;const { x, y, width, height } = mainWindow.getNormalBounds();- configStore.set('windowBounds', { x, y, width, height });+ const isMaximized = mainWindow.isMaximized();+ configStore.set('windowBounds', { x, y, width, height, isMaximized });}, 500);+ mainWindow.on('maximize', debouncedSaveWindowState);+ mainWindow.on('unmaximize', debouncedSaveWindowState);mainWindow.on('resize', debouncedSaveWindowState);mainWindow.on('move', debouncedSaveWindowState);}diff --git a/types.ts b/types.tsindex ba2aed0f..13fce5bf 100644--- a/types.ts+++ b/types.ts@@ -90,7 +90,7 @@ export interface Config {treatOutputFileModifiedTimeAsStart: boolean | undefined | null,outFormatLocked: string | undefined,safeOutputFileName: boolean,- windowBounds: { x: number, y: number, width: number, height: number } | undefined,+ windowBounds: { x: number, y: number, width: number, height: number, isMaximized?: boolean } | undefined,storeWindowBounds: boolean,enableAutoHtml5ify: boolean,keyBindings: KeyBinding[],