From 1bb882acf8ce4b6eac35df8a23f1f16313c93fc7 Mon Sep 17 00:00:00 2001 From: Andrew Varga Date: Tue, 24 Jun 2025 01:06:26 +0200 Subject: [PATCH] #7455 Last window size improvements: fix full screen on windows (#7586) * fix full screen size issue on windows * createWindow() reuse param is not used --- src/main.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index e73f1a787..f7c30ad35 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 }