win: Implement double-clicked event

This commit is contained in:
Cheng Zhao 2015-07-29 12:36:01 +08:00
parent edde653d60
commit 9afa94f4b8
4 changed files with 19 additions and 8 deletions

View file

@ -63,7 +63,8 @@ NotifyIcon::~NotifyIcon() {
}
void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
bool left_mouse_click) {
bool left_mouse_click,
bool double_button_click) {
NOTIFYICONIDENTIFIER icon_id;
memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
icon_id.uID = icon_id_;
@ -72,15 +73,17 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
RECT rect = { 0 };
Shell_NotifyIconGetRect(&icon_id, &rect);
// Pass to the observer if appropriate.
if (left_mouse_click) {
if (double_button_click) // double left click
NotifyDoubleClicked(gfx::Rect(rect));
else // single left click
NotifyClicked(gfx::Rect(rect));
return;
}
} else if (!double_button_click) { // single right click
NotifyRightClicked(gfx::Rect(rect));
PopContextMenu(cursor_pos);
}
}
void NotifyIcon::ResetIcon() {
NOTIFYICONDATA icon_data;

View file

@ -33,7 +33,9 @@ class NotifyIcon : public TrayIcon {
// Handles a click event from the user - if |left_button_click| is true and
// there is a registered observer, passes the click event to the observer,
// otherwise displays the context menu if there is one.
void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click);
void HandleClickEvent(const gfx::Point& cursor_pos,
bool left_button_click,
bool double_button_click);
// Re-creates the status tray icon now after the taskbar has been created.
void ResetIcon();

View file

@ -146,12 +146,17 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_CONTEXTMENU:
// Walk our icons, find which one was clicked on, and invoke its
// HandleClickEvent() method.
gfx::Point cursor_pos(
gfx::Screen::GetNativeScreen()->GetCursorScreenPoint());
win_icon->HandleClickEvent(cursor_pos, lparam == WM_LBUTTONDOWN);
win_icon->HandleClickEvent(
cursor_pos,
(lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK),
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK));
return TRUE;
}
}

View file

@ -183,6 +183,7 @@ void NativeImage::SetTemplateImage(bool setAsTemplate) {
}
bool NativeImage::IsTemplateImage() {
return false;
}
#endif