Fix Linux crash when config has large window dimensions
This commit is contained in:
parent
6503a0aad6
commit
31d9b8b353
1 changed files with 12 additions and 3 deletions
15
app/main.ts
15
app/main.ts
|
@ -673,10 +673,19 @@ async function createWindow() {
|
|||
const usePreloadBundle =
|
||||
!isTestEnvironment(getEnvironment()) || forcePreloadBundle;
|
||||
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width: maxWidth, height: maxHeight } = primaryDisplay.workAreaSize;
|
||||
const width = windowConfig
|
||||
? Math.min(windowConfig.width, maxWidth)
|
||||
: DEFAULT_WIDTH;
|
||||
const height = windowConfig
|
||||
? Math.min(windowConfig.height, maxHeight)
|
||||
: DEFAULT_HEIGHT;
|
||||
|
||||
const windowOptions: Electron.BrowserWindowConstructorOptions = {
|
||||
show: false,
|
||||
width: DEFAULT_WIDTH,
|
||||
height: DEFAULT_HEIGHT,
|
||||
width,
|
||||
height,
|
||||
minWidth: MIN_WIDTH,
|
||||
minHeight: MIN_HEIGHT,
|
||||
autoHideMenuBar: false,
|
||||
|
@ -701,7 +710,7 @@ async function createWindow() {
|
|||
disableBlinkFeatures: 'Accelerated2dCanvas,AcceleratedSmallCanvases',
|
||||
},
|
||||
icon: windowIcon,
|
||||
...pick(windowConfig, ['autoHideMenuBar', 'width', 'height', 'x', 'y']),
|
||||
...pick(windowConfig, ['autoHideMenuBar', 'x', 'y']),
|
||||
};
|
||||
|
||||
if (!isNumber(windowOptions.width) || windowOptions.width < MIN_WIDTH) {
|
||||
|
|
Loading…
Add table
Reference in a new issue