diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index 80f2d3ca0..582a99a6d 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -43,6 +43,34 @@ describe "the `atom` global", -> [actualWidth, h] = win.getMinimumSize() expect(actualWidth).toBe inputMinWidth + describe '::getDefaultWindowDimensions', -> + screen = require('remote').require 'screen' + + it "returns primary display's work area size if it's small enough", -> + spyOn(screen, 'getPrimaryDisplay').andReturn workAreaSize: width: 1440, height: 900 + + out = atom.getDefaultWindowDimensions() + expect(out).toEqual x: 0, y: 0, width: 1440, height: 900 + + it "caps width at 1440 and centers it, if wider", -> + spyOn(screen, 'getPrimaryDisplay').andReturn workAreaSize: width: 1840, height: 900 + + out = atom.getDefaultWindowDimensions() + expect(out).toEqual x: 200, y: 0, width: 1440, height: 900 + + it "caps height at 900 and centers it, if taller", -> + spyOn(screen, 'getPrimaryDisplay').andReturn workAreaSize: width: 1440, height: 1100 + + out = atom.getDefaultWindowDimensions() + expect(out).toEqual x: 0, y: 100, width: 1440, height: 900 + + it "returns only the max viewport size if it's smaller than the defaults", -> + spyOn(screen, 'getPrimaryDisplay').andReturn workAreaSize: width: 1000, height: 800 + + out = atom.getDefaultWindowDimensions() + expect(out).toEqual x: 0, y: 0, width: 1000, height: 800 + + describe ".isReleasedVersion()", -> it "returns false if the version is a SHA and true otherwise", -> version = '0.1.0' diff --git a/src/atom.coffee b/src/atom.coffee index bcb087232..91dd12623 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -586,7 +586,20 @@ class Atom extends Model getDefaultWindowDimensions: -> screen = remote.require('screen') {width, height} = screen.getPrimaryDisplay().workAreaSize - {x: 0, y: 0, width, height} + x = 0 + y = 0 + + MAX_WIDTH = 1440 + if width > MAX_WIDTH + x = (width - MAX_WIDTH) / 2 + width = MAX_WIDTH + + MAX_HEIGHT = 900 + if height > MAX_HEIGHT + y = (height - MAX_HEIGHT) / 2 + height = MAX_HEIGHT + + {x, y, width, height} restoreWindowDimensions: -> dimensions = @savedState.windowDimensions