Skip to content

Commit

Permalink
[FIX]: remember if window is maximized (#3007)
Browse files Browse the repository at this point in the history
fix: remember if window is maximized
  • Loading branch information
imLinguin authored Aug 31, 2023
1 parent 6592810 commit c56dd78
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ async function initializeWindow(): Promise<BrowserWindow> {

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()
Expand Down
14 changes: 10 additions & 4 deletions src/backend/main_window.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WindowProps } from 'common/types'
import { BrowserWindow, screen } from 'electron'
import path from 'path'
import { configStore } from './constants'
Expand Down Expand Up @@ -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')) {
Expand All @@ -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,
Expand All @@ -66,5 +68,9 @@ export const createMainWindow = () => {
}
})

if (maximized) {
mainWindow.maximize()
}

return mainWindow
}
4 changes: 4 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,7 @@ export interface WineManagerUISettings {
}

export type DownloadManagerState = 'idle' | 'running' | 'paused' | 'stopped'

export interface WindowProps extends Electron.Rectangle {
maximized: boolean
}
5 changes: 3 additions & 2 deletions src/common/types/electron_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
WineManagerUISettings,
AppSettings,
WikiInfo,
GameInfo
GameInfo,
WindowProps
} from 'common/types'
import { UserData } from 'common/types/gog'
import { NileUserData } from './nile'
Expand All @@ -40,7 +41,7 @@ export interface StoreStructure {
gogdlLogFile: string
nileLogFile: string
}
'window-props': Electron.Rectangle
'window-props': WindowProps
settings: AppSettings
skipVcRuntime: boolean
}
Expand Down

0 comments on commit c56dd78

Please sign in to comment.