From 87b60efb859d86fd9e96306112bc5453a549fa69 Mon Sep 17 00:00:00 2001 From: Colin Harrison Date: Sun, 2 Sep 2012 22:39:32 +0100 Subject: [PATCH] hw/xwin: Don't spam MotionNotify events when the mouse hasn't moved Don't spam MotionNotify events when the mouse hasn't moved, when polling the mouse position outside any X window (Test with 'xev -root' after mouse polling has started.) Signed-off-by: Colin Harrison Reviewed-by: Jon TURNEY --- hw/xwin/winwndproc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index fe662b9ba..7ba028042 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -930,6 +930,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WIN_POLLING_MOUSE_TIMER_ID: { + static POINT last_point; POINT point; WPARAM wL, wM, wR, wShift, wCtrl; LPARAM lPos; @@ -941,8 +942,12 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) point.x -= GetSystemMetrics(SM_XVIRTUALSCREEN); point.y -= GetSystemMetrics(SM_YVIRTUALSCREEN); - /* Deliver absolute cursor position to X Server */ - winEnqueueMotion(point.x, point.y); + /* If the mouse pointer has moved, deliver absolute cursor position to X Server */ + if (last_point.x != point.x || last_point.y != point.y) { + winEnqueueMotion(point.x, point.y); + last_point.x = point.x; + last_point.y = point.y; + } /* Check if a button was released but we didn't see it */ GetCursorPos(&point);