mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Do not return TopLevelWindow in BrowserWindow.getAllWindows
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user