mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
35 lines
1.1 KiB
CoffeeScript
35 lines
1.1 KiB
CoffeeScript
BrowserWindow = require 'browser_window'
|
|
ipc = require 'ipc'
|
|
|
|
module.exports =
|
|
class AtomWindow
|
|
browserWindow: null
|
|
|
|
constructor: ({bootstrapScript, resourcePath, pathToOpen, exitWhenDone, @isSpec}) ->
|
|
require('atom-application').addWindow(this)
|
|
|
|
@browserWindow = new BrowserWindow show: false, title: 'Atom'
|
|
@handleEvents()
|
|
|
|
url = "file://#{resourcePath}/static/index.html?bootstrapScript=#{bootstrapScript}&resourcePath=#{resourcePath}"
|
|
url += "&pathToOpen=#{pathToOpen}" if pathToOpen
|
|
url += '&exitWhenDone=1' if exitWhenDone
|
|
|
|
@browserWindow.loadUrl url
|
|
|
|
handleEvents: ->
|
|
@browserWindow.on 'destroyed', =>
|
|
require('atom-application').removeWindow(this)
|
|
|
|
if @isSpec
|
|
# Spec window's web view should always have focus
|
|
@browserWindow.on 'blur', =>
|
|
@browserWindow.focusOnWebView()
|
|
else
|
|
@browserWindow.on 'close', (event) =>
|
|
event.preventDefault()
|
|
@sendCommand 'window:close'
|
|
|
|
sendCommand: (command) ->
|
|
ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), 'command', command
|