2013-05-15 11:19:35 +00:00
|
|
|
EventEmitter = require('events').EventEmitter
|
2013-10-05 05:13:04 +00:00
|
|
|
app = require 'app'
|
2013-05-17 08:09:12 +00:00
|
|
|
v8Util = process.atomBinding 'v8_util'
|
2013-05-15 11:19:35 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
BrowserWindow = process.atomBinding('window').BrowserWindow
|
|
|
|
BrowserWindow::__proto__ = EventEmitter.prototype
|
2013-05-17 08:09:12 +00:00
|
|
|
|
2013-10-05 13:05:59 +00:00
|
|
|
BrowserWindow::_init = ->
|
|
|
|
# Simulate the application menu on platforms other than OS X.
|
|
|
|
if process.platform isnt 'darwin'
|
|
|
|
menu = app.getApplicationMenu()
|
|
|
|
@setMenu menu if menu?
|
|
|
|
|
2013-12-06 06:44:25 +00:00
|
|
|
# Tell the rpc server that a render view has been deleted and we need to
|
|
|
|
# release all objects owned by it.
|
2013-12-06 07:53:40 +00:00
|
|
|
@on 'render-view-deleted', (event, processId, routingId) ->
|
|
|
|
process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', processId, routingId
|
2013-12-06 06:44:25 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
BrowserWindow::toggleDevTools = ->
|
2013-11-05 02:32:45 +00:00
|
|
|
if @isDevToolsOpened() then @closeDevTools() else @openDevTools()
|
2013-05-15 11:19:35 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
BrowserWindow::restart = ->
|
|
|
|
@loadUrl(@getUrl())
|
2013-06-18 10:47:13 +00:00
|
|
|
|
2013-10-02 13:24:21 +00:00
|
|
|
BrowserWindow::setMenu = (menu) ->
|
|
|
|
throw new Error('BrowserWindow.setMenu is only available on Windows') unless process.platform is 'win32'
|
|
|
|
|
|
|
|
throw new TypeError('Invalid menu') unless menu?.constructor?.name is 'Menu'
|
|
|
|
|
|
|
|
@menu = menu # Keep a reference of menu in case of GC.
|
|
|
|
@menu.attachToWindow this
|
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
BrowserWindow.getFocusedWindow = ->
|
2013-10-05 05:13:04 +00:00
|
|
|
windows = app.getBrowserWindows()
|
2013-06-18 13:40:03 +00:00
|
|
|
return window for window in windows when window.isFocused()
|
2013-05-28 08:01:44 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) ->
|
2013-10-05 05:13:04 +00:00
|
|
|
windows = app.getBrowserWindows()
|
2013-06-18 13:40:03 +00:00
|
|
|
return window for window in windows when window.getProcessId() == processId and
|
|
|
|
window.getRoutingId() == routingId
|
2013-05-16 15:00:43 +00:00
|
|
|
|
2013-06-18 13:40:03 +00:00
|
|
|
module.exports = BrowserWindow
|