Do not return TopLevelWindow in BrowserWindow.getAllWindows
This commit is contained in:
parent
e38f511737
commit
1340b17424
2 changed files with 14 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue