mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Apply window background color after resizing window
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user