From d72e3d9c812eff5e31482f11c44cd725f5d2bd37 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 8 Apr 2014 17:11:20 -0700 Subject: [PATCH] Add AtomWindow::getWindowDimensions --- src/browser/atom-application.coffee | 17 +++-------------- src/browser/atom-window.coffee | 7 +++++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index 402f00c15..6637e92c1 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -172,7 +172,7 @@ class AtomApplication @on 'application:run-all-specs', -> @runSpecs(exitWhenDone: false, resourcePath: global.devResourcePath) @on 'application:run-benchmarks', -> @runBenchmarks() @on 'application:quit', -> app.quit() - @on 'application:new-window', -> @openPath(windowDimensions: @getFocusedWindowDimensions()) + @on 'application:new-window', -> @openPath(windowDimensions: @focusedWindow()?.getDimensions()) @on 'application:new-file', -> (@focusedWindow() ? this).openPath() @on 'application:open', -> @promptForPath() @on 'application:open-dev', -> @promptForPath(devMode: true) @@ -304,18 +304,6 @@ class AtomApplication focusedWindow: -> _.find @windows, (atomWindow) -> atomWindow.isFocused() - # Public: Get the dimensions focused window. - # - # Returns an object with x, y height and width keys or null if there is no - # focused window. - getFocusedWindowDimensions: -> - if focusedWindow = @focusedWindow() - [width, height] = focusedWindow.getSize() - [x, y] = focusedWindow.getPosition() - {x, y, width, height} - else - null - # Public: Opens multiple paths, in existing windows if possible. # # * options @@ -415,7 +403,8 @@ class AtomApplication if pack.urlMain packagePath = @packages.resolvePackagePath(packageName) bootstrapScript = path.resolve(packagePath, pack.urlMain) - new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen, windowDimensions: @getFocusedWindowDimensions()}) + windowDimensions = @focusedWindow()?.getDimensions() + new AtomWindow({bootstrapScript, @resourcePath, devMode, urlToOpen, windowDimensions}) else console.log "Package '#{pack.name}' does not have a url main: #{urlToOpen}" else diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index fed11e4d6..efa409c27 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -132,12 +132,15 @@ class AtomWindow action = if args[0]?.contextCommand then 'context-command' else 'command' ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), action, command, args... + getDimensions: -> + [x, y] = @browserWindow.getPosition() + [width, height] = @browserWindow.getSize() + {x, y, width, height} + close: -> @browserWindow.close() focus: -> @browserWindow.focus() - getSize: -> @browserWindow.getSize() - minimize: -> @browserWindow.minimize() maximize: -> @browserWindow.maximize()