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
|
@ -438,14 +438,8 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
BrowserWindow::BuildPrototype(isolate, templ);
|
||||
|
||||
mate::Dictionary browser_window(isolate, templ->GetFunction());
|
||||
browser_window.SetMethod(
|
||||
"fromId", &mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
|
||||
browser_window.SetMethod("getAllWindows",
|
||||
&mate::TrackableObject<TopLevelWindow>::GetAll);
|
||||
|
||||
mate::Dictionary dict(isolate, exports);
|
||||
dict.Set("BrowserWindow", browser_window);
|
||||
dict.Set("BrowserWindow", templ->GetFunction());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -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
Reference in a new issue