:apple: Add 'Hide' to App API for OS X only
authorSimon Madine <simon.madine@here.com>
Fri, 29 Jan 2016 11:30:19 +0000 (12:30 +0100)
committerSimon Madine <simon.madine@here.com>
Fri, 29 Jan 2016 15:09:54 +0000 (16:09 +0100)
atom/browser/api/atom_api_app.cc
atom/browser/browser.h
atom/browser/browser_mac.mm
docs/api/app.md

index 394014e..441b055 100644 (file)
@@ -356,6 +356,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
       .SetMethod("quit", base::Bind(&Browser::Quit, browser))
       .SetMethod("exit", base::Bind(&Browser::Exit, browser))
       .SetMethod("focus", base::Bind(&Browser::Focus, browser))
+      .SetMethod("hide", base::Bind(&Browser::Hide, browser))
       .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser))
       .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser))
       .SetMethod("getName", base::Bind(&Browser::GetName, browser))
index 0b55fb6..711415e 100644 (file)
@@ -55,6 +55,9 @@ class Browser : public WindowListObserver {
   // Focus the application.
   void Focus();
 
+  // Focus the application.
+  void Hide();
+
   // Returns the version of the executable (or bundle).
   std::string GetVersion() const;
 
index 1eb7fab..db89801 100644 (file)
@@ -18,6 +18,10 @@ void Browser::Focus() {
   [[AtomApplication sharedApplication] activateIgnoringOtherApps:YES];
 }
 
+void Browser::Hide() {
+  [[AtomApplication sharedApplication] hide:nil];
+}
+
 void Browser::AddRecentDocument(const base::FilePath& path) {
   NSString* path_string = base::mac::FilePathToNSString(path);
   if (!path_string)
index a26defb..808f5fa 100644 (file)
@@ -244,6 +244,10 @@ This method guarantees that all `beforeunload` and `unload` event handlers are
 correctly executed. It is possible that a window cancels the quitting by
 returning `false` in the `beforeunload` event handler.
 
+### `app.hide()` _OS X_
+
+Hides all application windows without minimising them.
+
 ### `app.exit(exitCode)`
 
 * `exitCode` Integer