electron/lib/browser/api/top-level-window.js

25 lines
686 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
'use strict';
2018-04-17 07:29:16 +00:00
2020-03-20 20:28:31 +00:00
const electron = require('electron');
const { EventEmitter } = require('events');
const { TopLevelWindow } = process.electronBinding('top_level_window');
2018-04-17 07:29:16 +00:00
2020-03-20 20:28:31 +00:00
Object.setPrototypeOf(TopLevelWindow.prototype, EventEmitter.prototype);
2018-04-17 07:29:16 +00:00
TopLevelWindow.prototype._init = function () {
// Avoid recursive require.
2020-03-20 20:28:31 +00:00
const { app } = electron;
// Simulate the application menu on platforms other than macOS.
if (process.platform !== 'darwin') {
2020-03-20 20:28:31 +00:00
const menu = app.applicationMenu;
if (menu) this.setMenu(menu);
}
2020-03-20 20:28:31 +00:00
};
2018-04-17 08:14:49 +00:00
TopLevelWindow.getFocusedWindow = () => {
2020-03-20 20:28:31 +00:00
return TopLevelWindow.getAllWindows().find((win) => win.isFocused());
};
2018-04-17 08:14:49 +00:00
2020-03-20 20:28:31 +00:00
module.exports = TopLevelWindow;