Skip to content

Commit

Permalink
refactor: refactor MouseProc
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed May 9, 2024
1 parent d28fe91 commit 91bef9d
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions src/tabbookmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down

0 comments on commit 91bef9d

Please sign in to comment.