From 20b44500d194b57b8631591d81881fdd5a4fb400 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 14:22:20 -0700 Subject: [PATCH 1/7] Restore maximized state of window On Linux and Windows there is a maximized state that isn't the same as simply restoring the window's size on Mac OS X. --- src/atom.coffee | 9 ++++++++- src/workspace.coffee | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index f86cb3860..77200240f 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -460,7 +460,8 @@ class Atom extends Model setImmediate => @show() @focus() - @setFullScreen(true) if @workspaceView.fullScreen + @setFullScreen(true) if @workspace.fullScreen + @maximize() if @workspace.maximized and process.platform isnt 'darwin' # Public: Close the current window. close: -> @@ -498,6 +499,12 @@ class Atom extends Model isFullScreen: -> @getCurrentWindow().isFullScreen() + maximize: -> + ipc.send('call-window-method', 'maximize') + + isMaximized: -> + @getCurrentWindow().isMaximized() + # Public: Get the version of the Atom application. # # Returns the version text {String}. diff --git a/src/workspace.coffee b/src/workspace.coffee index 6ee8a4600..54377e37d 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -56,6 +56,7 @@ class Workspace extends Model serializeParams: -> paneContainer: @paneContainer.serialize() fullScreen: atom.isFullScreen() + maximized: atom.isMaximized() packagesWithActiveGrammars: @getPackageNamesWithActiveGrammars() getPackageNamesWithActiveGrammars: -> From 8cf999f73b4c2e813035cf5dbfc467d274c0b0f3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 14:33:02 -0700 Subject: [PATCH 2/7] Store maximized state in window dimensions --- src/atom.coffee | 18 +++++++++++------- src/workspace.coffee | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 77200240f..396d4f77a 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -196,7 +196,8 @@ class Atom extends Model browserWindow = @getCurrentWindow() [x, y] = browserWindow.getPosition() [width, height] = browserWindow.getSize() - {x, y, width, height} + maximized = browserWindow.isMaximized() + {x, y, width, height, maximized} # Public: Set the dimensions of the window. # @@ -209,13 +210,17 @@ class Atom extends Model # :y - The new y coordinate. # :width - The new width. # :height - The new height. + # :maximized - A {Boolean} for the maximized window state. setWindowDimensions: ({x, y, width, height}) -> - if width? and height? - @setSize(width, height) - if x? and y? - @setPosition(x, y) + if maximized and process.platform isnt 'darwin' + @maximize() else - @center() + if width? and height? + @setSize(width, height) + if x? and y? + @setPosition(x, y) + else + @center() # Returns true if the dimensions are useable, false if they should be ignored. # Work around for https://github.com/atom/atom-shell/issues/473 @@ -461,7 +466,6 @@ class Atom extends Model @show() @focus() @setFullScreen(true) if @workspace.fullScreen - @maximize() if @workspace.maximized and process.platform isnt 'darwin' # Public: Close the current window. close: -> diff --git a/src/workspace.coffee b/src/workspace.coffee index 54377e37d..6ee8a4600 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -56,7 +56,6 @@ class Workspace extends Model serializeParams: -> paneContainer: @paneContainer.serialize() fullScreen: atom.isFullScreen() - maximized: atom.isMaximized() packagesWithActiveGrammars: @getPackageNamesWithActiveGrammars() getPackageNamesWithActiveGrammars: -> From ef47bdab3fb43b26cc21637da1efeee121177d2e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 14:34:14 -0700 Subject: [PATCH 3/7] Remove unused method --- src/atom.coffee | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 396d4f77a..df54425da 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -506,9 +506,6 @@ class Atom extends Model maximize: -> ipc.send('call-window-method', 'maximize') - isMaximized: -> - @getCurrentWindow().isMaximized() - # Public: Get the version of the Atom application. # # Returns the version text {String}. From a7a6236b265a0c4fdf869a74a9bcf5671ca813bf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 14:37:15 -0700 Subject: [PATCH 4/7] Add maximized parameter --- src/atom.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index df54425da..c92276fcc 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -211,7 +211,7 @@ class Atom extends Model # :width - The new width. # :height - The new height. # :maximized - A {Boolean} for the maximized window state. - setWindowDimensions: ({x, y, width, height}) -> + setWindowDimensions: ({x, y, width, height, maximized}) -> if maximized and process.platform isnt 'darwin' @maximize() else From f9010078926797a13cbe791db2430a1be4a8979a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 14:37:42 -0700 Subject: [PATCH 5/7] Document darwin check --- src/atom.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/atom.coffee b/src/atom.coffee index c92276fcc..858daef93 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -212,6 +212,7 @@ class Atom extends Model # :height - The new height. # :maximized - A {Boolean} for the maximized window state. setWindowDimensions: ({x, y, width, height, maximized}) -> + # Maximized state only applies on Windows and Linux if maximized and process.platform isnt 'darwin' @maximize() else From 75f01f87da9e47713abd9e357863eee87a6ef2c1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 15:30:01 -0700 Subject: [PATCH 6/7] Maximize window after it is shown --- src/atom.coffee | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/atom.coffee b/src/atom.coffee index 858daef93..a550735ab 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -210,18 +210,13 @@ class Atom extends Model # :y - The new y coordinate. # :width - The new width. # :height - The new height. - # :maximized - A {Boolean} for the maximized window state. - setWindowDimensions: ({x, y, width, height, maximized}) -> - # Maximized state only applies on Windows and Linux - if maximized and process.platform isnt 'darwin' - @maximize() + setWindowDimensions: ({x, y, width, height}) -> + if width? and height? + @setSize(width, height) + if x? and y? + @setPosition(x, y) else - if width? and height? - @setSize(width, height) - if x? and y? - @setPosition(x, y) - else - @center() + @center() # Returns true if the dimensions are useable, false if they should be ignored. # Work around for https://github.com/atom/atom-shell/issues/473 @@ -255,6 +250,7 @@ class Atom extends Model unless @isValidDimensions(dimensions) dimensions = @getDefaultWindowDimensions() @setWindowDimensions(dimensions) + dimensions storeWindowDimensions: -> dimensions = @getWindowDimensions() @@ -304,7 +300,7 @@ class Atom extends Model CommandInstaller.installApmCommand resourcePath, false, (error) -> console.warn error.message if error? - @restoreWindowDimensions() + dimensions = @restoreWindowDimensions() @config.load() @config.setDefaults('core', require('./workspace-view').configDefaults) @config.setDefaults('editor', require('./editor-view').configDefaults) @@ -317,7 +313,7 @@ class Atom extends Model @requireUserInitScript() @menu.update() - @displayWindow() + @displayWindow(maximize: dimensions?.maximized) unloadEditorWindow: -> return if not @project and not @workspaceView @@ -462,11 +458,12 @@ class Atom extends Model # # This is done in a next tick to prevent a white flicker from occurring # if called synchronously. - displayWindow: -> + displayWindow: ({maximize}={})-> setImmediate => @show() @focus() @setFullScreen(true) if @workspace.fullScreen + @maximize() if maximize # Public: Close the current window. close: -> From d6852cab153554b6a91d26d491cb9e6715cab3a2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 14 Aug 2014 15:46:42 -0700 Subject: [PATCH 7/7] Don't maximize on Mac OS X Just setting size, position, and full screen state is sufficient since there is no explicit maximized state. --- src/atom.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/atom.coffee b/src/atom.coffee index a550735ab..ee7f7bd06 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -313,7 +313,8 @@ class Atom extends Model @requireUserInitScript() @menu.update() - @displayWindow(maximize: dimensions?.maximized) + maximize = dimensions?.maximized and process.platform isnt 'darwin' + @displayWindow({maximize}) unloadEditorWindow: -> return if not @project and not @workspaceView