mouse fixups
cover mouse fixups
Hi,
In the 0.13 devel cycle the mouse handler activation code has been updated, but (at least) two drivers have not been updated accordingly:
vmmouse and usb-wacom. This patch series updates them so they are functional again.
IMHO the patches should also be cherry-picked into stable.
The patches are also available in the git repository at:
git://anongit.freedesktop.org/spice/qemu mouse.1
Gerd Hoffmann (2):
vmmouse: adapt to mouse handler changes.
wacom tablet: activate event handlers.
hw/usb-wacom.c | 13 ++++++++++--- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-)
PATCH 1/2 vmmouse: adapt to mouse handler changes.
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.
--- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
hw/vmmouse.c +21 -10
@@ -100,16 +100,29 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_i8042_isa_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 ; }
Signature · 1 line
1.7.1
PATCH 2/2 wacom tablet: activate event handlers.
In reply to Gerd HoffmannAdd qemu_activate_mouse_event_handler() calls to the usb wavom tablet so it actually receives events. Also make sure we only remove the handler if we registered it before.
--- hw/usb-wacom.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
hw/usb-wacom.c +10 -3
@@ -160,6 +160,7 @@ static int usb_mouse_poll(USBWacomState *s, uint8_t *buf, int len)if (!s->mouse_grabbed) { s->eh_entry =qemu_add_mouse_event_handler (usb_mouse_event, s,0 ,"QEMU PenPartner tablet" ); +qemu_activate_mouse_event_handler (s->eh_entry); s->mouse_grabbed =1 ; }
@@ -197,6 +198,7 @@ static int usb_wacom_poll(USBWacomState *s, uint8_t *buf, int len)if (!s->mouse_grabbed) { s->eh_entry =qemu_add_mouse_event_handler (usb_wacom_event, s,1 ,"QEMU PenPartner tablet" ); +qemu_activate_mouse_event_handler (s->eh_entry); s->mouse_grabbed =1 ; }
@@ -334,8 +336,10 @@ static int usb_wacom_handle_control(USBDevice *dev, int request, int value, ret =0 ;break ;case WACOM_SET_REPORT : -qemu_remove_mouse_event_handler (s->eh_entry); - s->mouse_grabbed =0 ; +if (s->mouse_grabbed) { +qemu_remove_mouse_event_handler (s->eh_entry); + s->mouse_grabbed =0 ; + } s->mode = data[0 ]; ret =0 ;break ;
@@ -397,7 +401,10 @@ static void usb_wacom_handle_destroy(USBDevice *dev) {USBWacomState *s = (USBWacomState *) dev; -qemu_remove_mouse_event_handler (s->eh_entry); +if (s->mouse_grabbed) { +qemu_remove_mouse_event_handler (s->eh_entry); + s->mouse_grabbed =0 ; + } }static int usb_wacom_initfn (USBDevice *dev)
Signature · 1 line
1.7.1
Anthony Liguori
AppliedQuoted 7 lines · Gerd Hoffmann
Hi,In the 0.13 devel cycle the mouse handler activation code has been updated, but (at least) two drivers have not been updated accordingly:
vmmouse and usb-wacom. This patch series updates them so they are functional again.
Quoted 6 lines
IMHO the patches should also be cherry-picked into stable.
The patches are also available in the git repository at:
git://anongit.freedesktop.org/spice/qemumouse.1
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 10 lines
Gerd Hoffmann (2):
vmmouse: adapt to mouse handler changes.
wacom tablet: activate event handlers.hw/usb-wacom.c | 13 ++++++++++--- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-)