Apply window background color after resizing window

This commit is contained in:
Max Brunsfeld
2016-01-27 13:00:18 -08:00
parent 32f5149196
commit 28e535ee15
2 changed files with 9 additions and 26 deletions

View File

@@ -524,6 +524,7 @@ class AtomEnvironment extends Model
displayWindow: ->
@restoreWindowDimensions().then (dimensions) =>
steps = [
@restoreWindowBackground(),
@show(),
@focus()
]
@@ -603,6 +604,13 @@ class AtomEnvironment extends Model
dimensions = @getWindowDimensions()
@state.windowDimensions = dimensions if @isValidDimensions(dimensions)
restoreWindowBackground: ->
if backgroundColor = window.localStorage.getItem('atom:window-background-color')
@backgroundStylesheet = document.createElement('style')
@backgroundStylesheet.type = 'text/css'
@backgroundStylesheet.innerText = 'html, body { background: ' + backgroundColor + ' !important; }'
document.head.appendChild(@backgroundStylesheet)
storeWindowBackground: ->
return if @inSpecMode()
@@ -627,6 +635,7 @@ class AtomEnvironment extends Model
@packages.loadPackages()
@loadStateSync()
@document.body.appendChild(@views.getView(@workspace))
@backgroundStylesheet?.remove()
@watchProjectPath()

View File

@@ -146,31 +146,6 @@
}
}
function setupWindowBackground () {
if (loadSettings && loadSettings.isSpec) {
return
}
var backgroundColor = window.localStorage.getItem('atom:window-background-color')
if (!backgroundColor) {
return
}
var backgroundStylesheet = document.createElement('style')
backgroundStylesheet.type = 'text/css'
backgroundStylesheet.innerText = 'html, body { background: ' + backgroundColor + ' !important; }'
document.head.appendChild(backgroundStylesheet)
// Remove once the page loads
window.addEventListener('load', function loadWindow () {
window.removeEventListener('load', loadWindow, false)
setTimeout(function () {
backgroundStylesheet.remove()
backgroundStylesheet = null
}, 1000)
}, false)
}
var setupAtomHome = function () {
if (process.env.ATOM_HOME) {
return
@@ -186,5 +161,4 @@
parseLoadSettings()
setupAtomHome()
setupWindowBackground()
})()