Serialize window dimensions

This commit is contained in:
probablycorey
2013-05-21 14:33:45 -07:00
parent f65fbdf7ae
commit d4b146d080
2 changed files with 14 additions and 1 deletions

View File

@@ -78,6 +78,7 @@ 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()
@@ -153,6 +154,7 @@ window.deserializeEditorWindow = ->
atom.packageStates = windowState.packageStates ? {}
window.project = deserialize(windowState.project) ? new Project(pathToOpen)
window.rootView = deserialize(windowState.rootView) ? new RootView
window.setDimensions(windowState.dimensions ? defaultWindowDimensions)
if !windowState.rootView and (!pathToOpen or fsUtils.isFile(pathToOpen))
rootView.open(pathToOpen)
@@ -222,6 +224,17 @@ window.applyStylesheet = (id, text, ttype = 'bundled') ->
else
$("head").append "<style class='#{ttype}' id='#{id}'>#{text}</style>"
window.getDimensions = ->
browserWindow = remote.getCurrentWindow()
[x, y] = browserWindow.getPosition()
[width, height] = browserWindow.getSize()
{x, y, width, height}
window.setDimensions = ({x, y, width, height}) ->
browserWindow = remote.getCurrentWindow()
browserWindow.setPosition(x, y)
browserWindow.setSize(width, height)
window.closeWithoutConfirm = ->
ipc.sendChannel 'close-without-confirm'

View File

@@ -144,7 +144,7 @@ class AtomWindow
browserWindow: null
constructor: ({bootstrapScript, resourcePath, pathToOpen}) ->
@browserWindow = new BrowserWindow width: 800, height: 600, show: false, title: 'Atom'
@browserWindow = new BrowserWindow show: false, title: 'Atom'
@handleEvents()
url = "file://#{resourcePath}/static/index.html?bootstrapScript=#{bootstrapScript}&resourcePath=#{resourcePath}"