2013-05-15 19:19:35 +08:00
|
|
|
EventEmitter = require('events').EventEmitter
|
2013-05-17 16:09:12 +08:00
|
|
|
v8Util = process.atomBinding 'v8_util'
|
2013-05-30 20:16:54 +08:00
|
|
|
objectsRegistry = require '../../atom/objects-registry.js'
|
2013-05-15 19:19:35 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
Window = process.atomBinding('window').Window
|
|
|
|
Window::__proto__ = EventEmitter.prototype
|
2013-05-17 16:09:12 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
module.exports = class BrowserWindow extends Window
|
|
|
|
constructor: ->
|
|
|
|
super
|
2013-05-15 19:19:35 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
toggleDevTools: ->
|
|
|
|
opened = v8Util.getHiddenValue this, 'devtoolsOpened'
|
|
|
|
if opened
|
|
|
|
@closeDevTools()
|
|
|
|
v8Util.setHiddenValue this, 'devtoolsOpened', false
|
|
|
|
else
|
|
|
|
@openDevTools()
|
|
|
|
v8Util.setHiddenValue this, 'devtoolsOpened', true
|
2013-05-28 16:01:44 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
restart: ->
|
|
|
|
@loadUrl @getUrl()
|
2013-05-16 23:00:43 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
@getFocusedWindow: ->
|
|
|
|
windows = objectsRegistry.getAllWindows()
|
|
|
|
return window for window in windows when window.isFocused()
|
2013-05-17 21:53:37 +08:00
|
|
|
|
2013-06-18 18:35:08 +08:00
|
|
|
@fromProcessIdAndRoutingId = (processId, routingId) ->
|
|
|
|
windows = objectsRegistry.getAllWindows()
|
|
|
|
return window for window in windows when window.getProcessId() == processId and
|
|
|
|
window.getRoutingId() == routingId
|