]> khamidou — GitHub mirrors - electron.git/commitdiff
Implement 'activiate' event instead of 'activate-with-open-windows'.
authorHaojian Wu <hokein.wu@gmail.com>
Tue, 15 Sep 2015 01:34:27 +0000 (18:34 -0700)
committerHaojian Wu <hokein.wu@gmail.com>
Tue, 15 Sep 2015 01:34:27 +0000 (18:34 -0700)
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 f7c20483b49003067f05fd1a162046848adbdb02..cf187c451c83741efb4ca59eb7da1e61a3cac092 100644 (file)
@@ -171,8 +171,8 @@ void App::OnActivateWithNoOpenWindows() {
   Emit("activate-with-no-open-windows");
 }
 
-void App::OnActivateWithOpenWindows() {
-  Emit("activate-with-open-windows");
+void App::OnActivate(bool hasVisibleWindows) {
+  Emit("activate", hasVisibleWindows);
 }
 
 void App::OnWillFinishLaunching() {
index 5f29744e919ba8451c25c58e685f49ce8a20bb31..7e16a8df4e6c55690895c798c4a41d7d9b4bdcb9 100644 (file)
@@ -42,7 +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 OnActivate(bool hasVisibleWindows) override;
   void OnWillFinishLaunching() override;
   void OnFinishLaunching() override;
   void OnSelectCertificate(
index 11530375eff819efa9a09faf852612fa0b402ad1..186b6c6e37aff850cc7b87efecee8a212ed605f3 100644 (file)
@@ -98,8 +98,8 @@ void Browser::ActivateWithNoOpenWindows() {
   FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows());
 }
 
-void Browser::ActivateWithOpenWindows() {
-  FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithOpenWindows());
+void Browser::Activate(bool hasVisibleWindows) {
+  FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivate(hasVisibleWindows));
 }
 
 void Browser::WillFinishLaunching() {
index 43b253c840a804946f64dfd53af766d6c625a7ef..3afa1b5a688c99f64a1e391357525fb1c09b7af0 100644 (file)
@@ -111,8 +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 that application is activated with visible/invisible
+  // windows.
+  void Activate(bool hasVisibleWindows);
 
   // Tell the application the loading has been done.
   void WillFinishLaunching();
index 815d21bb843f17eeefba88c599c46d2397add554..37be4922ddfa29b01aecc17c78e4610deb5184fc 100644 (file)
@@ -47,9 +47,9 @@ 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 is activated with visible/invisible windows (usually by
+  // clicking on the dock icon).
+  virtual void OnActivate(bool hasVisibleWindows) {}
 
   // The browser has finished loading.
   virtual void OnWillFinishLaunching() {}
index 0ee46e59e6ec15ddc72955fd16dc297407005a74..525e700e2b4e1303402b34da2ff3c8e5fc1aba49 100644 (file)
@@ -52,8 +52,8 @@
 - (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
                     hasVisibleWindows:(BOOL)flag {
   atom::Browser* browser = atom::Browser::Get();
+  browser->Activate(static_cast<bool>(flag));
   if (flag) {
-    browser->ActivateWithOpenWindows();
     return YES;
   } else {
     browser->ActivateWithNoOpenWindows();
index 12be27ce75fceb9c16e23d31c6159359cd49aa86..ba61e1a0e0d8f848eaa106a0c83d8821c48f6bae 100644 (file)
@@ -100,10 +100,15 @@ 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_
+### Event: 'activate' _OS X_
 
-Emitted when the application is activated while there are open windows, which
-usually happens when clicks on the applications's dock icon.
+Returns:
+
+* `event` Event
+* `hasVisibleWindows` Bool
+
+Emitted when the application is activated, which usually happens when clicks on
+the applications's dock icon.
 
 ### Event: 'browser-window-blur'