asarfuckery/electronasar/ptb/browser/api/top-level-window.js

20 lines
712 B
JavaScript
Raw Normal View History

2019-10-01 13:49:56 +00:00
'use strict';
const electron = require('electron');
const { EventEmitter } = require('events');
const { TopLevelWindow } = process.electronBinding('top_level_window');
Object.setPrototypeOf(TopLevelWindow.prototype, EventEmitter.prototype);
2019-01-17 18:22:05 +00:00
TopLevelWindow.prototype._init = function () {
2019-10-01 13:49:56 +00:00
// Avoid recursive require.
const { app } = electron;
// Simulate the application menu on platforms other than macOS.
if (process.platform !== 'darwin') {
const menu = app.applicationMenu;
if (menu)
this.setMenu(menu);
}
};
2019-01-17 18:22:05 +00:00
TopLevelWindow.getFocusedWindow = () => {
2019-10-01 13:49:56 +00:00
return TopLevelWindow.getAllWindows().find((win) => win.isFocused());
};
module.exports = TopLevelWindow;