fix(NUX): set smaller default window size for users with large monitors

Summary:
fixes T4080

set the maximum default viewport size to 1440x900, the screen resolution for a 15 inch macbook pro.

if the monitor is either wider or taller than the default, then cap the dimension and center it.

Test Plan: added tests

Reviewers: evan, bengotow

Reviewed By: evan, bengotow

Maniphest Tasks: T4080

Differential Revision: https://phab.nylas.com/D2115
This commit is contained in:
dillon 2015-10-05 16:24:17 -07:00
parent 3e3b5d0230
commit 98e2f5a8c6
2 changed files with 42 additions and 1 deletions

View file

@ -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'

View file

@ -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