]> khamidou — GitHub mirrors - electron.git/commitdiff
[OS X] Implement 'activate-with-open-windows' event for app.
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 14 Sep 2015 11:28:13 +0000 (19:28 +0800)
committerHaojian Wu <hokein.wu@gmail.com>
Mon, 14 Sep 2015 12:32:50 +0000 (20:32 +0800)
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_app.h
atom/browser/browser.cc
atom/browser/browser.h
atom/browser/browser_observer.h
atom/browser/mac/atom_application_delegate.mm
docs/api/app.md

index e2d265c5da39222d2c1eca13d2fe35de554b7d0b..f7c20483b49003067f05fd1a162046848adbdb02 100644 (file)
@@ -171,6 +171,10 @@ void App::OnActivateWithNoOpenWindows() {
   Emit("activate-with-no-open-windows");
 }
 
+void App::OnActivateWithOpenWindows() {
+  Emit("activate-with-open-windows");
+}
+
 void App::OnWillFinishLaunching() {
   Emit("will-finish-launching");
 }
index 040f7e3363a9bcaccde9707970fc286c9c73b706..5f29744e919ba8451c25c58e685f49ce8a20bb31 100644 (file)
@@ -42,6 +42,7 @@ class App : public mate::EventEmitter,
   void OnOpenFile(bool* prevent_default, const std::string& file_path) override;
   void OnOpenURL(const std::string& url) override;
   void OnActivateWithNoOpenWindows() override;
+  void OnActivateWithOpenWindows() override;
   void OnWillFinishLaunching() override;
   void OnFinishLaunching() override;
   void OnSelectCertificate(
index 3419ecbe330d75886f183c930060ef6fa6fdc4d1..11530375eff819efa9a09faf852612fa0b402ad1 100644 (file)
@@ -98,6 +98,10 @@ void Browser::ActivateWithNoOpenWindows() {
   FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows());
 }
 
+void Browser::ActivateWithOpenWindows() {
+  FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithOpenWindows());
+}
+
 void Browser::WillFinishLaunching() {
   FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
 }
index dc412cefb046ab0034d25b8a676fbe8e0d3033d7..43b253c840a804946f64dfd53af766d6c625a7ef 100644 (file)
@@ -111,6 +111,9 @@ class Browser : public WindowListObserver {
   // Tell the application that application is activated with no open windows.
   void ActivateWithNoOpenWindows();
 
+  // Tell the application that application is activated with open windows.
+  void ActivateWithOpenWindows();
+
   // Tell the application the loading has been done.
   void WillFinishLaunching();
   void DidFinishLaunching();
index 20fd08a2e911ede508f8077dcce1be6eaa1ddb16..815d21bb843f17eeefba88c599c46d2397add554 100644 (file)
@@ -47,6 +47,10 @@ class BrowserObserver {
   // dock icon).
   virtual void OnActivateWithNoOpenWindows() {}
 
+  // The browser is activated with open windows (usually by clicking on the dock
+  // icon).
+  virtual void OnActivateWithOpenWindows() {}
+
   // The browser has finished loading.
   virtual void OnWillFinishLaunching() {}
   virtual void OnFinishLaunching() {}
index 16dcf6fd95239748fec7cb08a864e1b27b1d10b2..0ee46e59e6ec15ddc72955fd16dc297407005a74 100644 (file)
@@ -53,6 +53,7 @@
                     hasVisibleWindows:(BOOL)flag {
   atom::Browser* browser = atom::Browser::Get();
   if (flag) {
+    browser->ActivateWithOpenWindows();
     return YES;
   } else {
     browser->ActivateWithNoOpenWindows();
index 799db98882fecd15ccbf16422ed2e0ec4c24406f..bb77a32913fce1d5a6c0c5e99c9dec0ac56777a5 100644 (file)
@@ -100,6 +100,11 @@ Emitted when the application is activated while there are no open windows, which
 usually happens when the user has closed all of the application's windows and
 then clicks on the application's dock icon.
 
+### Event: activated-with-open-windows _OS X_
+
+Emitted when the application is activated while there are open windows, which
+usually happens when clicks on the applications's dock icon.
+
 ### Event: 'browser-window-blur'
 
 Returns: