mirror of
https://github.com/electron/electron.git
synced 2026-01-28 16:58:21 -05:00
feat: support mouse-move event of Tray API on Windows (#19265)
* add Tray.mouse-move on win * change docs
This commit is contained in:
committed by
Shelley Vohr
parent
9711fc895e
commit
2467350180
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user