]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Don't emit "clicked" event if there is menu attached
authorCheng Zhao <zcbenz@gmail.com>
Mon, 10 Aug 2015 04:18:00 +0000 (12:18 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 10 Aug 2015 04:18:00 +0000 (12:18 +0800)
atom/browser/ui/tray_icon_cocoa.mm

index 055ac12c40466699c6488c5fc5275f9f68d99f3d..3ac865cce5ab89df8cd5293ef4caeccd8d9e5099 100644 (file)
@@ -207,23 +207,26 @@ const CGFloat kVerticalTitleMargin = 2;
   }
   inMouseEventSequence_ = NO;
 
-  // Single click
-  if (event.clickCount == 1) {
-    if (menuController_) {
-      [statusItem_ popUpStatusItemMenu:[menuController_ menu]];
-    }
+  // Show menu when single clicked on the icon.
+  if (event.clickCount == 1 && menuController_)
+    [statusItem_ popUpStatusItemMenu:[menuController_ menu]];
+
+  // Don't emit click events when menu is showing.
+  if (menuController_)
+    return;
 
+  // Single click event.
+  if (event.clickCount == 1)
     trayIcon_->NotifyClicked(
         [self getBoundsFromEvent:event],
         ui::EventFlagsFromModifiers([event modifierFlags]));
-  }
 
-  // Double click
-  if (event.clickCount == 2 && !menuController_) {
+  // Double click event.
+  if (event.clickCount == 2)
     trayIcon_->NotifyDoubleClicked(
         [self getBoundsFromEvent:event],
         ui::EventFlagsFromModifiers([event modifierFlags]));
-  }
+
   [self setNeedsDisplay:YES];
 }