From 38518afad8ee05d303e612159c7733345c251c27 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 5 Jan 2011 15:29:16 -0200 Subject: [PATCH 11/48] vmmouse: adapt to mouse handler changes. RH-Author: Gerd Hoffmann Message-id: <1294241382-17988-13-git-send-email-kraxel@redhat.com> Patchwork-id: 15742 O-Subject: [RHEL-6 kvm PATCH 12/38] vmmouse: adapt to mouse handler changes. Bugzilla: 642131 634153 615947 632458 631832 647865 RH-Acked-by: Uri Lublin RH-Acked-by: Alon Levy RH-Acked-by: Hans de Goede This patch updates the vmmouse handler registration and activation. Old behavior: vmmouse_read_id, vmmouse_request_relative and vmmouse_request_absolute unregister the handler and re-register it. New behavior: vmmouse_request_relative and vmmouse_request_absolute will unregister the handler in case the mode did change. Then register and active the handler with current mode if needed. Note that the old code never ever *activates* the handler, so the vmmouse doesn't receive events. This trips up Fedora 14 for example: Boot a default install without usb tablet, watch the X-Server activating the vmmouse then, enjoy a non-functional mouse. upstream: cd496926155afcb3b6323e70dd720dc118b3a255 Signed-off-by: Gerd Hoffmann Signed-off-by: Anthony Liguori --- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) Signed-off-by: Luiz Capitulino --- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/hw/vmmouse.c b/hw/vmmouse.c index 51b6e31..c6f1a2e 100644 --- a/hw/vmmouse.c +++ b/hw/vmmouse.c @@ -100,16 +100,29 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_ ps2_mouse_fake_event(s->ps2_mouse); } -static void vmmouse_update_handler(VMMouseState *s) +static void vmmouse_remove_handler(VMMouseState *s) { if (s->entry) { qemu_remove_mouse_event_handler(s->entry); s->entry = NULL; } - if (s->status == 0) +} + +static void vmmouse_update_handler(VMMouseState *s, int absolute) +{ + if (s->status != 0) { + return; + } + if (s->absolute != absolute) { + s->absolute = absolute; + vmmouse_remove_handler(s); + } + if (s->entry == NULL) { s->entry = qemu_add_mouse_event_handler(vmmouse_mouse_event, s, s->absolute, "vmmouse"); + qemu_activate_mouse_event_handler(s->entry); + } } static void vmmouse_read_id(VMMouseState *s) @@ -121,28 +134,25 @@ static void vmmouse_read_id(VMMouseState *s) s->queue[s->nb_queue++] = VMMOUSE_VERSION; s->status = 0; - vmmouse_update_handler(s); } static void vmmouse_request_relative(VMMouseState *s) { DPRINTF("vmmouse_request_relative()\n"); - s->absolute = 0; - vmmouse_update_handler(s); + vmmouse_update_handler(s, 0); } static void vmmouse_request_absolute(VMMouseState *s) { DPRINTF("vmmouse_request_absolute()\n"); - s->absolute = 1; - vmmouse_update_handler(s); + vmmouse_update_handler(s, 1); } static void vmmouse_disable(VMMouseState *s) { DPRINTF("vmmouse_disable()\n"); s->status = 0xffff; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); } static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size) @@ -154,7 +164,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size) if (size == 0 || size > 6 || size > s->nb_queue) { printf("vmmouse: driver requested too much data %d\n", size); s->status = 0xffff; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); return; } @@ -239,7 +249,8 @@ static int vmmouse_post_load(void *opaque, int version_id) { VMMouseState *s = opaque; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); + vmmouse_update_handler(s, s->absolute); return 0; } -- 1.7.4.rc1.16.gd2f15e