diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 0f5829e19c1..5381c77c379 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -78,6 +78,14 @@ void Tray::OnDropFiles(const std::vector& files) { Emit("drop-files", files); } +void Tray::OnDragEntered() { + Emit("drag-entered"); +} + +void Tray::OnDragExited() { + Emit("drag-exited"); +} + bool Tray::IsDestroyed() const { return !tray_icon_; } diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 9a423f61764..b26796bcced 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -49,6 +49,8 @@ class Tray : public mate::TrackableObject, void OnBalloonClicked() override; void OnBalloonClosed() override; void OnDropFiles(const std::vector& files) override; + void OnDragEntered() override; + void OnDragExited() override; // mate::Wrappable: bool IsDestroyed() const override; diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index d2c6bc1b259..bc69b6e7275 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -59,4 +59,12 @@ void TrayIcon::NotifyDropFiles(const std::vector& files) { FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDropFiles(files)); } +void TrayIcon::NotifyDragEntered() { + FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragEntered()); +} + +void TrayIcon::NotifyDragExited() { + FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnDragExited()); +} + } // namespace atom diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index 539fe04f4bb..bff3057bf61 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -62,6 +62,8 @@ class TrayIcon { void NotifyRightClicked(const gfx::Rect& bounds = gfx::Rect(), int modifiers = 0); void NotifyDropFiles(const std::vector& files); + void TrayIcon::NotifyDragEntered(); + void TrayIcon::NotifyDragExited(); protected: TrayIcon(); diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 34ca4e9a911..40505a64d8c 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -254,9 +254,14 @@ const CGFloat kVerticalTitleMargin = 2; } - (NSDragOperation)draggingEntered:(id )sender { + trayIcon_->NotifyDragEntered(); return NSDragOperationCopy; } +- (void)draggingExited:(id )sender { + trayIcon_->NotifyDragExited(); +} + - (BOOL)performDragOperation:(id )sender { NSPasteboard* pboard = [sender draggingPasteboard]; diff --git a/atom/browser/ui/tray_icon_observer.h b/atom/browser/ui/tray_icon_observer.h index fa8090d7d6c..e9a8bd33f1d 100644 --- a/atom/browser/ui/tray_icon_observer.h +++ b/atom/browser/ui/tray_icon_observer.h @@ -23,6 +23,8 @@ class TrayIconObserver { virtual void OnBalloonClosed() {} virtual void OnRightClicked(const gfx::Rect& bounds, int modifiers) {} virtual void OnDropFiles(const std::vector& files) {} + virtual void OnDragEntered() {} + virtual void OnDragExited() {} protected: virtual ~TrayIconObserver() {}