mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user