Register visibility change listener when attached

This commit is contained in:
Kevin Sawicki 2017-02-22 14:15:20 -08:00
parent 2f5f7721fc
commit f4717b34e9

View file

@ -34,10 +34,10 @@ class WebViewImpl {
this.viewInstanceId = getNextId() this.viewInstanceId = getNextId()
shadowRoot.appendChild(this.browserPluginNode) shadowRoot.appendChild(this.browserPluginNode)
// Forward window visibility changes to guest contents
this.onVisibilityChanged = (event, visibilityState) => { this.onVisibilityChanged = (event, visibilityState) => {
this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState) this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState)
} }
ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged)
} }
createBrowserPluginNode () { createBrowserPluginNode () {
@ -315,6 +315,7 @@ var registerWebViewElement = function () {
return return
} }
if (!internal.elementAttached) { if (!internal.elementAttached) {
ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', internal.onVisibilityChanged)
guestViewInternal.registerEvents(internal, internal.viewInstanceId) guestViewInternal.registerEvents(internal, internal.viewInstanceId)
internal.elementAttached = true internal.elementAttached = true
instance = internal.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].getValue() instance = internal.attributes[webViewConstants.ATTRIBUTE_GUESTINSTANCE].getValue()