[OS X] Implement 'activate-with-open-windows' event for app.

This commit is contained in:
Haojian Wu 2015-09-14 19:28:13 +08:00
parent 4d28fbf561
commit 3ad5d17612
7 changed files with 22 additions and 0 deletions

View file

@ -171,6 +171,10 @@ void App::OnActivateWithNoOpenWindows() {
Emit("activate-with-no-open-windows"); Emit("activate-with-no-open-windows");
} }
void App::OnActivateWithOpenWindows() {
Emit("activate-with-open-windows");
}
void App::OnWillFinishLaunching() { void App::OnWillFinishLaunching() {
Emit("will-finish-launching"); Emit("will-finish-launching");
} }

View file

@ -42,6 +42,7 @@ class App : public mate::EventEmitter,
void OnOpenFile(bool* prevent_default, const std::string& file_path) override; void OnOpenFile(bool* prevent_default, const std::string& file_path) override;
void OnOpenURL(const std::string& url) override; void OnOpenURL(const std::string& url) override;
void OnActivateWithNoOpenWindows() override; void OnActivateWithNoOpenWindows() override;
void OnActivateWithOpenWindows() override;
void OnWillFinishLaunching() override; void OnWillFinishLaunching() override;
void OnFinishLaunching() override; void OnFinishLaunching() override;
void OnSelectCertificate( void OnSelectCertificate(

View file

@ -98,6 +98,10 @@ void Browser::ActivateWithNoOpenWindows() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows()); FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows());
} }
void Browser::ActivateWithOpenWindows() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithOpenWindows());
}
void Browser::WillFinishLaunching() { void Browser::WillFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching()); FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
} }

View file

@ -111,6 +111,9 @@ class Browser : public WindowListObserver {
// Tell the application that application is activated with no open windows. // Tell the application that application is activated with no open windows.
void ActivateWithNoOpenWindows(); void ActivateWithNoOpenWindows();
// Tell the application that application is activated with open windows.
void ActivateWithOpenWindows();
// Tell the application the loading has been done. // Tell the application the loading has been done.
void WillFinishLaunching(); void WillFinishLaunching();
void DidFinishLaunching(); void DidFinishLaunching();

View file

@ -47,6 +47,10 @@ class BrowserObserver {
// dock icon). // dock icon).
virtual void OnActivateWithNoOpenWindows() {} 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. // The browser has finished loading.
virtual void OnWillFinishLaunching() {} virtual void OnWillFinishLaunching() {}
virtual void OnFinishLaunching() {} virtual void OnFinishLaunching() {}

View file

@ -53,6 +53,7 @@
hasVisibleWindows:(BOOL)flag { hasVisibleWindows:(BOOL)flag {
atom::Browser* browser = atom::Browser::Get(); atom::Browser* browser = atom::Browser::Get();
if (flag) { if (flag) {
browser->ActivateWithOpenWindows();
return YES; return YES;
} else { } else {
browser->ActivateWithNoOpenWindows(); browser->ActivateWithNoOpenWindows();

View 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 usually happens when the user has closed all of the application's windows and
then clicks on the application's dock icon. 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' ### Event: 'browser-window-blur'
Returns: Returns: