Use new IPC API of atom-shell.

This commit is contained in:
Cheng Zhao
2014-04-29 15:15:45 +08:00
parent a7b94e1709
commit f48241bc5e
5 changed files with 45 additions and 46 deletions

View File

@@ -191,7 +191,7 @@ class AtomApplication
@emit('application:new-window')
# A request from the associated render process to open a new render process.
ipc.on 'open', (processId, routingId, options) =>
ipc.on 'open', (event, options) =>
if options?
if options.pathsToOpen?.length > 0
@openPaths(options)
@@ -200,21 +200,21 @@ class AtomApplication
else
@promptForPath()
ipc.on 'update-application-menu', (processId, routingId, template, keystrokesByCommand) =>
ipc.on 'update-application-menu', (event, template, keystrokesByCommand) =>
@applicationMenu.update(template, keystrokesByCommand)
ipc.on 'run-package-specs', (processId, routingId, specDirectory) =>
ipc.on 'run-package-specs', (event, specDirectory) =>
@runSpecs({resourcePath: global.devResourcePath, specDirectory: specDirectory, exitWhenDone: false})
ipc.on 'command', (processId, routingId, command) =>
ipc.on 'command', (event, command) =>
@emit(command)
ipc.on 'window-command', (processId, routingId, command, args...) ->
win = BrowserWindow.fromProcessIdAndRoutingId(processId, routingId)
ipc.on 'window-command', (event, command, args...) ->
win = BrowserWindow.fromWebContents(event.sender)
win.emit(command, args...)
ipc.on 'call-window-method', (processId, routingId, method, args...) ->
win = BrowserWindow.fromProcessIdAndRoutingId(processId, routingId)
ipc.on 'call-window-method', (event, method, args...) ->
win = BrowserWindow.fromWebContents(event.sender)
win[method](args...)
# Public: Executes the given command.

View File

@@ -2,7 +2,6 @@ BrowserWindow = require 'browser-window'
ContextMenu = require './context-menu'
app = require 'app'
dialog = require 'dialog'
ipc = require 'ipc'
path = require 'path'
fs = require 'fs'
url = require 'url'
@@ -136,7 +135,7 @@ class AtomWindow
sendCommandToBrowserWindow: (command, args...) ->
action = if args[0]?.contextCommand then 'context-command' else 'command'
ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), action, command, args...
@browserWindow.webContents.send action, command, args...
getDimensions: ->
[x, y] = @browserWindow.getPosition()