clean up ignore double click event implementation

This commit is contained in:
mikeykhalil 2018-04-28 20:07:32 -07:00
parent 664e14b91f
commit 208374afa4
2 changed files with 6 additions and 12 deletions

View file

@ -177,7 +177,9 @@ void Tray::SetHighlightMode(TrayIcon::HighlightMode mode) {
} }
void Tray::SetIgnoreDoubleClickEvents(bool ignore) { void Tray::SetIgnoreDoubleClickEvents(bool ignore) {
#if defined(OS_MACOSX)
tray_icon_->SetIgnoreDoubleClickEvents(ignore); tray_icon_->SetIgnoreDoubleClickEvents(ignore);
#endif
} }
void Tray::DisplayBalloon(mate::Arguments* args, void Tray::DisplayBalloon(mate::Arguments* args,

View file

@ -287,24 +287,16 @@ const CGFloat kVerticalTitleMargin = 2;
// If we are ignoring double click events, we should ignore the `clickCount` // If we are ignoring double click events, we should ignore the `clickCount`
// value and immediately emit a click event. // value and immediately emit a click event.
if (ignoreDoubleClickEvents_ == YES) { BOOL shouldBeHandledAsASingleClick = (event.clickCount == 1) || ignoreDoubleClickEvents_;
trayIcon_->NotifyClicked( if (shouldBeHandledAsASingleClick)
gfx::ScreenRectFromNSRect(event.window.frame),
gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags]));
[self setNeedsDisplay:YES];
return;
}
// Single click event.
if (event.clickCount == 1)
trayIcon_->NotifyClicked( trayIcon_->NotifyClicked(
gfx::ScreenRectFromNSRect(event.window.frame), gfx::ScreenRectFromNSRect(event.window.frame),
gfx::ScreenPointFromNSPoint([event locationInWindow]), gfx::ScreenPointFromNSPoint([event locationInWindow]),
ui::EventFlagsFromModifiers([event modifierFlags])); ui::EventFlagsFromModifiers([event modifierFlags]));
// Double click event. // Double click event.
if (event.clickCount == 2) BOOL shouldBeHandledAsADoubleClick = (event.clickCount == 2) && !ignoreDoubleClickEvents_;
if (shouldBeHandledAsADoubleClick)
trayIcon_->NotifyDoubleClicked( trayIcon_->NotifyDoubleClicked(
gfx::ScreenRectFromNSRect(event.window.frame), gfx::ScreenRectFromNSRect(event.window.frame),
ui::EventFlagsFromModifiers([event modifierFlags])); ui::EventFlagsFromModifiers([event modifierFlags]));