Get rid of the ugly ATOM_BROWSER_INTERNAL_NEW message.
This commit is contained in:
parent
cfca12d4a5
commit
d3f33152d0
7 changed files with 29 additions and 37 deletions
|
@ -1,16 +1,27 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
IDWeakMap = require 'id-weak-map'
|
||||
app = require 'app'
|
||||
v8Util = process.atomBinding 'v8_util'
|
||||
|
||||
BrowserWindow = process.atomBinding('window').BrowserWindow
|
||||
BrowserWindow::__proto__ = EventEmitter.prototype
|
||||
|
||||
# Store all created windows in the weak map.
|
||||
BrowserWindow.windows = new IDWeakMap
|
||||
|
||||
BrowserWindow::_init = ->
|
||||
# Simulate the application menu on platforms other than OS X.
|
||||
if process.platform isnt 'darwin'
|
||||
menu = app.getApplicationMenu()
|
||||
@setMenu menu if menu?
|
||||
|
||||
# Remember the window.
|
||||
id = BrowserWindow.windows.add this
|
||||
|
||||
# Remove the window from weak map immediately when it's destroyed, since we
|
||||
# could be iterating windows before GC happended.
|
||||
@once 'destroyed', ->
|
||||
BrowserWindow.windows.remove id if BrowserWindow.windows.has id
|
||||
|
||||
# Tell the rpc server that a render view has been deleted and we need to
|
||||
# release all objects owned by it.
|
||||
@on 'render-view-deleted', (event, processId, routingId) ->
|
||||
|
@ -30,12 +41,16 @@ BrowserWindow::setMenu = (menu) ->
|
|||
@menu = menu # Keep a reference of menu in case of GC.
|
||||
@menu.attachToWindow this
|
||||
|
||||
BrowserWindow.getAllWindows = ->
|
||||
windows = BrowserWindow.windows
|
||||
windows.get key for key in windows.keys()
|
||||
|
||||
BrowserWindow.getFocusedWindow = ->
|
||||
windows = app.getBrowserWindows()
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
return window for window in windows when window.isFocused()
|
||||
|
||||
BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) ->
|
||||
windows = app.getBrowserWindows()
|
||||
windows = BrowserWindow.getAllWindows()
|
||||
return window for window in windows when window.getProcessId() == processId and
|
||||
window.getRoutingId() == routingId
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue