diff --git a/native/v8_extensions/native.h b/native/v8_extensions/native.h index 1031be7ec..e7a200493 100644 --- a/native/v8_extensions/native.h +++ b/native/v8_extensions/native.h @@ -7,15 +7,18 @@ namespace v8_extensions { class Native : public CefV8Handler { public: Native(); - + virtual bool Execute(const CefString& name, CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, CefString& exception) OVERRIDE; - + // Provide the reference counting implementation for this class. IMPLEMENT_REFCOUNTING(Native); + +private: + std::string windowState; }; } diff --git a/native/v8_extensions/native.js b/native/v8_extensions/native.js index 85cdf5be8..9124d89fc 100644 --- a/native/v8_extensions/native.js +++ b/native/v8_extensions/native.js @@ -76,4 +76,10 @@ var $native = {}; native function getPlatform(); $native.getPlatform = getPlatform; + native function setWindowState(state); + $native.setWindowState = setWindowState; + + native function getWindowState(); + $native.getWindowState = getWindowState; + })(); diff --git a/native/v8_extensions/native.mm b/native/v8_extensions/native.mm index c947aec01..0a66591ca 100644 --- a/native/v8_extensions/native.mm +++ b/native/v8_extensions/native.mm @@ -31,6 +31,7 @@ void throwException(const CefRefPtr& global, CefRefPtrGetStringValue().ToString(); + return true; + } + + else if (name == "getWindowState") { + retval = CefV8Value::CreateString(windowState); + return true; + } + return false; }; diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 96594961e..8f02a3db0 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -109,3 +109,16 @@ _.extend atom, if name is 'reply' [messageId, callbackIndex] = data.shift() @pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?(data...) + + setWindowState: (keyPath, value) -> + windowState = @getWindowState() + _.setValueForKeyPath(windowState, keyPath, value) + $native.setWindowState(JSON.stringify(windowState)) + windowState + + getWindowState: (keyPath) -> + windowState = JSON.parse($native.getWindowState()) + if keyPath + _.valueForKeyPath(windowState, keyPath) + else + windowState diff --git a/src/app/window.coffee b/src/app/window.coffee index 85077e84a..4d0b6e6a7 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -47,8 +47,10 @@ windowAdditions = false shutdown: -> - @rootView?.deactivate() - @rootView = null + if @rootView + atom.setWindowState('pathToOpen', @rootView.project.getPath()) + @rootView.deactivate() + @rootView = null $(window).unbind('focus') $(window).unbind('blur') $(window).off('before') diff --git a/src/window-bootstrap.coffee b/src/window-bootstrap.coffee index 86404bb98..5720d9af9 100644 --- a/src/window-bootstrap.coffee +++ b/src/window-bootstrap.coffee @@ -1,4 +1,6 @@ # Like sands through the hourglass, so are the days of our lives. require 'atom' require 'window' -window.attachRootView(window.location.params.pathToOpen) + +pathToOpen = atom.getWindowState('pathToOpen') ? window.location.params.pathToOpen +window.attachRootView(pathToOpen)