Browse Source

add getter for ignoreDoubleClickEvents field

mikeykhalil 7 years ago
parent
commit
94ffd4bfc0

+ 10 - 0
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<NativeImage> 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)

+ 1 - 0
atom/browser/api/atom_api_tray.h

@@ -71,6 +71,7 @@ class Tray : public mate::TrackableObject<Tray>, 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> menu);

+ 0 - 3
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) {}

+ 6 - 3
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.

+ 1 - 0
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;

+ 9 - 1
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];