refactor: rename TopLevelWindow to BaseWindow (#24305)
This commit is contained in:
parent
80e5007c47
commit
ef3579eae3
21 changed files with 433 additions and 451 deletions
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const { TopLevelWindow, MenuItem, webContents } = require('electron');
|
||||
const { BaseWindow, MenuItem, webContents } = require('electron');
|
||||
const { sortMenuItems } = require('@electron/internal/browser/api/menu-utils');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||
|
@ -46,7 +46,7 @@ Menu.prototype._shouldRegisterAcceleratorForCommandId = function (id) {
|
|||
Menu.prototype._executeCommand = function (event, id) {
|
||||
const command = this.commandsMap[id];
|
||||
if (!command) return;
|
||||
command.click(event, TopLevelWindow.getFocusedWindow(), webContents.getFocusedWebContents());
|
||||
command.click(event, BaseWindow.getFocusedWindow(), webContents.getFocusedWebContents());
|
||||
};
|
||||
|
||||
Menu.prototype._menuWillShow = function () {
|
||||
|
@ -72,14 +72,14 @@ Menu.prototype.popup = function (options = {}) {
|
|||
if (typeof positioningItem !== 'number') positioningItem = -1;
|
||||
|
||||
// find which window to use
|
||||
const wins = TopLevelWindow.getAllWindows();
|
||||
const wins = BaseWindow.getAllWindows();
|
||||
if (!wins || wins.indexOf(window) === -1) {
|
||||
window = TopLevelWindow.getFocusedWindow();
|
||||
window = BaseWindow.getFocusedWindow();
|
||||
if (!window && wins && wins.length > 0) {
|
||||
window = wins[0];
|
||||
}
|
||||
if (!window) {
|
||||
throw new Error('Cannot open Menu without a TopLevelWindow present');
|
||||
throw new Error('Cannot open Menu without a BaseWindow present');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ Menu.prototype.popup = function (options = {}) {
|
|||
};
|
||||
|
||||
Menu.prototype.closePopup = function (window) {
|
||||
if (window instanceof TopLevelWindow) {
|
||||
if (window instanceof BaseWindow) {
|
||||
this.closePopupAt(window.id);
|
||||
} else {
|
||||
// Passing -1 (invalid) would make closePopupAt close the all menu runners
|
||||
|
@ -168,7 +168,7 @@ Menu.setApplicationMenu = function (menu) {
|
|||
menu._callMenuWillShow();
|
||||
bindings.setApplicationMenu(menu);
|
||||
} else {
|
||||
const windows = TopLevelWindow.getAllWindows();
|
||||
const windows = BaseWindow.getAllWindows();
|
||||
return windows.map(w => w.setMenu(menu));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue