mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 23:54:13 +08:00
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:
parent
6cf6f9087e
commit
b8b8b7af6a
2 changed files with 42 additions and 1 deletions
|
@ -43,6 +43,34 @@ describe "the `atom` global", ->
|
||||||
[actualWidth, h] = win.getMinimumSize()
|
[actualWidth, h] = win.getMinimumSize()
|
||||||
expect(actualWidth).toBe inputMinWidth
|
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()", ->
|
describe ".isReleasedVersion()", ->
|
||||||
it "returns false if the version is a SHA and true otherwise", ->
|
it "returns false if the version is a SHA and true otherwise", ->
|
||||||
version = '0.1.0'
|
version = '0.1.0'
|
||||||
|
|
|
@ -586,7 +586,20 @@ class Atom extends Model
|
||||||
getDefaultWindowDimensions: ->
|
getDefaultWindowDimensions: ->
|
||||||
screen = remote.require('screen')
|
screen = remote.require('screen')
|
||||||
{width, height} = screen.getPrimaryDisplay().workAreaSize
|
{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: ->
|
restoreWindowDimensions: ->
|
||||||
dimensions = @savedState.windowDimensions
|
dimensions = @savedState.windowDimensions
|
||||||
|
|
Loading…
Reference in a new issue