refactor: rename TopLevelWindow to BaseWindow (#24305)

This commit is contained in:
Cheng Zhao 2020-06-29 16:06:20 +09:00 committed by GitHub
parent 80e5007c47
commit ef3579eae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 433 additions and 451 deletions

View file

@ -1,12 +1,12 @@
import { TopLevelWindow, WebContents, Event, BrowserView, TouchBar } from 'electron';
import { BaseWindow, WebContents, Event, BrowserView, TouchBar } from 'electron';
import type { BrowserWindow as BWT } from 'electron';
const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT };
Object.setPrototypeOf(BrowserWindow.prototype, TopLevelWindow.prototype);
Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype);
(BrowserWindow.prototype as any)._init = function (this: BWT) {
// Call parent class's _init.
(TopLevelWindow.prototype as any)._init.call(this);
(BaseWindow.prototype as any)._init.call(this);
// Avoid recursive require.
const { app } = require('electron');
@ -74,12 +74,12 @@ const isBrowserWindow = (win: any) => {
};
BrowserWindow.fromId = (id: number) => {
const win = TopLevelWindow.fromId(id);
const win = BaseWindow.fromId(id);
return isBrowserWindow(win) ? win as any as BWT : null;
};
BrowserWindow.getAllWindows = () => {
return TopLevelWindow.getAllWindows().filter(isBrowserWindow) as any[] as BWT[];
return BaseWindow.getAllWindows().filter(isBrowserWindow) as any[] as BWT[];
};
BrowserWindow.getFocusedWindow = () => {