Mouse events now report the correct window id and window enter/leave events are now reported.
authorBob Pendleton
Thu, 11 Jun 2009 20:08:33 +0000
changeset 319508747e24a50f
parent 3194 c18c03927a77
child 3196 413672b09bb3
Mouse events now report the correct window id and window enter/leave events are now reported.
src/events/SDL_mouse.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11mouse.c
     1.1 --- a/src/events/SDL_mouse.c	Thu Jun 11 06:03:05 2009 +0000
     1.2 +++ b/src/events/SDL_mouse.c	Thu Jun 11 20:08:33 2009 +0000
     1.3 @@ -97,6 +97,7 @@
     1.4      /* we're setting the mouse properties */
     1.5      length = 0;
     1.6      length = SDL_strlen(name);
     1.7 +    SDL_mice[index]->focus = 0;
     1.8      SDL_mice[index]->name = SDL_malloc((length + 2) * sizeof(char));
     1.9      SDL_strlcpy(SDL_mice[index]->name, name, length + 1);
    1.10      SDL_mice[index]->pressure_max = pressure_max;
     2.1 --- a/src/video/x11/SDL_x11events.c	Thu Jun 11 06:03:05 2009 +0000
     2.2 +++ b/src/video/x11/SDL_x11events.c	Thu Jun 11 20:08:33 2009 +0000
     2.3 @@ -83,8 +83,10 @@
     2.4          /* Gaining mouse coverage? */
     2.5      case EnterNotify:{
     2.6  #ifdef DEBUG_XEVENTS
     2.7 -            printf("EnterNotify! (%d,%d)\n", xevent.xcrossing.x,
     2.8 -                   xevent.xcrossing.y);
     2.9 +            printf("EnterNotify! (%d,%d,%d)\n", 
    2.10 +	           xevent.xcrossing.x,
    2.11 + 	           xevent.xcrossing.y,
    2.12 +                   xevent.xcrossing.mode);
    2.13              if (xevent.xcrossing.mode == NotifyGrab)
    2.14                  printf("Mode: NotifyGrab\n");
    2.15              if (xevent.xcrossing.mode == NotifyUngrab)
    2.16 @@ -92,10 +94,12 @@
    2.17  #endif
    2.18              if ((xevent.xcrossing.mode != NotifyGrab) &&
    2.19                  (xevent.xcrossing.mode != NotifyUngrab)) {
    2.20 +#if 1
    2.21                  /* FIXME: Should we reset data for all mice? */
    2.22 -#if 0
    2.23 -                SDL_SetMouseFocus(0, data->windowID);
    2.24 -                SDL_SendMouseMotion(0, 0, move->x, move->y, 0);
    2.25 +	       for (i = 0; i < SDL_GetNumMice(); ++i) {
    2.26 +		  SDL_Mouse *mouse = SDL_GetMouse(i);
    2.27 +		  SDL_SetMouseFocus(mouse->id, data->windowID);
    2.28 +	       }
    2.29  #endif
    2.30              }
    2.31          }
    2.32 @@ -104,8 +108,10 @@
    2.33          /* Losing mouse coverage? */
    2.34      case LeaveNotify:{
    2.35  #ifdef DEBUG_XEVENTS
    2.36 -            printf("LeaveNotify! (%d,%d)\n", xevent.xcrossing.x,
    2.37 -                   xevent.xcrossing.y);
    2.38 +            printf("LeaveNotify! (%d,%d,%d)\n", 
    2.39 +	           xevent.xcrossing.x,
    2.40 + 	           xevent.xcrossing.y,
    2.41 +                   xevent.xcrossing.mode);
    2.42              if (xevent.xcrossing.mode == NotifyGrab)
    2.43                  printf("Mode: NotifyGrab\n");
    2.44              if (xevent.xcrossing.mode == NotifyUngrab)
    2.45 @@ -114,9 +120,12 @@
    2.46              if ((xevent.xcrossing.mode != NotifyGrab) &&
    2.47                  (xevent.xcrossing.mode != NotifyUngrab) &&
    2.48                  (xevent.xcrossing.detail != NotifyInferior)) {
    2.49 +#if 1
    2.50                  /* FIXME: Should we reset data for all mice? */
    2.51 -#if 0
    2.52 -                SDL_SetMouseFocus(0, 0);
    2.53 +	       for (i = 0; i < SDL_GetNumMice(); ++i) {
    2.54 +		  SDL_Mouse *mouse = SDL_GetMouse(i);
    2.55 +		  SDL_SetMouseFocus(mouse->id, 0);
    2.56 +	       }
    2.57  #endif
    2.58              }
    2.59          }
     3.1 --- a/src/video/x11/SDL_x11mouse.c	Thu Jun 11 06:03:05 2009 +0000
     3.2 +++ b/src/video/x11/SDL_x11mouse.c	Thu Jun 11 20:08:33 2009 +0000
     3.3 @@ -52,6 +52,8 @@
     3.4  #endif
     3.5      int num_mice = 0;
     3.6  
     3.7 +    SDL_zero(mouse);
     3.8 +
     3.9  #if SDL_VIDEO_DRIVER_X11_XINPUT
    3.10      /* we're getting the list of input devices */
    3.11      n = 0;