diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index cd95d423d82..5dba76dacb7 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -36,6 +36,10 @@ void Tray::OnClicked() { Emit("clicked"); } +void Tray::OnDoubleClicked() { + Emit("double-clicked"); +} + void Tray::SetImage(const gfx::ImageSkia& image) { tray_icon_->SetImage(image); } diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 791cc5611ba..1630ba7cfd9 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -37,6 +37,7 @@ class Tray : public mate::EventEmitter, // TrayIcon implementations: virtual void OnClicked() OVERRIDE; + virtual void OnDoubleClicked() OVERRIDE; void SetImage(const gfx::ImageSkia& image); void SetPressedImage(const gfx::ImageSkia& image); diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index 3f291025a41..95460fb64ee 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -22,4 +22,8 @@ void TrayIcon::NotifyClicked() { FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked()); } +void TrayIcon::NotifyDoubleClicked() { + FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDoubleClicked()); +} + } // namespace atom diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index 7eaef16d7b9..e2de226836d 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -45,6 +45,7 @@ class TrayIcon { void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); } void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); } void NotifyClicked(); + void NotifyDoubleClicked(); protected: TrayIcon(); diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 4fb1372c048..a7b322fe3fb 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -13,6 +13,7 @@ } - (id)initWithIcon:(atom::TrayIconCocoa*)icon; - (void)handleClick:(id)sender; +- (void)handleDoubleClick:(id)sender; @end // @interface StatusItemController @@ -24,10 +25,13 @@ } - (void)handleClick:(id)sender { - DCHECK(trayIcon_); trayIcon_->NotifyClicked(); } +- (void)handleDoubleClick:(id)sender { + trayIcon_->NotifyDoubleClicked(); +} + @end namespace atom { @@ -40,6 +44,7 @@ TrayIconCocoa::TrayIconCocoa() { [item_ setEnabled:YES]; [item_ setTarget:controller_]; [item_ setAction:@selector(handleClick:)]; + [item_ setDoubleAction:@selector(handleDoubleClick:)]; [item_ setHighlightMode:YES]; } diff --git a/atom/browser/ui/tray_icon_observer.h b/atom/browser/ui/tray_icon_observer.h index f28bfd6cc9a..5a4fc3a004e 100644 --- a/atom/browser/ui/tray_icon_observer.h +++ b/atom/browser/ui/tray_icon_observer.h @@ -10,6 +10,7 @@ namespace atom { class TrayIconObserver { public: virtual void OnClicked() {} + virtual void OnDoubleClicked() {} protected: virtual ~TrayIconObserver() {}