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

25 lines
675 B
JavaScript
Raw Normal View History

2019-02-06 20:27:58 +00:00
'use strict'
const electron = require('electron')
const { EventEmitter } = require('events')
const { TopLevelWindow } = process.atomBinding('top_level_window')
Object.setPrototypeOf(TopLevelWindow.prototype, EventEmitter.prototype)
TopLevelWindow.prototype._init = function () {
// Avoid recursive require.
const { app } = electron
// Simulate the application menu on platforms other than macOS.
if (process.platform !== 'darwin') {
const menu = app.getApplicationMenu()
if (menu) this.setMenu(menu)
}
}
TopLevelWindow.getFocusedWindow = () => {
return TopLevelWindow.getAllWindows().find((win) => win.isFocused())
}
module.exports = TopLevelWindow