diff --git a/src/main/index.js b/src/main/index.js index ac6d54f06d17..849f12c58592 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -180,7 +180,7 @@ function runApp() { /** * Initial window options */ - const newWindow = new BrowserWindow({ + const commonBrowserWindowOptions = { backgroundColor: '#212121', icon: isDev ? path.join(__dirname, '../../_icons/iconColor.png') @@ -194,10 +194,36 @@ function runApp() { webSecurity: false, backgroundThrottling: false, contextIsolation: false - }, - show: false + } + } + const newWindow = new BrowserWindow( + Object.assign( + { + // It will be shown later when ready via `ready-to-show` event + show: false + }, + commonBrowserWindowOptions + ) + ) + + // region Ensure child windows use same options since electron 14 + + // https://github.com/electron/electron/blob/14-x-y/docs/api/window-open.md#native-window-example + newWindow.webContents.setWindowOpenHandler(() => { + return { + action: 'allow', + overrideBrowserWindowOptions: Object.assign( + { + // It should be visible on click + show: true + }, + commonBrowserWindowOptions + ) + } }) + // endregion Ensure child windows use same options since electron 14 + if (replaceMainWindow) { mainWindow = newWindow }