diff --git a/src/backend/main.ts b/src/backend/main.ts index d6fe44c8f4..7ce9bd4dba 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -200,7 +200,10 @@ async function initializeWindow(): Promise { if (!isCLIFullscreen && !isSteamDeckGameMode) { // store windows properties - configStore.set('window-props', mainWindow.getBounds()) + configStore.set('window-props', { + ...mainWindow.getBounds(), + maximized: mainWindow.isMaximized() + }) } const { exitToTray } = GlobalConfig.get().getSettings() diff --git a/src/backend/main_window.ts b/src/backend/main_window.ts index d33a33c49f..cab2385891 100644 --- a/src/backend/main_window.ts +++ b/src/backend/main_window.ts @@ -1,3 +1,4 @@ +import { WindowProps } from 'common/types' import { BrowserWindow, screen } from 'electron' import path from 'path' import { configStore } from './constants' @@ -28,11 +29,12 @@ export const sendFrontendMessage = (message: string, ...payload: unknown[]) => { // creates the mainWindow based on the configuration export const createMainWindow = () => { - let windowProps: Electron.Rectangle = { + let windowProps: WindowProps = { height: 690, width: 1200, x: 0, - y: 0 + y: 0, + maximized: false } if (configStore.has('window-props')) { @@ -49,10 +51,10 @@ export const createMainWindow = () => { windowProps.width = screenInfo.workAreaSize.width * 0.8 } } - + const { maximized, ...props } = windowProps // Create the browser window. mainWindow = new BrowserWindow({ - ...windowProps, + ...props, minHeight: 345, minWidth: 600, show: false, @@ -66,5 +68,9 @@ export const createMainWindow = () => { } }) + if (maximized) { + mainWindow.maximize() + } + return mainWindow } diff --git a/src/common/types.ts b/src/common/types.ts index d29ef02856..8009b6c2f6 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -690,3 +690,7 @@ export interface WineManagerUISettings { } export type DownloadManagerState = 'idle' | 'running' | 'paused' | 'stopped' + +export interface WindowProps extends Electron.Rectangle { + maximized: boolean +} diff --git a/src/common/types/electron_store.ts b/src/common/types/electron_store.ts index 5f26fe1d36..a1aa33251c 100644 --- a/src/common/types/electron_store.ts +++ b/src/common/types/electron_store.ts @@ -13,7 +13,8 @@ import { WineManagerUISettings, AppSettings, WikiInfo, - GameInfo + GameInfo, + WindowProps } from 'common/types' import { UserData } from 'common/types/gog' import { NileUserData } from './nile' @@ -40,7 +41,7 @@ export interface StoreStructure { gogdlLogFile: string nileLogFile: string } - 'window-props': Electron.Rectangle + 'window-props': WindowProps settings: AppSettings skipVcRuntime: boolean }