From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JJSTw-0002YU-Va for qemu-devel@nongnu.org; Mon, 28 Jan 2008 06:48:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JJSTu-0002Xb-Ma for qemu-devel@nongnu.org; Mon, 28 Jan 2008 06:48:56 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JJSTu-0002XS-Ef for qemu-devel@nongnu.org; Mon, 28 Jan 2008 06:48:54 -0500 Received: from smtp02.citrix.com ([66.165.176.63]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JJSTt-000712-SQ for qemu-devel@nongnu.org; Mon, 28 Jan 2008 06:48:54 -0500 Received: from [172.31.33.111] (host217-46-209-99.in-addr.btopenworld.com [217.46.209.99]) (authenticated bits=0) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id m0SBmGBE018380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 28 Jan 2008 03:48:18 -0800 Message-ID: <479DC0F0.5050205@citrix.com> Date: Mon, 28 Jan 2008 11:48:00 +0000 From: Stefano Stabellini MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060108050504050107080806" Subject: [Qemu-devel] [PATCH] mouse click simple queue Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060108050504050107080806 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi all, qemu doesn't enqueue mouse events, just records the latest mouse state. This can cause some lost mouse double clicks if the events are not processed fast enought. I am attaching a patch that implements a simple queue for left mouse click events. Best Regards, Stefano Stabellini --------------060108050504050107080806 Content-Type: text/x-patch; name="mouseclick-queue.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mouseclick-queue.patch" Index: sdl.c =================================================================== RCS file: /sources/qemu/qemu/sdl.c,v retrieving revision 1.45 diff -r1.45 sdl.c 293c293 < static void sdl_send_mouse_event(int dz) --- > static void sdl_send_mouse_event(int dx, int dy, int dz, int state) 295,297c295,296 < int dx, dy, state, buttons; < state = SDL_GetRelativeMouseState(&dx, &dy); < buttons = 0; --- > int buttons = 0; > 314c313 < SDL_GetMouseState(&dx, &dy); --- > SDL_GetMouseState(&dx, &dy); 477c476,478 < sdl_send_mouse_event(0); --- > int dx, dy, state; > state = SDL_GetRelativeMouseState(&dx, &dy); > sdl_send_mouse_event(dx, dy, 0, state); 480d480 < case SDL_MOUSEBUTTONDOWN: 481a482,488 > if (gui_grab || kbd_mouse_is_absolute()) { > int dx, dy, state; > state = SDL_GetRelativeMouseState(&dx, &dy); > sdl_send_mouse_event(dx, dy, 0, state); > } > break; > case SDL_MOUSEBUTTONDOWN: 491c498 < int dz; --- > int dx, dy, dz, state; 492a500 > state = SDL_GetRelativeMouseState(&dx, &dy); 494c502 < if (bev->button == SDL_BUTTON_WHEELUP && ev->type == SDL_MOUSEBUTTONDOWN) { --- > if (bev->button == SDL_BUTTON_WHEELUP) { 496c504,505 < } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type == SDL_MOUSEBUTTONDOWN) { --- > } > else if (bev->button == SDL_BUTTON_WHEELDOWN) { 498a508,510 > else { > state = bev->button | state; > } 500c512 < sdl_send_mouse_event(dz); --- > sdl_send_mouse_event(dx, dy, dz, state); Index: hw/usb-hid.c =================================================================== RCS file: /sources/qemu/qemu/hw/usb-hid.c,v retrieving revision 1.16 diff -r1.16 usb-hid.c 386a387,395 > static int currentbutton = 0; > typedef struct _mouseclick { > int button_state; > struct _mouseclick *next; > } mouseclick; > static mouseclick mousequeue[20]; > static mouseclick *head = mousequeue; > static mouseclick *tail = mousequeue; > 392a402,414 > if (hs->changed == 1){ > //A mouse event is lost > if (buttons_state != currentbutton && tail->next != head) { > //A left click event is lost: let's add it to the queue > //counter++; > tail->button_state = buttons_state; > tail = tail->next; > } > } > else { > s->buttons_state = buttons_state; > } > 396d417 < s->buttons_state = buttons_state; 397a419 > currentbutton = buttons_state; 405a428,440 > if (hs->changed == 1){ > //A mouse event is lost > if (buttons_state != currentbutton && tail->next != head) { > //A left click event is lost: let's add it to the queue > //counter++; > tail->button_state = buttons_state; > tail = tail->next; > } > } > else { > s->buttons_state = buttons_state; > } > 409d443 < s->buttons_state = buttons_state; 410a445 > currentbutton = buttons_state; 779c814 < s->changed = 0; --- > 785a821,833 > > if ((s->kind == USB_MOUSE || s->kind == USB_TABLET) && s->changed) { > USBMouseState *ms = &s->ptr; > if (head != tail) { > ms->buttons_state = head->button_state; > head = head->next; > } > else { > s->changed = 0; > } > } else { > s->changed = 0; > } 810a859 > int i; 812a862,868 > for (i = 0; i < 19; i++) { > mousequeue[i].button_state = 0; > mousequeue[i].next = &(mousequeue[i + 1]); > } > mousequeue[i].button_state = 0; > mousequeue[i].next = mousequeue; > 833a890 > int i; 835a893,899 > for (i = 0; i < 19; i++) { > mousequeue[i].button_state = 0; > mousequeue[i].next = &(mousequeue[i + 1]); > } > mousequeue[i].button_state = 0; > mousequeue[i].next = mousequeue; > --------------060108050504050107080806--