Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
use shared memory for initial state transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Jul 14, 2017
1 parent d3f96bb commit e009588
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ window.addEventListener('beforeunload', function (e) {
ipc.send(messages.LAST_WINDOW_STATE, windowStore.getState().toJS())
})

ipc.on(messages.INITIALIZE_WINDOW, (e, windowValue, appState, frames, windowState) => {
ipc.on(messages.INITIALIZE_WINDOW, (e, mem) => {
const message = mem.memory()
const windowValue = message.windowValue

currentWindow.setWindowId(windowValue.id)
const newState = Immutable.fromJS(windowState) || windowStore.getState()
const newState = Immutable.fromJS(message.windowState) || windowStore.getState()

appStoreRenderer.state = Immutable.fromJS(appState)
appStoreRenderer.state = Immutable.fromJS(message.appState)
windowStore.state = newState
generateTabs(newState, frames, windowValue.id)
generateTabs(newState, message.frames, windowValue.id)
appActions.windowReady(windowValue.id)
ReactDOM.render(<Window />, document.getElementById('appContainer'))
})
Expand Down
11 changes: 7 additions & 4 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,17 @@ const createWindow = (action) => {
mainWindow.webContents.on('did-finish-load', (e) => {
lastEmittedState = appState
mainWindow.webContents.setZoomLevel(zoomLevel[toolbarUserInterfaceScale] || 0.0)
e.sender.send(messages.INITIALIZE_WINDOW,
{

const mem = muon.shared_memory.create({
windowValue: {
disposition: frameOpts.disposition,
id: mainWindow.id
},
appState.toJS(),
appState: appState.toJS(),
frames,
action.restoredState)
windowState: action.restoredState})

e.sender.sendShared(messages.INITIALIZE_WINDOW, mem)
if (action.cb) {
action.cb()
}
Expand Down

0 comments on commit e009588

Please sign in to comment.