win: Implement double-clicked event
authorCheng Zhao <zcbenz@gmail.com>
Wed, 29 Jul 2015 04:36:01 +0000 (12:36 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 29 Jul 2015 04:36:01 +0000 (12:36 +0800)
atom/browser/ui/win/notify_icon.cc
atom/browser/ui/win/notify_icon.h
atom/browser/ui/win/notify_icon_host.cc
atom/common/api/atom_api_native_image.cc

index 450fd08..ed422b8 100644 (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,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() {
index 25ba8c8..c004d5f 100644 (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();
index 4aac629..33ac722 100644 (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;
     }
   }
index ee9bb71..7819e31 100644 (file)
@@ -183,6 +183,7 @@ void NativeImage::SetTemplateImage(bool setAsTemplate) {
 }
 
 bool NativeImage::IsTemplateImage() {
+  return false;
 }
 #endif