mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-10 22:54:45 +08:00
fix(focus): Show drafts in unfocused state when window is blurred
- See #1695 - Update key commands region to clear focus when window blurs - Dispatch broswer-window-focus/blur as a window event into the renderer window - Update tray icon to listen to window instead of ipc event
This commit is contained in:
parent
d324a33d4b
commit
b47c707845
3 changed files with 12 additions and 4 deletions
|
@ -26,10 +26,11 @@ class SystemTrayIconStore {
|
|||
this._updateIcon()
|
||||
this._unsubscribers.push(UnreadBadgeStore.listen(this._updateIcon));
|
||||
|
||||
ipcRenderer.on('browser-window-blur', this._onWindowBlur)
|
||||
ipcRenderer.on('browser-window-focus', this._onWindowFocus)
|
||||
this._unsubscribers.push(() => ipcRenderer.removeListener('browser-window-blur', this._onWindowBlur))
|
||||
this._unsubscribers.push(() => ipcRenderer.removeListener('browser-window-focus', this._onWindowFocus))
|
||||
|
||||
window.addEventListener('browser-window-blur', this._onWindowBlur);
|
||||
window.addEventListener('browser-window-focus', this._onWindowFocus);
|
||||
this._unsubscribers.push(() => window.removeEventListener('browser-window-blur', this._onWindowBlur))
|
||||
this._unsubscribers.push(() => window.removeEventListener('browser-window-focus', this._onWindowFocus))
|
||||
}
|
||||
|
||||
_getIconImageData(unreadCount, isWindowBlurred) {
|
||||
|
|
|
@ -162,6 +162,7 @@ class KeyCommandsRegion extends React.Component
|
|||
@_localDisposable = NylasEnv.commands.add($el, props.localHandlers)
|
||||
$el.addEventListener('focusin', @_in)
|
||||
$el.addEventListener('focusout', @_out)
|
||||
window.addEventListener('browser-window-blur', @_onWindowBlur)
|
||||
|
||||
_unmountListeners: ->
|
||||
@_globalDisposable?.dispose()
|
||||
|
@ -171,8 +172,12 @@ class KeyCommandsRegion extends React.Component
|
|||
$el = React.findDOMNode(@)
|
||||
$el.removeEventListener('focusin', @_in)
|
||||
$el.removeEventListener('focusout', @_out)
|
||||
window.removeEventListener('browser-window-blur', @_onWindowBlur)
|
||||
@_goingout = false
|
||||
|
||||
_onWindowBlur: =>
|
||||
@setState(focused: false)
|
||||
|
||||
render: ->
|
||||
classname = classNames
|
||||
'key-commands-region': true
|
||||
|
|
|
@ -32,9 +32,11 @@ class WindowEventHandler
|
|||
|
||||
@subscribe ipcRenderer, 'browser-window-focus', ->
|
||||
document.body.classList.remove('is-blurred')
|
||||
window.dispatchEvent(new Event('browser-window-focus'))
|
||||
|
||||
@subscribe ipcRenderer, 'browser-window-blur', ->
|
||||
document.body.classList.add('is-blurred')
|
||||
window.dispatchEvent(new Event('browser-window-blur'))
|
||||
|
||||
@subscribe ipcRenderer, 'command', (event, command, args...) ->
|
||||
activeElement = document.activeElement
|
||||
|
|
Loading…
Add table
Reference in a new issue