Use default dimensions the first time we load a window, but saved dimensions after that.

This commit is contained in:
joshaber
2016-02-08 21:20:36 -05:00
parent f9ec7b5691
commit 03e33b4474
3 changed files with 19 additions and 9 deletions

View File

@@ -384,6 +384,9 @@ class AtomEnvironment extends Model
inSpecMode: ->
@specMode ?= @getLoadSettings().isSpec
isFirstLoad: ->
@firstLoad ?= @getLoadSettings().firstLoad
# Public: Get the version of the Atom application.
#
# Returns the version text {String}.
@@ -492,8 +495,6 @@ class AtomEnvironment extends Model
# Extended: Reload the current window.
reload: ->
@saveWindowDimensions()
@applicationDelegate.restartWindow()
# Extended: Returns a {Boolean} that is `true` if the current window is maximized.
@@ -532,6 +533,11 @@ class AtomEnvironment extends Model
@setFullScreen(true) if @workspace?.fullScreen
@maximize() if dimensions?.maximized and process.platform isnt 'darwin'
if @isFirstLoad()
loadSettings = getWindowLoadSettings()
loadSettings.firstLoad = false
setWindowLoadSettings(loadSettings)
# Get the dimensions of this window.
#
# Returns an {Object} with the following keys:
@@ -593,7 +599,14 @@ class AtomEnvironment extends Model
{x: 0, y: 0, width: Math.min(1024, width), height}
restoreWindowDimensions: ->
dimensions = @state.windowDimensions
dimensions = null
# The first time the window's loaded we want to use the default dimensions.
# But after that, e.g., when the window's been reloaded, we want to use the
# dimensions we've saved for it.
if !@isFirstLoad()
dimensions = @state.windowDimensions
unless @isValidDimensions(dimensions)
dimensions = @getDefaultWindowDimensions()
@setWindowDimensions(dimensions)
@@ -625,7 +638,7 @@ class AtomEnvironment extends Model
@registerDefaultTargetForKeymaps()
@packages.loadPackages()
@loadStateSync()
@document.body.appendChild(@views.getView(@workspace))
@watchProjectPath()
@@ -782,11 +795,6 @@ class AtomEnvironment extends Model
@blobStore.save()
saveWindowDimensions: ->
loadSettings = getWindowLoadSettings()
loadSettings['windowDimensions'] = @getWindowDimensions()
setWindowLoadSettings(loadSettings)
saveStateSync: ->
return unless @enablePersistence

View File

@@ -49,6 +49,7 @@ class AtomWindow
loadSettings.devMode ?= false
loadSettings.safeMode ?= false
loadSettings.atomHome = process.env.ATOM_HOME
loadSettings.firstLoad = true
# Only send to the first non-spec window created
if @constructor.includeShellLoadTime and not @isSpec

View File

@@ -23,6 +23,7 @@ module.exports = ({blobStore}) ->
enablePersistence: true
})
atom.loadStateSync()
atom.displayWindow()
atom.startEditorWindow()