Fix Linux crash when config has large window dimensions
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
parent
2179577636
commit
1f8f6af6a8
1 changed files with 12 additions and 3 deletions
15
app/main.ts
15
app/main.ts
|
@ -672,10 +672,19 @@ async function createWindow() {
|
||||||
const usePreloadBundle =
|
const usePreloadBundle =
|
||||||
!isTestEnvironment(getEnvironment()) || forcePreloadBundle;
|
!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 = {
|
const windowOptions: Electron.BrowserWindowConstructorOptions = {
|
||||||
show: false,
|
show: false,
|
||||||
width: DEFAULT_WIDTH,
|
width,
|
||||||
height: DEFAULT_HEIGHT,
|
height,
|
||||||
minWidth: MIN_WIDTH,
|
minWidth: MIN_WIDTH,
|
||||||
minHeight: MIN_HEIGHT,
|
minHeight: MIN_HEIGHT,
|
||||||
autoHideMenuBar: false,
|
autoHideMenuBar: false,
|
||||||
|
@ -700,7 +709,7 @@ async function createWindow() {
|
||||||
disableBlinkFeatures: 'Accelerated2dCanvas,AcceleratedSmallCanvases',
|
disableBlinkFeatures: 'Accelerated2dCanvas,AcceleratedSmallCanvases',
|
||||||
},
|
},
|
||||||
icon: windowIcon,
|
icon: windowIcon,
|
||||||
...pick(windowConfig, ['autoHideMenuBar', 'width', 'height', 'x', 'y']),
|
...pick(windowConfig, ['autoHideMenuBar', 'x', 'y']),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isNumber(windowOptions.width) || windowOptions.width < MIN_WIDTH) {
|
if (!isNumber(windowOptions.width) || windowOptions.width < MIN_WIDTH) {
|
||||||
|
|
Loading…
Reference in a new issue