Add initial size to window options when opening urls

This commit is contained in:
Kevin Sawicki
2013-10-09 09:25:19 -07:00
parent 662262ab82
commit 8061101bbd

View File

@@ -130,8 +130,7 @@ class AtomApplication
@on 'application:hide-other-applications', -> Menu.sendActionToFirstResponder('hideOtherApplications:')
@on 'application:unhide-all-applications', -> Menu.sendActionToFirstResponder('unhideAllApplications:')
@on 'application:new-window', ->
[width, height] = @focusedWindow()?.getSize() ? []
@openPath(initialSize: {width, height})
@openPath(initialSize: @getFocusedWindowSize())
@on 'application:new-file', -> (@focusedWindow() ? this).openPath()
@on 'application:open', -> @promptForPath()
@on 'application:open-dev', -> @promptForPath(devMode: true)
@@ -197,6 +196,17 @@ class AtomApplication
focusedWindow: ->
_.find @windows, (atomWindow) -> atomWindow.isFocused()
# Public: Get the height and width of the focused window.
#
# Returns an object with height and width keys or null if there is no
# focused window.
getFocusedWindowSize: ->
if focusedWindow = @focusedWindow()
[width, height] = focusedWindow.getSize()
{width, height}
else
null
# Public: Opens multiple paths, in existing windows if possible.
#
# * options
@@ -282,7 +292,7 @@ class AtomApplication
if pack.urlMain
packagePath = @packages.resolvePackagePath(packageName)
bootstrapScript = path.resolve(packagePath, pack.urlMain)
new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen})
new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen, initialSize: getFocusedWindowSize()})
else
console.log "Package '#{pack.name}' does not have a url main: #{urlToOpen}"
else