From 9afa94f4b8a9f9ebe6ac3851f638bcfbd71ddc2e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 29 Jul 2015 12:36:01 +0800 Subject: [PATCH] win: Implement double-clicked event --- atom/browser/ui/win/notify_icon.cc | 15 +++++++++------ atom/browser/ui/win/notify_icon.h | 4 +++- atom/browser/ui/win/notify_icon_host.cc | 7 ++++++- atom/common/api/atom_api_native_image.cc | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 450fd08..ed422b8 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -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,14 +73,16 @@ 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) { - NotifyClicked(gfx::Rect(rect)); + 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); } - - NotifyRightClicked(gfx::Rect(rect)); - PopContextMenu(cursor_pos); } void NotifyIcon::ResetIcon() { diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index 25ba8c8..c004d5f 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -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(); diff --git a/atom/browser/ui/win/notify_icon_host.cc b/atom/browser/ui/win/notify_icon_host.cc index 4aac629..33ac722 100644 --- a/atom/browser/ui/win/notify_icon_host.cc +++ b/atom/browser/ui/win/notify_icon_host.cc @@ -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; } } diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index ee9bb71..7819e31 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -183,6 +183,7 @@ void NativeImage::SetTemplateImage(bool setAsTemplate) { } bool NativeImage::IsTemplateImage() { + return false; } #endif -- 2.7.4