mirror of
https://github.com/atom/atom.git
synced 2026-02-17 10:01:25 -05:00
Allow spec window to store window state
It just stores window dimensions for now.
This commit is contained in:
@@ -218,20 +218,21 @@ window.atom =
|
||||
rootView?.open(path)
|
||||
|
||||
getWindowStatePath: ->
|
||||
shasum = crypto.createHash('sha1')
|
||||
shasum.update(@getPathToOpen())
|
||||
fsUtils.join(config.userStoragePath, shasum.digest('hex'))
|
||||
if not @getPathToOpen()
|
||||
'probably-a-spec-window'
|
||||
else
|
||||
shasum = crypto.createHash('sha1')
|
||||
shasum.update(@getPathToOpen())
|
||||
fsUtils.join(config.userStoragePath, shasum.digest('hex'))
|
||||
|
||||
setWindowState: (keyPath, value) ->
|
||||
return {} if not @getPathToOpen()
|
||||
|
||||
windowState = @getWindowState()
|
||||
_.setValueForKeyPath(windowState, keyPath, value)
|
||||
fsUtils.write(@getWindowStatePath(), JSON.stringify(windowState))
|
||||
windowState
|
||||
|
||||
getWindowState: (keyPath) ->
|
||||
return {} if not @getPathToOpen() or not fsUtils.exists(@getWindowStatePath())
|
||||
return {} unless fsUtils.exists(@getWindowStatePath())
|
||||
|
||||
windowState = JSON.parse(fsUtils.read(@getWindowStatePath()) or '{}')
|
||||
if keyPath
|
||||
|
||||
@@ -40,6 +40,7 @@ window.setUpEnvironment = ->
|
||||
dimensions = defaultWindowDimensions unless dimensions.width and dimensions.height
|
||||
window.setDimensions(dimensions)
|
||||
remote.getCurrentWindow().show()
|
||||
$(window).on 'unload', -> atom.setWindowState('dimensions', window.getDimensions())
|
||||
|
||||
# This method is only called when opening a real application window
|
||||
window.startEditorWindow = ->
|
||||
@@ -78,7 +79,6 @@ window.unloadEditorWindow = ->
|
||||
atom.setWindowState('project', project.serialize())
|
||||
atom.setWindowState('syntax', syntax.serialize())
|
||||
atom.setWindowState('rootView', rootView.serialize())
|
||||
atom.setWindowState('dimensions', window.getDimensions())
|
||||
atom.deactivatePackages()
|
||||
atom.setWindowState('packageStates', atom.packageStates)
|
||||
rootView.remove()
|
||||
|
||||
Reference in New Issue
Block a user