From: Soumyajyotii Ssarkar <[email protected]>

hid_reset() clears the pointer event queue but leaves the rest of the
mouse state alone. After a guest reboot the wheel and pan multipliers
the previous guest enabled would stay in effect and leftover residuals
would leak into the first reports of the new boot.

Reset the multipliers and residuals together with the queue. Also
clear mouse_grabbed, so that hid_pointer_activate() activates the input
handler again when the rebooted guest first polls the device, instead
of keeping the state from before the reset.

Suggested-by: Helge Deller <[email protected]>
Signed-off-by: Soumyajyotii Ssarkar <[email protected]>
---
 hw/input/hid.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/input/hid.c b/hw/input/hid.c
index bc84e99dbc..403cac127e 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -551,6 +551,11 @@ void hid_reset(HIDState *hs)
     case HID_MOUSE:
     case HID_TABLET:
         memset(hs->ptr.queue, 0, sizeof(hs->ptr.queue));
+        hs->ptr.mouse_grabbed = 0;
+        hs->ptr.wheel_multiplier = 0;
+        hs->ptr.pan_multiplier = 0;
+        hs->ptr.wheel_residual = 0;
+        hs->ptr.pan_residual = 0;
         break;
     }
     hs->head = 0;
-- 
2.56.0


Reply via email to