refactor: simplify events (#37099)

This commit is contained in:
Jeremy Rose
2023-02-13 13:39:18 -08:00
committed by GitHub
parent 8b3e498436
commit 71944f2c3b
32 changed files with 290 additions and 409 deletions

View File

@@ -1,4 +1,4 @@
import { BaseWindow, WebContents, Event, BrowserView, TouchBar } from 'electron/main';
import { BaseWindow, WebContents, BrowserView, TouchBar } from 'electron/main';
import type { BrowserWindow as BWT } from 'electron/main';
import * as deprecate from '@electron/internal/common/deprecate';
const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT };
@@ -22,10 +22,10 @@ BrowserWindow.prototype._init = function (this: BWT) {
};
// Redirect focus/blur event to app instance too.
this.on('blur', (event: Event) => {
this.on('blur', (event: Electron.Event) => {
app.emit('browser-window-blur', event, this);
});
this.on('focus', (event: Event) => {
this.on('focus', (event: Electron.Event) => {
app.emit('browser-window-focus', event, this);
});
@@ -68,8 +68,7 @@ BrowserWindow.prototype._init = function (this: BWT) {
});
// Notify the creation of the window.
const event = process._linkedBinding('electron_browser_event').createEmpty();
app.emit('browser-window-created', event, this);
app.emit('browser-window-created', { preventDefault () {} }, this);
Object.defineProperty(this, 'devToolsWebContents', {
enumerable: true,