top-level-window.js 674 B

123456789101112131415161718192021222324
  1. 'use strict'
  2. const electron = require('electron')
  3. const { EventEmitter } = require('events')
  4. const { TopLevelWindow } = process.electronBinding('top_level_window')
  5. Object.setPrototypeOf(TopLevelWindow.prototype, EventEmitter.prototype)
  6. TopLevelWindow.prototype._init = function () {
  7. // Avoid recursive require.
  8. const { app } = electron
  9. // Simulate the application menu on platforms other than macOS.
  10. if (process.platform !== 'darwin') {
  11. const menu = app.applicationMenu
  12. if (menu) this.setMenu(menu)
  13. }
  14. }
  15. TopLevelWindow.getFocusedWindow = () => {
  16. return TopLevelWindow.getAllWindows().find((win) => win.isFocused())
  17. }
  18. module.exports = TopLevelWindow