Correctly set initial visibilityState

This commit is contained in:
Cheng Zhao 2016-04-13 22:56:11 +09:00
parent 07a4c52919
commit 43c44da50b
8 changed files with 37 additions and 17 deletions

View file

@ -79,7 +79,7 @@ BrowserWindow.prototype._init = function () {
})
// Subscribe to visibilityState changes and pass to renderer process.
let isVisible = false
let isVisible = this.isVisible() && !this.isMinimized()
let visibilityChanged = () => {
let newState = this.isVisible() && !this.isMinimized()
if (isVisible != newState) {
@ -94,7 +94,8 @@ BrowserWindow.prototype._init = function () {
this.on('maximize', visibilityChanged)
// Make renderer process have correct initial state.
visibilityChanged()
if (!isVisible)
this.webContents.mergeWebPreferences({visibilityState: 'hidden'})
// Notify the creation of the window.
app.emit('browser-window-created', {}, this)