feat: add middle click event to tray (#39926)

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
Tomasz 2023-09-27 20:21:15 +02:00 committed by GitHub
parent 480f48b2fc
commit 689d1b76de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 3 deletions

View file

@ -73,7 +73,8 @@ NotifyIcon::~NotifyIcon() {
void NotifyIcon::HandleClickEvent(int modifiers,
bool left_mouse_click,
bool double_button_click) {
bool double_button_click,
bool middle_button_click) {
gfx::Rect bounds = GetBounds();
if (left_mouse_click) {
@ -84,6 +85,8 @@ void NotifyIcon::HandleClickEvent(int modifiers,
display::Screen::GetScreen()->GetCursorScreenPoint(),
modifiers);
return;
} else if (middle_button_click) { // single middle click
NotifyMiddleClicked(bounds, modifiers);
} else if (!double_button_click) { // single right click
if (menu_model_)
PopUpContextMenu(gfx::Point(), menu_model_->GetWeakPtr());

View file

@ -45,7 +45,8 @@ class NotifyIcon : public TrayIcon {
// otherwise displays the context menu if there is one.
void HandleClickEvent(int modifiers,
bool left_button_click,
bool double_button_click);
bool double_button_click,
bool middle_button_click);
// Handles a mouse move event from the user.
void HandleMouseMoveEvent(int modifiers);

View file

@ -189,8 +189,10 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_LBUTTONDBLCLK:
case WM_RBUTTONDBLCLK:
case WM_MBUTTONDBLCLK:
case WM_CONTEXTMENU:
// Walk our icons, find which one was clicked on, and invoke its
// HandleClickEvent() method.
@ -200,7 +202,8 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd,
&NotifyIcon::HandleClickEvent, win_icon_weak,
GetKeyboardModifiers(),
(lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK),
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK)));
(lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK),
(lparam == WM_MBUTTONDOWN || lparam == WM_MBUTTONDBLCLK)));
return TRUE;