Request loadSettings.windowState via IPC messages.

This commit is contained in:
Cheng Zhao
2014-02-04 11:46:21 +08:00
parent 9680ad7bb5
commit 01876c4004
2 changed files with 14 additions and 3 deletions

View File

@@ -94,7 +94,14 @@ class Atom extends Model
# Private: Returns the load settings hash associated with the current window.
@getLoadSettings: ->
_.deepClone(@loadSettings ?= JSON.parse(decodeURIComponent(location.search.substr(14))))
@loadSettings ?= JSON.parse(decodeURIComponent(location.search.substr(14)))
cloned = _.deepClone(@loadSettings)
# The loadSettings.windowState could be large, request it only when needed.
cloned.__defineGetter__ 'windowState', =>
@getCurrentWindow().loadSettings.windowState
cloned.__defineSetter__ 'windowState', (value) =>
@getCurrentWindow().loadSettings.windowState = value
cloned
# Private:
@getCurrentWindow: ->

View File

@@ -55,12 +55,16 @@ class AtomWindow
process.env['NODE_PATH'] = path.resolve(resourcePath, 'exports')
getUrl: (loadSettingsObj) ->
loadSettings = JSON.stringify(loadSettingsObj)
# Ignore the windowState when passing loadSettings via URL, since it could
# be quite large.
loadSettings = _.clone(loadSettingsObj)
delete loadSettings['windowState']
url.format
protocol: 'file'
pathname: "#{@resourcePath}/static/index.html"
slashes: true
query: {loadSettings}
query: {loadSettings: JSON.stringify(loadSettings)}
getInitialPath: ->
@browserWindow.loadSettings.initialPath