Bug#798265: Please apply upstream mouse event duplication patch

RjY rjy at users.sourceforge.net
Mon Sep 7 13:51:19 UTC 2015


Source: libsdl2
Version: 2.0.2+dfsg1-7
Severity: wishlist
Tags: patch fixed-upstream

Please apply this patch, cherry-picked from unreleased 2.0.4 upstream:

https://hg.libsdl.org/SDL/rev/957a6ed39ad0

as it fixes some very annoying mouse behaviour in SDL2.

-8<-----------------------------------------------

diff -r fd60d77139fc -r 957a6ed39ad0 src/video/x11/SDL_x11xinput2.c
--- a/src/video/x11/SDL_x11xinput2.c	Mon Jun 08 01:52:43 2015 -0400
+++ b/src/video/x11/SDL_x11xinput2.c	Mon Jun 08 02:58:46 2015 -0400
@@ -136,15 +136,25 @@
         case XI_RawMotion: {
             const XIRawEvent *rawev = (const XIRawEvent*)cookie->data;
             SDL_Mouse *mouse = SDL_GetMouse();
-            double relative_cords[2];
+            double relative_coords[2];
+            static Time prev_time = 0;
+            static double prev_rel_coords[2];
 
             if (!mouse->relative_mode || mouse->relative_mode_warp) {
                 return 0;
             }
 
             parse_valuators(rawev->raw_values,rawev->valuators.mask,
-                            rawev->valuators.mask_len,relative_cords,2);
-            SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_cords[0],(int)relative_cords[1]);
+                            rawev->valuators.mask_len,relative_coords,2);
+
+            if ((rawev->time == prev_time) && (relative_coords[0] == prev_rel_coords[0]) && (relative_coords[1] == prev_rel_coords[1])) {
+                return 0;  /* duplicate event, drop it. */
+            }
+
+            SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_coords[0],(int)relative_coords[1]);
+            prev_rel_coords[0] = relative_coords[0];
+            prev_rel_coords[1] = relative_coords[1];
+            prev_time = rawev->time;
             return 1;
             }
             break;

->8-----------------------------------------------

-- 
http://rjy.org.uk/



More information about the Pkg-sdl-maintainers mailing list