#7455 Last window size improvements: fix full screen on windows (#7586)

* fix full screen size issue on windows

* createWindow() reuse param is not used
This commit is contained in:
Andrew Varga
2025-06-24 01:06:26 +02:00
committed by GitHub
parent 478bf34f2b
commit 1bb882acf8

View File

@ -102,13 +102,9 @@ if (!singleInstanceLock && !IS_PLAYWRIGHT) {
registerStartupListeners()
}
const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
const createWindow = (pathToOpen?: string): BrowserWindow => {
let newWindow: BrowserWindow | null = null
if (reuse) {
newWindow = mainWindow
Menu.setApplicationMenu(null)
}
if (!newWindow) {
const primaryDisplay = screen.getPrimaryDisplay()
const { width, height } = primaryDisplay.workAreaSize
@ -154,6 +150,10 @@ const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
titleBarStyle: 'hiddenInset',
backgroundColor: nativeTheme.shouldUseDarkColors ? '#1C1C1C' : '#FCFCFC',
})
// This is only needed on windows, but it doesn't do any harm on other platforms.
// On windows the initial width, height supplied above cannot be larger than screen resolution which causes
// some weird border to appear when the last window size was close to full screen.
newWindow.setBounds({ x, y, width: windowWidth, height: windowHeight })
}
newWindow.on('close', () => {
@ -239,9 +239,7 @@ const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
// Open the DevTools.
// mainWindow.webContents.openDevTools()
if (!reuse) {
if (!process.env.HEADLESS) newWindow.show()
}
if (!process.env.HEADLESS) newWindow.show()
return newWindow
}