Reduces the IPC messages used for visibilityState
This commit is contained in:
parent
c3ac92b500
commit
07a4c52919
2 changed files with 29 additions and 57 deletions
|
@ -78,19 +78,23 @@ BrowserWindow.prototype._init = function () {
|
|||
app.emit('browser-window-focus', event, this)
|
||||
})
|
||||
|
||||
// Evented visibilityState changes
|
||||
this.on('show', () => {
|
||||
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
|
||||
})
|
||||
this.on('hide', () => {
|
||||
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
|
||||
})
|
||||
this.on('minimize', () => {
|
||||
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
|
||||
})
|
||||
this.on('restore', () => {
|
||||
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
|
||||
})
|
||||
// Subscribe to visibilityState changes and pass to renderer process.
|
||||
let isVisible = false
|
||||
let visibilityChanged = () => {
|
||||
let newState = this.isVisible() && !this.isMinimized()
|
||||
if (isVisible != newState) {
|
||||
isVisible = newState
|
||||
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', isVisible ? 'visible' : 'hidden')
|
||||
}
|
||||
}
|
||||
this.on('show', visibilityChanged)
|
||||
this.on('hide', visibilityChanged)
|
||||
this.on('minimize', visibilityChanged)
|
||||
this.on('restore', visibilityChanged)
|
||||
this.on('maximize', visibilityChanged)
|
||||
|
||||
// Make renderer process have correct initial state.
|
||||
visibilityChanged()
|
||||
|
||||
// Notify the creation of the window.
|
||||
app.emit('browser-window-created', {}, this)
|
||||
|
@ -105,6 +109,7 @@ BrowserWindow.prototype._init = function () {
|
|||
this.webContents.on('devtools-closed', () => {
|
||||
this.emit('devtools-closed')
|
||||
})
|
||||
|
||||
Object.defineProperty(this, 'devToolsWebContents', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
|
@ -195,37 +200,21 @@ BrowserWindow.prototype.inspectServiceWorker = function () {
|
|||
}
|
||||
|
||||
// Deprecated.
|
||||
|
||||
deprecate.member(BrowserWindow, 'undo', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'redo', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'cut', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'copy', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'paste', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'selectAll', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'reloadIgnoringCache', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'isLoading', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'isWaitingForResponse', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'stop', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'isCrashed', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'print', 'webContents')
|
||||
|
||||
deprecate.member(BrowserWindow, 'printToPDF', 'webContents')
|
||||
|
||||
deprecate.rename(BrowserWindow, 'restart', 'reload')
|
||||
|
||||
deprecate.rename(BrowserWindow, 'loadUrl', 'loadURL')
|
||||
|
||||
deprecate.rename(BrowserWindow, 'getUrl', 'getURL')
|
||||
|
||||
BrowserWindow.prototype.executeJavaScriptInDevTools = deprecate('executeJavaScriptInDevTools', 'devToolsWebContents.executeJavaScript', function (code) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue