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

Commit

Permalink
Merge pull request #10580 from NejcZdovc/feature/#10473-zindex
Browse files Browse the repository at this point in the history
Windows are restored with the correct z-index
  • Loading branch information
cezaraugusto authored Sep 22, 2017
2 parents e05d815 + 2f0dcfb commit 843d9b3
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 11 deletions.
13 changes: 11 additions & 2 deletions app/browser/reducers/windowsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,23 @@ const createWindow = (state, action) => {
const appStore = require('../../../js/stores/appStore')
win.webContents.setZoomLevel(zoomLevel[toolbarUserInterfaceScale] || 0.0)

const position = win.getPosition()
const size = win.getSize()

const mem = muon.shared_memory.create({
windowValue: {
disposition: frameOpts.disposition,
id: win.id
id: win.id,
focused: win.isFocused(),
left: position[0],
top: position[1],
height: size[1],
width: size[0]
},
appState: appStore.getLastEmittedState().toJS(),
frames: frames.toJS(),
windowState: (restoredImmutableWindowState && restoredImmutableWindowState.toJS()) || undefined})
windowState: (restoredImmutableWindowState && restoredImmutableWindowState.toJS()) || undefined
})

e.sender.sendShared(messages.INITIALIZE_WINDOW, mem)
if (action.cb) {
Expand Down
1 change: 0 additions & 1 deletion app/browser/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ const api = {
LocalShortcuts.register(win)

appActions.windowCreated(windowValue)
windowActions.onWindowUpdate(windowId, windowValue)
})
win.once('closed', () => {
})
Expand Down
20 changes: 17 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,23 @@ app.on('ready', () => {
appActions.newWindow()
}
} else {
loadedPerWindowImmutableState.forEach((wndState) => {
appActions.newWindow(undefined, undefined, wndState)
})
loadedPerWindowImmutableState
.sort((a, b) => {
let comparison = 0
const aTime = a.getIn(['windowInfo', 'focusTime'], 0)
const bTime = b.getIn(['windowInfo', 'focusTime'], 0)

if (aTime > bTime) {
comparison = 1
} else if (aTime < bTime) {
comparison = -1
}

return comparison
})
.forEach((wndState) => {
appActions.newWindow(undefined, undefined, wndState)
})
}
process.emit(messages.APP_INITIALIZED)

Expand Down
8 changes: 6 additions & 2 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ const appActions = {
})
},

windowReady: function (windowId) {
windowReady: function (windowId, windowValue) {
dispatch({
actionType: appConstants.APP_WINDOW_READY,
windowId
windowId,
windowValue,
queryInfo: {
windowId
}
})
},

Expand Down
2 changes: 1 addition & 1 deletion js/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ipc.on(messages.INITIALIZE_WINDOW, (e, mem) => {
appStoreRenderer.state = Immutable.fromJS(message.appState)
windowStore.state = newState
generateTabs(newState, message.frames, windowValue.id)
appActions.windowReady(windowValue.id)
appActions.windowReady(windowValue.id, windowValue)
ReactDOM.render(<Window />, document.getElementById('appContainer'))
})

Expand Down
15 changes: 13 additions & 2 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global performance */

const appDispatcher = require('../dispatcher/appDispatcher')
const EventEmitter = require('events').EventEmitter
const appActions = require('../actions/appActions')
Expand Down Expand Up @@ -759,8 +761,17 @@ const doAction = (action) => {
break
}
case windowConstants.WINDOW_ON_WINDOW_UPDATE:
windowState = windowState.set('windowInfo', action.windowValue)
break
case appConstants.APP_WINDOW_READY:
{
const oldInfo = windowState.get('windowInfo', Immutable.Map())
let windowValue = makeImmutable(action.windowValue)

if (windowValue.get('focused')) {
windowValue = windowValue.set('focusTime', performance.timing.navigationStart + performance.now())
}
windowState = windowState.set('windowInfo', oldInfo.merge(windowValue))
break
}
default:
break
}
Expand Down

0 comments on commit 843d9b3

Please sign in to comment.