From 91bef9dff02730634f86ceab3f027000052c8f9f Mon Sep 17 00:00:00 2001 From: Bush2021 <79072750+Bush2021@users.noreply.github.com> Date: Thu, 9 May 2024 15:27:22 -0400 Subject: [PATCH] refactor: refactor `MouseProc` --- src/tabbookmark.h | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/src/tabbookmark.h b/src/tabbookmark.h index a9311ba..f41645f 100644 --- a/src/tabbookmark.h +++ b/src/tabbookmark.h @@ -240,45 +240,22 @@ bool HandleBookmarkMenu(WPARAM wParam, PMOUSEHOOKSTRUCT pmouse) { } LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) { - static bool wheel_tab_ing = false; - static bool double_click_ing = false; - if (nCode != HC_ACTION) { return CallNextHookEx(mouse_hook, nCode, wParam, lParam); } - if (nCode == HC_ACTION) { - PMOUSEHOOKSTRUCT pmouse = (PMOUSEHOOKSTRUCT)lParam; - + do { if (wParam == WM_MOUSEMOVE || wParam == WM_NCMOUSEMOVE) { - return CallNextHookEx(mouse_hook, nCode, wParam, lParam); + break; } + PMOUSEHOOKSTRUCT pmouse = (PMOUSEHOOKSTRUCT)lParam; // Defining a `dwExtraInfo` value to prevent hook the message sent by // Chrome++ itself. if (pmouse->dwExtraInfo == MAGIC_CODE) { - // DebugLog(L"MAGIC_CODE %x", wParam); - goto next; + break; } - if (wParam == WM_RBUTTONUP && wheel_tab_ing) { - // DebugLog(L"wheel_tab_ing"); - wheel_tab_ing = false; - return 1; - } - - // if (wParam == WM_MBUTTONDOWN) - //{ - // //DebugLog(L"wheel_tab_ing"); - // return 1; - // } - // if (wParam == WM_LBUTTONUP && double_click_ing) - //{ - // //DebugLog(L"double_click_ing"); - // double_click_ing = false; - // return 1; - // } - if (HandleMouseWheel(wParam, lParam, pmouse)) { return 1; } @@ -304,9 +281,7 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) { if (HandleBookmarkMenu(wParam, pmouse)) { return 1; } - } -next: - // DebugLog(L"CallNextHookEx %X", wParam); + } while (0); return CallNextHookEx(mouse_hook, nCode, wParam, lParam); }