[c-host] mousehook: ignore repeated hook events

This commit is contained in:
Geoffrey McRae 2020-01-26 16:23:35 +11:00
parent 687eddcc63
commit b4cf8f76c8
2 changed files with 9 additions and 3 deletions

View file

@ -1 +1 @@
B1-106-g9d6d137b50+1
B1-107-g687eddcc63+1

View file

@ -29,6 +29,7 @@ struct mouseHook
bool installed;
HHOOK hook;
MouseHookFn callback;
int x, y;
};
static struct mouseHook mouseHook = { 0 };
@ -92,7 +93,12 @@ static LRESULT WINAPI mouseHook_hook(int nCode, WPARAM wParam, LPARAM lParam)
if (nCode == HC_ACTION && wParam == WM_MOUSEMOVE)
{
MSLLHOOKSTRUCT *msg = (MSLLHOOKSTRUCT *)lParam;
mouseHook.callback(msg->pt.x, msg->pt.y);
if (mouseHook.x != msg->pt.x || mouseHook.y != msg->pt.y)
{
mouseHook.x = msg->pt.x;
mouseHook.y = msg->pt.y;
mouseHook.callback(msg->pt.x, msg->pt.y);
}
}
return CallNextHookEx(mouseHook.hook, nCode, wParam, lParam);
}
}