Do not return TopLevelWindow in BrowserWindow.getAllWindows

This commit is contained in:
Cheng Zhao 2018-04-17 16:53:55 +09:00
parent e38f511737
commit 1340b17424
2 changed files with 14 additions and 7 deletions

View file

@ -128,6 +128,19 @@ BrowserWindow.prototype._init = function () {
})
}
const isBrowserWindow = (win) => {
return win && win.constructor.name === 'BrowserWindow'
}
BrowserWindow.fromId = (id) => {
const win = TopLevelWindow.fromId(id)
return isBrowserWindow(win) ? win : null
}
BrowserWindow.getAllWindows = () => {
return TopLevelWindow.getAllWindows().filter(isBrowserWindow)
}
BrowserWindow.getFocusedWindow = () => {
for (let window of BrowserWindow.getAllWindows()) {
if (window.isFocused() || window.isDevToolsFocused()) return window