Fixes #194.
Emit("open-url", &args);
}
+void App::OnActivateWithNoOpenWindows() {
+ Emit("activate-with-no-open-windows");
+}
+
void App::OnWillFinishLaunching() {
Emit("will-finish-launching");
}
virtual void OnOpenFile(bool* prevent_default,
const std::string& file_path) OVERRIDE;
virtual void OnOpenURL(const std::string& url) OVERRIDE;
+ virtual void OnActivateWithNoOpenWindows() OVERRIDE;
virtual void OnWillFinishLaunching() OVERRIDE;
virtual void OnFinishLaunching() OVERRIDE;
}
}
+- (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
+ hasVisibleWindows:(BOOL)flag {
+ atom::Browser* browser = atom::Browser::Get();
+ if (flag) {
+ return YES;
+ } else {
+ browser->ActivateWithNoOpenWindows();
+ return NO;
+ }
+}
+
@end
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnOpenURL(url));
}
+void Browser::ActivateWithNoOpenWindows() {
+ FOR_EACH_OBSERVER(BrowserObserver, observers_, OnActivateWithNoOpenWindows());
+}
+
void Browser::WillFinishLaunching() {
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
}
// Tell the application to open a url.
void OpenURL(const std::string& url);
+ // Tell the application that application is activated with no open windows.
+ void ActivateWithNoOpenWindows();
+
// Tell the application the loading has been done.
void WillFinishLaunching();
void DidFinishLaunching();
// Browser is used to open a url.
virtual void OnOpenURL(const std::string& url) {}
+ // The browser is activated with no open windows (usually by clicking on the
+ // dock icon).
+ virtual void OnActivateWithNoOpenWindows() {}
+
// The browser has finished loading.
virtual void OnWillFinishLaunching() {}
virtual void OnFinishLaunching() {}
You should call `event.preventDefault()` if you want to handle this event.
+## Event: activate-with-no-open-windows
+
+Emitted when the application is activated while there is no opened windows. It
+usually happens when user has closed all of application's windows and then
+click on the application's dock icon.
+
## app.quit()
Try to close all windows. If all windows are successfully closed, the