Skip to content

Commit

Permalink
! Fix child window options due to breaking change in electron 14.x
Browse files Browse the repository at this point in the history
Breaking change:
electron/electron#28550
Child windows no longer inherit BrowserWindow construction options from their parents.
  • Loading branch information
PikachuEXE committed Oct 5, 2021
1 parent b500a96 commit 175139a
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/main/index.js
Expand Up @@ -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')
Expand All @@ -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
}
Expand Down

0 comments on commit 175139a

Please sign in to comment.