Add BrowserWindow.fromProcessIdAndRoutingId API.

This commit is contained in:
Cheng Zhao 2013-05-17 21:53:37 +08:00
parent d356be9c54
commit 66c35e4517
2 changed files with 7 additions and 4 deletions

View file

@ -18,4 +18,9 @@ BrowserWindow.getFocusedWindow = ->
windows = objectsRegistry.getAllWindows() windows = objectsRegistry.getAllWindows()
return window for window in windows when window.isFocused() return window for window in windows when window.isFocused()
BrowserWindow.fromProcessIdAndRoutingId = (processId, routingId) ->
windows = objectsRegistry.getAllWindows()
return window for window in windows when window.getProcessId() == processId and
window.getRoutingId() == routingId
module.exports = BrowserWindow module.exports = BrowserWindow

View file

@ -68,10 +68,8 @@ ipc.on 'ATOM_BROWSER_RELEASE_RENDER_VIEW', (event, processId, routingId) ->
ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, processId, routingId) -> ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, processId, routingId) ->
try try
windows = objectsRegistry.getAllWindows() BrowserWindow = require 'browser_window'
for window in windows window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
break if window.getProcessId() == processId and
window.getRoutingId() == routingId
event.result = valueToMeta processId, routingId, window event.result = valueToMeta processId, routingId, window
catch e catch e
event.result = errorToMeta e event.result = errorToMeta e