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

use shared memory for initial state transfer #9989

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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