Use ipc to store and retrieve windowState

I'll want to change the interface in the future. For now I am trying
to keep the code as simple and small as possible.
This commit is contained in:
probablycorey
2013-05-16 09:56:58 -07:00
parent f65a2826f2
commit ee12977a9f
2 changed files with 9 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ fsUtils = require 'fs-utils'
_ = require 'underscore'
Package = require 'package'
Theme = require 'theme'
ipc = require 'ipc'
window.atom =
exitWhenDone: window.location.params.exitWhenDone
@@ -244,7 +245,7 @@ window.atom =
setWindowState: (keyPath, value) ->
windowState = @getWindowState()
_.setValueForKeyPath(windowState, keyPath, value)
$native.setWindowState(JSON.stringify(windowState))
ipc.sendChannel('window-state', JSON.stringify(windowState))
windowState
getWindowState: (keyPath) ->
@@ -255,7 +256,7 @@ window.atom =
windowState
getInMemoryWindowState: ->
inMemoryState = $native.getWindowState()
inMemoryState = ipc.sendChannelSync('window-state')
if inMemoryState.length > 0
inMemoryState
else

View File

@@ -2,12 +2,18 @@ app = require 'app'
delegate = require 'atom_delegate'
path = require 'path'
BrowserWindow = require 'browser_window'
ipc = require 'ipc'
windowState = {}
# Quit when all windows are closed.
app.on 'window-all-closed', ->
app.quit()
ipc.on 'window-state', (event, processId, messageId, message) ->
windowState = message unless message == undefined
event.result = windowState
class AtomWindow
@windows = []