diff --git a/docs/api/tray.md b/docs/api/tray.md index 0452a83ce7c0..0411b9386798 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -161,7 +161,7 @@ Returns: Emitted when the mouse exits the tray icon. -#### Event: 'mouse-move' _macOS_ +#### Event: 'mouse-move' _macOS_ _Windows_ Returns: diff --git a/shell/browser/ui/win/notify_icon.cc b/shell/browser/ui/win/notify_icon.cc index c78b0f323698..231eb37f6c7a 100644 --- a/shell/browser/ui/win/notify_icon.cc +++ b/shell/browser/ui/win/notify_icon.cc @@ -65,6 +65,13 @@ void NotifyIcon::HandleClickEvent(int modifiers, } } +void NotifyIcon::HandleMouseMoveEvent(int modifiers) { + gfx::Point cursorPos = display::Screen::GetScreen()->GetCursorScreenPoint(); + // Omit event fired when tray icon is created but cursor is outside of it. + if (GetBounds().Contains(cursorPos)) + NotifyMouseMoved(cursorPos, modifiers); +} + void NotifyIcon::ResetIcon() { NOTIFYICONDATA icon_data; InitIconData(&icon_data); diff --git a/shell/browser/ui/win/notify_icon.h b/shell/browser/ui/win/notify_icon.h index 9a809223c97c..6c71034f15e7 100644 --- a/shell/browser/ui/win/notify_icon.h +++ b/shell/browser/ui/win/notify_icon.h @@ -44,6 +44,9 @@ class NotifyIcon : public TrayIcon { bool left_button_click, bool double_button_click); + // Handles a mouse move event from the user. + void HandleMouseMoveEvent(int modifiers); + // Re-creates the status tray icon now after the taskbar has been created. void ResetIcon(); diff --git a/shell/browser/ui/win/notify_icon_host.cc b/shell/browser/ui/win/notify_icon_host.cc index 0ec1b02a95ee..928e326b8aaa 100644 --- a/shell/browser/ui/win/notify_icon_host.cc +++ b/shell/browser/ui/win/notify_icon_host.cc @@ -170,6 +170,10 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd, (lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK), (lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK)); return TRUE; + + case WM_MOUSEMOVE: + win_icon->HandleMouseMoveEvent(GetKeyboardModifers()); + return TRUE; } } return ::DefWindowProc(hwnd, message, wparam, lparam);