WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] ioemu: fix SDL mouse events processing

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] ioemu: fix SDL mouse events processing
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Wed, 5 Mar 2008 11:47:04 +0000
Delivery-date: Wed, 05 Mar 2008 03:48:04 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
ioemu: fix SDL mouse events processing
- GetRelativeMouseState always returns the last position, so when the
  polling loop gets several mouse events in one go, we would send
  useless 'no move' events.
- So as to make sure we don't miss any mouse click / double click, we
  should not use GetRelativeMouseState() to get the button state, but
  keep records of the button state ourselves.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 86e64b684fb2 tools/ioemu/sdl.c
--- a/tools/ioemu/sdl.c Wed Mar 05 11:10:29 2008 +0000
+++ b/tools/ioemu/sdl.c Wed Mar 05 11:41:24 2008 +0000
@@ -360,6 +360,7 @@
 {
     SDL_Event ev1, *ev = &ev1;
     int mod_state;
+    int state;
                      
     if (last_vm_running != vm_running) {
         last_vm_running = vm_running;
@@ -368,6 +369,7 @@
 
     vga_hw_update();
 
+    state = SDL_GetMouseState(NULL, NULL);
     while (SDL_PollEvent(ev)) {
         switch (ev->type) {
         case SDL_VIDEOEXPOSE:
@@ -475,41 +477,38 @@
         case SDL_MOUSEMOTION:
             if (gui_grab || kbd_mouse_is_absolute() ||
                 absolute_enabled) {
-                int dx, dy, state;
-                state = SDL_GetRelativeMouseState(&dx, &dy);
-                sdl_send_mouse_event(dx, dy, 0, state);
+                int dx, dy;
+                SDL_GetRelativeMouseState(&dx, &dy);
+                if (dx || dy)
+                    sdl_send_mouse_event(dx, dy, 0, state);
             }
             break;
         case SDL_MOUSEBUTTONUP:
             if (gui_grab || kbd_mouse_is_absolute()) {
-                int dx, dy, state;
-                state = SDL_GetRelativeMouseState(&dx, &dy);
-                sdl_send_mouse_event(dx, dy, 0, state);
+                state &= ~SDL_BUTTON(ev->button.button);
+                sdl_send_mouse_event(0, 0, 0, state);
             }
             break;
         case SDL_MOUSEBUTTONDOWN:
             {
                 SDL_MouseButtonEvent *bev = &ev->button;
                 if (!gui_grab && !kbd_mouse_is_absolute()) {
-                    if (ev->type == SDL_MOUSEBUTTONDOWN &&
-                        (bev->state & SDL_BUTTON_LMASK)) {
+                    if (bev->button == SDL_BUTTON_LEFT) {
                         /* start grabbing all events */
                         sdl_grab_start();
                     }
                 } else {
-                    int dx, dy, dz, state;
+                    int dz;
                     dz = 0;
-                    state = SDL_GetRelativeMouseState(&dx, &dy);
+                    state |= SDL_BUTTON(bev->button);
 #ifdef SDL_BUTTON_WHEELUP
                     if (bev->button == SDL_BUTTON_WHEELUP) {
                         dz = -1;
                     } else if (bev->button == SDL_BUTTON_WHEELDOWN) {
                         dz = 1;
-                    } else {
-                        state = bev->button | state;
                     }
 #endif               
-                    sdl_send_mouse_event(dx, dy, dz, state);
+                    sdl_send_mouse_event(0, 0, dz, state);
                 }
             }
             break;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] ioemu: fix SDL mouse events processing, Samuel Thibault <=