From 28e535ee15921e621a2b3218acc456e985a24d2b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 27 Jan 2016 13:00:18 -0800 Subject: [PATCH] Apply window background color after resizing window --- src/atom-environment.coffee | 9 +++++++++ static/index.js | 26 -------------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index be05ef4cf..44579a4bc 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -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() diff --git a/static/index.js b/static/index.js index 796cda363..bedd422fb 100644 --- a/static/index.js +++ b/static/index.js @@ -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() })()