]> khamidou — GitHub mirrors - electron.git/commitdiff
Added `bounds` payload to tray `clicked` event
authorSeppe Stas <seppe.stas@fifthplay.com>
Tue, 2 Jun 2015 19:43:37 +0000 (21:43 +0200)
committerSeppe Stas <seppe.stas@fifthplay.com>
Tue, 2 Jun 2015 19:43:37 +0000 (21:43 +0200)
Used [Shell_NotifyIconGetRect function](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378426) to get the bounds of the application's tray icon.
Note: only works with Windows 7 and later.

Related to #1159, #1500.

atom/browser/ui/win/notify_icon.cc

index 99b7153631af2fa645f883f55c1e7ad98beb120e..bce2589018618154c537f2beab1b868287f83039 100644 (file)
@@ -49,7 +49,18 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos,
                                   bool left_mouse_click) {
   // Pass to the observer if appropriate.
   if (left_mouse_click) {
-    NotifyClicked();
+    NOTIFYICONIDENTIFIER icon_id;
+    memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
+    icon_id.uID = icon_id_;
+    icon_id.hWnd = window_;
+    icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER);
+
+    RECT rect;
+    Shell_NotifyIconGetRect(&icon_id, &rect);
+
+    int width = rect.right - rect.left;
+    int height =  rect.bottom - rect.top;
+    NotifyClicked(gfx::Rect(rect.left, rect.top, width, height));
     return;
   }