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] fix SDL mouse events processing

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] fix SDL mouse events processing
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Tue, 29 Jul 2008 10:59:46 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Delivery-date: Tue, 29 Jul 2008 02:59:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080505)
Hi all,
this patch fixes some SDL mouse event related issues; it was originally
posted on qemu-devel by Samuel:

http://lists.gnu.org/archive/html/qemu-devel/2008-03/msg00049.html

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---

diff --git a/sdl.c b/sdl.c
index 72e7d82..9afd884 100644
--- a/sdl.c
+++ b/sdl.c
@@ -492,8 +492,6 @@ static void sdl_grab_start(void)
 {
     sdl_hide_cursor();
     SDL_WM_GrabInput(SDL_GRAB_ON);
-    /* dummy read to avoid moving the mouse */
-    SDL_GetRelativeMouseState(NULL, NULL);
     gui_grab = 1;
     sdl_update_caption();
 }
@@ -685,39 +683,37 @@ static void sdl_refresh(DisplayState *ds)
                 absolute_enabled) {
                 int dx, dy, state;
                 state = SDL_GetRelativeMouseState(&dx, &dy);
-                sdl_send_mouse_event(dx, dy, 0, state);
+                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);
-            }
-            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)) {
+                        (bev->button == SDL_BUTTON_LEFT)) {
                         /* start grabbing all events */
                         sdl_grab_start();
                     }
                 } else {
-                    int dx, dy, dz, state;
+                    int dz, state;
                     dz = 0;
-                    state = SDL_GetRelativeMouseState(&dx, &dy);
+                    state = SDL_GetMouseState(NULL, NULL);
+                    if (ev->type == SDL_MOUSEBUTTONDOWN) {
+                        state |= SDL_BUTTON(bev->button);
+                    } else {
+                        state &= ~SDL_BUTTON(bev->button);
+                    }
 #ifdef SDL_BUTTON_WHEELUP
-                    if (bev->button == SDL_BUTTON_WHEELUP) {
+                    if (bev->button == SDL_BUTTON_WHEELUP && ev->type == 
SDL_MOUSEBUTTONDOWN) {
                         dz = -1;
-                    } else if (bev->button == SDL_BUTTON_WHEELDOWN) {
+                    } else if (bev->button == SDL_BUTTON_WHEELDOWN && ev->type 
== SDL_MOUSEBUTTONDOWN) {
                         dz = 1;
-                    } else {
-                        state = bev->button | state;
                     }
-#endif               
-                    sdl_send_mouse_event(dx, dy, dz, state);
+#endif
+                    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] fix SDL mouse events processing, Stefano Stabellini <=