Set initial window size depending on screen size (#5845)

* set initial electron window size to be almost full screen with some space left

* refine initial window size and position

* slightly larger

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Andrew Varga
2025-03-18 20:39:04 +01:00
committed by GitHub
parent 44be072d04
commit cccb71fd30
8 changed files with 15 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import {
nativeTheme,
desktopCapturer,
systemPreferences,
screen,
} from 'electron'
import path from 'path'
import { Issuer } from 'openid-client'
@ -86,12 +87,24 @@ const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
newWindow = mainWindow
}
if (!newWindow) {
const primaryDisplay = screen.getPrimaryDisplay()
const { width, height } = primaryDisplay.workAreaSize
const windowWidth = Math.max(500, width - 150)
const windowHeight = Math.max(400, height - 100)
const x = primaryDisplay.workArea.x + Math.floor((width - windowWidth) / 2)
const y =
primaryDisplay.workArea.y + Math.floor((height - windowHeight) / 2)
newWindow = new BrowserWindow({
autoHideMenuBar: false,
show: false,
enableLargerThanScreen: true,
width: 1800,
height: 1200,
width: windowWidth,
height: windowHeight,
x,
y,
webPreferences: {
nodeIntegration: false, // do not give the application implicit system access
contextIsolation: true, // expose system functions in preload