Use SetTouchBar withe empty vector instead of DestroyTouchBar

This commit is contained in:
Kevin Sawicki 2017-03-01 11:05:34 -08:00
parent d5dbe3676e
commit 51f1c5a557
8 changed files with 11 additions and 25 deletions

View file

@ -199,20 +199,20 @@ Object.assign(BrowserWindow.prototype, {
// TouchBar API
setTouchBar (touchBar) {
// This property is set from within TouchBar
if (this._touchBar != null) {
this._touchBar._removeFromWindow(this)
}
if (touchBar == null) {
if (this._touchBar != null) {
this._touchBar._removeFromWindow(this)
}
this._destroyTouchBar()
this._setTouchBarItems([])
return
}
if (Array.isArray(touchBar)) {
touchBar = new TouchBar(touchBar)
}
this._touchBar = touchBar
this._touchBar._addToWindow(this)
touchBar._addToWindow(this)
}
})

View file

@ -38,6 +38,8 @@ class TouchBar extends EventEmitter {
// Already added to window
if (this.windowListeners.hasOwnProperty(id)) return
window._touchBar = this
const changeListener = (itemID) => {
window._refreshTouchBarItem(itemID)
}
@ -61,7 +63,7 @@ class TouchBar extends EventEmitter {
window.once('closed', removeListeners)
this.windowListeners[id] = removeListeners
window._setTouchBar(this.ordereredItems)
window._setTouchBarItems(this.ordereredItems)
}
// Called by BrowserWindow.setTouchBar