diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2010-03-09 20:52:22 -0600 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-03-19 15:27:38 -0500 |
commit | 6fef28ee6e5e0a443857e67aa026d49b6bbdc1b6 (patch) | |
tree | 44ca8b9340ab1b8de2fefa84706ebbdcfe262c8f /hw/usb-hid.c | |
parent | d1e70c5e6d1472856c52969301247fe8c3c8389d (diff) | |
download | qemu-6fef28ee6e5e0a443857e67aa026d49b6bbdc1b6.zip qemu-6fef28ee6e5e0a443857e67aa026d49b6bbdc1b6.tar.gz qemu-6fef28ee6e5e0a443857e67aa026d49b6bbdc1b6.tar.bz2 |
Rewrite mouse handlers to use QTAILQ and to have an activation function
And convert usb-hid to use it (to avoid regression with bisection)
Right now, when we do info mice and we've added a usb tablet, we don't see it
until the guest starts using the tablet. We implement this behavior in order
to provide a means to delay registration of a mouse handler since we treat
the last registered handler as the current handler.
This is a usability problem though as we would like to give the user feedback
that they've either 1) not added an absolute device 2) there is an absolute
device but the guest isn't using it 3) we have an absolute device and it's
active.
By using QTAILQ and having an explicit activation function that moves the
handler to the front of the queue, we can implement the same semantics as
before with respect to automatically switching to usb tablet while providing
the user with a whole lot more information.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-hid.c')
-rw-r--r-- | hw/usb-hid.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/hw/usb-hid.c b/hw/usb-hid.c index 2e4e647..8e6c6e0 100644 --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -511,8 +511,7 @@ static int usb_mouse_poll(USBHIDState *hs, uint8_t *buf, int len) USBMouseState *s = &hs->ptr; if (!s->mouse_grabbed) { - s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, hs, - 0, "QEMU USB Mouse"); + qemu_activate_mouse_event_handler(s->eh_entry); s->mouse_grabbed = 1; } @@ -553,8 +552,7 @@ static int usb_tablet_poll(USBHIDState *hs, uint8_t *buf, int len) USBMouseState *s = &hs->ptr; if (!s->mouse_grabbed) { - s->eh_entry = qemu_add_mouse_event_handler(usb_tablet_event, hs, - 1, "QEMU USB Tablet"); + qemu_activate_mouse_event_handler(s->eh_entry); s->mouse_grabbed = 1; } @@ -866,6 +864,15 @@ static int usb_hid_initfn(USBDevice *dev, int kind) USBHIDState *s = DO_UPCAST(USBHIDState, dev, dev); s->dev.speed = USB_SPEED_FULL; s->kind = kind; + + if (s->kind == USB_MOUSE) { + s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s, + 0, "QEMU USB Mouse"); + } else if (s->kind == USB_TABLET) { + s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_tablet_event, s, + 1, "QEMU USB Tablet"); + } + /* Force poll routine to be run and grab input the first time. */ s->changed = 1; return 0; |