Blame 0041-vmmouse-adapt-to-mouse-handler-changes.patch

Justin M. Forbes 502ffe
From ff53b62094b009f34dd3312e32a637ca73c752e3 Mon Sep 17 00:00:00 2001
Justin M. Forbes 502ffe
From: Gerd Hoffmann <kraxel@redhat.com>
Justin M. Forbes 502ffe
Date: Fri, 8 Oct 2010 00:30:13 +0000
Justin M. Forbes 502ffe
Subject: [PATCH 41/42] vmmouse: adapt to mouse handler changes.
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
This patch updates the vmmouse handler registration and activation.
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
Old behavior:
Justin M. Forbes 502ffe
  vmmouse_read_id, vmmouse_request_relative and vmmouse_request_absolute
Justin M. Forbes 502ffe
  unregister the handler and re-register it.
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
New behavior:
Justin M. Forbes 502ffe
  vmmouse_request_relative and vmmouse_request_absolute will unregister
Justin M. Forbes 502ffe
  the handler in case the mode did change.  Then register and active the
Justin M. Forbes 502ffe
  handler with current mode if needed.
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
Note that the old code never ever *activates* the handler, so the
Justin M. Forbes 502ffe
vmmouse doesn't receive events.  This trips up Fedora 14 for example:
Justin M. Forbes 502ffe
Boot a default install without usb tablet, watch the X-Server activating
Justin M. Forbes 502ffe
the vmmouse then, enjoy a non-functional mouse.
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Justin M. Forbes 502ffe
---
Justin M. Forbes 502ffe
 hw/vmmouse.c |   31 +++++++++++++++++++++----------
Justin M. Forbes 502ffe
 1 files changed, 21 insertions(+), 10 deletions(-)
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
Justin M. Forbes 502ffe
index f359304..2097119 100644
Justin M. Forbes 502ffe
--- a/hw/vmmouse.c
Justin M. Forbes 502ffe
+++ b/hw/vmmouse.c
Justin M. Forbes 502ffe
@@ -100,16 +100,29 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_
Justin M. Forbes 502ffe
     i8042_isa_mouse_fake_event(s->ps2_mouse);
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
-static void vmmouse_update_handler(VMMouseState *s)
Justin M. Forbes 502ffe
+static void vmmouse_remove_handler(VMMouseState *s)
Justin M. Forbes 502ffe
 {
Justin M. Forbes 502ffe
     if (s->entry) {
Justin M. Forbes 502ffe
         qemu_remove_mouse_event_handler(s->entry);
Justin M. Forbes 502ffe
         s->entry = NULL;
Justin M. Forbes 502ffe
     }
Justin M. Forbes 502ffe
-    if (s->status == 0)
Justin M. Forbes 502ffe
+}
Justin M. Forbes 502ffe
+
Justin M. Forbes 502ffe
+static void vmmouse_update_handler(VMMouseState *s, int absolute)
Justin M. Forbes 502ffe
+{
Justin M. Forbes 502ffe
+    if (s->status != 0) {
Justin M. Forbes 502ffe
+        return;
Justin M. Forbes 502ffe
+    }
Justin M. Forbes 502ffe
+    if (s->absolute != absolute) {
Justin M. Forbes 502ffe
+        s->absolute = absolute;
Justin M. Forbes 502ffe
+        vmmouse_remove_handler(s);
Justin M. Forbes 502ffe
+    }
Justin M. Forbes 502ffe
+    if (s->entry == NULL) {
Justin M. Forbes 502ffe
         s->entry = qemu_add_mouse_event_handler(vmmouse_mouse_event,
Justin M. Forbes 502ffe
                                                 s, s->absolute,
Justin M. Forbes 502ffe
                                                 "vmmouse");
Justin M. Forbes 502ffe
+        qemu_activate_mouse_event_handler(s->entry);
Justin M. Forbes 502ffe
+    }
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
 static void vmmouse_read_id(VMMouseState *s)
Justin M. Forbes 502ffe
@@ -121,28 +134,25 @@ static void vmmouse_read_id(VMMouseState *s)
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
     s->queue[s->nb_queue++] = VMMOUSE_VERSION;
Justin M. Forbes 502ffe
     s->status = 0;
Justin M. Forbes 502ffe
-    vmmouse_update_handler(s);
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
 static void vmmouse_request_relative(VMMouseState *s)
Justin M. Forbes 502ffe
 {
Justin M. Forbes 502ffe
     DPRINTF("vmmouse_request_relative()\n");
Justin M. Forbes 502ffe
-    s->absolute = 0;
Justin M. Forbes 502ffe
-    vmmouse_update_handler(s);
Justin M. Forbes 502ffe
+    vmmouse_update_handler(s, 0);
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
 static void vmmouse_request_absolute(VMMouseState *s)
Justin M. Forbes 502ffe
 {
Justin M. Forbes 502ffe
     DPRINTF("vmmouse_request_absolute()\n");
Justin M. Forbes 502ffe
-    s->absolute = 1;
Justin M. Forbes 502ffe
-    vmmouse_update_handler(s);
Justin M. Forbes 502ffe
+    vmmouse_update_handler(s, 1);
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
 static void vmmouse_disable(VMMouseState *s)
Justin M. Forbes 502ffe
 {
Justin M. Forbes 502ffe
     DPRINTF("vmmouse_disable()\n");
Justin M. Forbes 502ffe
     s->status = 0xffff;
Justin M. Forbes 502ffe
-    vmmouse_update_handler(s);
Justin M. Forbes 502ffe
+    vmmouse_remove_handler(s);
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
 static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size)
Justin M. Forbes 502ffe
@@ -154,7 +164,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size)
Justin M. Forbes 502ffe
     if (size == 0 || size > 6 || size > s->nb_queue) {
Justin M. Forbes 502ffe
         printf("vmmouse: driver requested too much data %d\n", size);
Justin M. Forbes 502ffe
         s->status = 0xffff;
Justin M. Forbes 502ffe
-        vmmouse_update_handler(s);
Justin M. Forbes 502ffe
+        vmmouse_remove_handler(s);
Justin M. Forbes 502ffe
         return;
Justin M. Forbes 502ffe
     }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
@@ -239,7 +249,8 @@ static int vmmouse_post_load(void *opaque, int version_id)
Justin M. Forbes 502ffe
 {
Justin M. Forbes 502ffe
     VMMouseState *s = opaque;
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
-    vmmouse_update_handler(s);
Justin M. Forbes 502ffe
+    vmmouse_remove_handler(s);
Justin M. Forbes 502ffe
+    vmmouse_update_handler(s, s->absolute);
Justin M. Forbes 502ffe
     return 0;
Justin M. Forbes 502ffe
 }
Justin M. Forbes 502ffe
Justin M. Forbes 502ffe
-- 
Justin M. Forbes 502ffe
1.7.2.3
Justin M. Forbes 502ffe