src/video/x11/SDL_x11xinput2.c
changeset 9721 957a6ed39ad0
parent 9696 a7e9b75ec1c9
child 9998 f67cf37e9cd4
     1.1 --- a/src/video/x11/SDL_x11xinput2.c	Mon Jun 08 01:52:43 2015 -0400
     1.2 +++ b/src/video/x11/SDL_x11xinput2.c	Mon Jun 08 02:58:46 2015 -0400
     1.3 @@ -136,15 +136,25 @@
     1.4          case XI_RawMotion: {
     1.5              const XIRawEvent *rawev = (const XIRawEvent*)cookie->data;
     1.6              SDL_Mouse *mouse = SDL_GetMouse();
     1.7 -            double relative_cords[2];
     1.8 +            double relative_coords[2];
     1.9 +            static Time prev_time = 0;
    1.10 +            static double prev_rel_coords[2];
    1.11  
    1.12              if (!mouse->relative_mode || mouse->relative_mode_warp) {
    1.13                  return 0;
    1.14              }
    1.15  
    1.16              parse_valuators(rawev->raw_values,rawev->valuators.mask,
    1.17 -                            rawev->valuators.mask_len,relative_cords,2);
    1.18 -            SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_cords[0],(int)relative_cords[1]);
    1.19 +                            rawev->valuators.mask_len,relative_coords,2);
    1.20 +
    1.21 +            if ((rawev->time == prev_time) && (relative_coords[0] == prev_rel_coords[0]) && (relative_coords[1] == prev_rel_coords[1])) {
    1.22 +                return 0;  /* duplicate event, drop it. */
    1.23 +            }
    1.24 +
    1.25 +            SDL_SendMouseMotion(mouse->focus,mouse->mouseID,1,(int)relative_coords[0],(int)relative_coords[1]);
    1.26 +            prev_rel_coords[0] = relative_coords[0];
    1.27 +            prev_rel_coords[1] = relative_coords[1];
    1.28 +            prev_time = rawev->time;
    1.29              return 1;
    1.30              }
    1.31              break;