From 94ffd4bfc017b47641fdfe96f46cbba83196f512 Mon Sep 17 00:00:00 2001 From: mikeykhalil Date: Thu, 3 May 2018 00:43:46 -0700 Subject: [PATCH] add getter for ignoreDoubleClickEvents field --- atom/browser/api/atom_api_tray.cc | 10 ++++++++++ atom/browser/api/atom_api_tray.h | 1 + atom/browser/ui/tray_icon.cc | 3 --- atom/browser/ui/tray_icon.h | 9 ++++++--- atom/browser/ui/tray_icon_cocoa.h | 1 + atom/browser/ui/tray_icon_cocoa.mm | 10 +++++++++- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 80a4d20c915c..20416b012c33 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -182,6 +182,14 @@ void Tray::SetIgnoreDoubleClickEvents(bool ignore) { #endif } +bool Tray::GetIgnoreDoubleClickEvents() { +#if defined(OS_MACOSX) + return tray_icon_->GetIgnoreDoubleClickEvents(); +#else + return false; +#endif +} + void Tray::DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options) { mate::Handle icon; @@ -232,6 +240,8 @@ void Tray::BuildPrototype(v8::Isolate* isolate, .SetMethod("setHighlightMode", &Tray::SetHighlightMode) .SetMethod("setIgnoreDoubleClickEvents", &Tray::SetIgnoreDoubleClickEvents) + .SetMethod("getIgnoreDoubleClickEvents", + &Tray::GetIgnoreDoubleClickEvents) .SetMethod("displayBalloon", &Tray::DisplayBalloon) .SetMethod("popUpContextMenu", &Tray::PopUpContextMenu) .SetMethod("setContextMenu", &Tray::SetContextMenu) diff --git a/atom/browser/api/atom_api_tray.h b/atom/browser/api/atom_api_tray.h index 298659ddaad7..2ccb836d6299 100644 --- a/atom/browser/api/atom_api_tray.h +++ b/atom/browser/api/atom_api_tray.h @@ -71,6 +71,7 @@ class Tray : public mate::TrackableObject, public TrayIconObserver { void SetTitle(const std::string& title); void SetHighlightMode(TrayIcon::HighlightMode mode); void SetIgnoreDoubleClickEvents(bool ignore); + bool GetIgnoreDoubleClickEvents(); void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options); void PopUpContextMenu(mate::Arguments* args); void SetContextMenu(v8::Isolate* isolate, mate::Handle menu); diff --git a/atom/browser/ui/tray_icon.cc b/atom/browser/ui/tray_icon.cc index 5a7c0c926d28..b5332ac97b27 100644 --- a/atom/browser/ui/tray_icon.cc +++ b/atom/browser/ui/tray_icon.cc @@ -16,9 +16,6 @@ void TrayIcon::SetTitle(const std::string& title) {} void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {} -void TrayIcon::SetIgnoreDoubleClickEvents(bool ignore) { -} - void TrayIcon::DisplayBalloon(ImageType icon, const base::string16& title, const base::string16& contents) {} diff --git a/atom/browser/ui/tray_icon.h b/atom/browser/ui/tray_icon.h index 097fb180d3af..76155000e887 100644 --- a/atom/browser/ui/tray_icon.h +++ b/atom/browser/ui/tray_icon.h @@ -51,9 +51,12 @@ class TrayIcon { }; virtual void SetHighlightMode(HighlightMode mode); - // Sets the flag which determines whether to ignore double click events. This - // only works on macOS. - virtual void SetIgnoreDoubleClickEvents(bool ignore); + // Setter and getter for the flag which determines whether to ignore double + // click events. These only work on macOS. +#if defined(OS_MACOSX) + virtual void SetIgnoreDoubleClickEvents(bool ignore) = 0; + virtual bool GetIgnoreDoubleClickEvents() = 0; +#endif // Displays a notification balloon with the specified contents. // Depending on the platform it might not appear by the icon tray. diff --git a/atom/browser/ui/tray_icon_cocoa.h b/atom/browser/ui/tray_icon_cocoa.h index 2f6a5f79943c..0208b1898016 100644 --- a/atom/browser/ui/tray_icon_cocoa.h +++ b/atom/browser/ui/tray_icon_cocoa.h @@ -28,6 +28,7 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer { void SetTitle(const std::string& title) override; void SetHighlightMode(TrayIcon::HighlightMode mode) override; void SetIgnoreDoubleClickEvents(bool ignore) override; + bool GetIgnoreDoubleClickEvents() override; void PopUpContextMenu(const gfx::Point& pos, AtomMenuModel* menu_model) override; void SetContextMenu(AtomMenuModel* menu_model) override; diff --git a/atom/browser/ui/tray_icon_cocoa.mm b/atom/browser/ui/tray_icon_cocoa.mm index 166a6fe82ca9..f5ad0624dffe 100644 --- a/atom/browser/ui/tray_icon_cocoa.mm +++ b/atom/browser/ui/tray_icon_cocoa.mm @@ -206,10 +206,14 @@ const CGFloat kVerticalTitleMargin = 2; [self setNeedsDisplay:YES]; } -- (void) setIgnoreDoubleClickEvents:(BOOL)ignore { +- (void)setIgnoreDoubleClickEvents:(BOOL)ignore { ignoreDoubleClickEvents_ = ignore; } +- (BOOL)getIgnoreDoubleClickEvents { + return ignoreDoubleClickEvents_; +} + - (void)setTitle:(NSString*)title { if (title.length > 0) { title_.reset([title copy]); @@ -450,6 +454,10 @@ void TrayIconCocoa::SetIgnoreDoubleClickEvents(bool ignore) { [status_item_view_ setIgnoreDoubleClickEvents:ignore]; } +bool TrayIconCocoa::GetIgnoreDoubleClickEvents() { + return [status_item_view_ getIgnoreDoubleClickEvents]; +} + void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos, AtomMenuModel* menu_model) { [status_item_view_ popUpContextMenu:menu_model];