win: Correctly close popup menu

This commit is contained in:
Cheng Zhao 2017-12-21 15:26:32 +09:00
parent 459db92052
commit 088042841d
3 changed files with 23 additions and 7 deletions

View file

@ -94,10 +94,13 @@ Menu.prototype.popup = function (window, x, y, positioningItem) {
}
Menu.prototype.closePopup = function (window) {
if (!window || window.constructor !== BrowserWindow) {
window = BrowserWindow.getFocusedWindow()
if (window && window.constructor !== BrowserWindow) {
this.closePopupAt(window.id)
} else {
// Passing -1 (invalid) would make closePopupAt close the all menu runners
// belong to this menu.
this.closePopupAt(-1)
}
if (window) this.closePopupAt(window.id)
}
Menu.prototype.getMenuItemById = function (id) {