src/events/SDL_mouse.c
changeset 2794 f7872b7a8732
parent 2765 f55c87ae336b
child 2842 97ba0be8b565
     1.1 --- a/src/events/SDL_mouse.c	Thu Nov 27 05:29:12 2008 +0000
     1.2 +++ b/src/events/SDL_mouse.c	Thu Nov 27 21:53:18 2008 +0000
     1.3 @@ -34,7 +34,6 @@
     1.4  static int *SDL_IdIndex = NULL;
     1.5  static int SDL_highestId = -1;
     1.6  static int last_x, last_y;      /* the last reported x and y coordinates by the system cursor */
     1.7 -int x_max, y_max;               /* current window width and height */
     1.8  
     1.9  
    1.10  /* Public functions */
    1.11 @@ -365,6 +364,21 @@
    1.12          if (!focus) {
    1.13              SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
    1.14          }
    1.15 +        SDL_GetWindowSize(windowID, &mouse->x_max, &mouse->y_max);
    1.16 +    }
    1.17 +}
    1.18 +
    1.19 +void
    1.20 +SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h)
    1.21 +{
    1.22 +    int i;
    1.23 +
    1.24 +    for (i = 0; i < SDL_num_mice; ++i) {
    1.25 +        SDL_Mouse *mouse = SDL_GetMouse(i);
    1.26 +        if (mouse && mouse->focus == windowID) {
    1.27 +            mouse->x_max = w;
    1.28 +            mouse->y_max = h;
    1.29 +        }
    1.30      }
    1.31  }
    1.32  
    1.33 @@ -407,15 +421,6 @@
    1.34      int xrel;
    1.35      int yrel;
    1.36  
    1.37 -    /* while using the relative mode and many windows, we have to be sure,
    1.38 -       that the pointers find themselves inside the windows */
    1.39 -    if (x > x_max) {
    1.40 -        x = x_max;
    1.41 -    }
    1.42 -    if (y > y_max) {
    1.43 -        y = y_max;
    1.44 -    }
    1.45 -
    1.46      if (!mouse || mouse->flush_motion) {
    1.47          return 0;
    1.48      }
    1.49 @@ -445,15 +450,17 @@
    1.50          mouse->x = x;
    1.51          mouse->y = y;
    1.52      } else {
    1.53 -        if (mouse->x + xrel > x_max) {
    1.54 -            mouse->x = x_max;
    1.55 +        /* while using the relative mode and many windows, we have to be
    1.56 +           sure that the pointers find themselves inside the windows */
    1.57 +        if (mouse->x + xrel > mouse->x_max) {
    1.58 +            mouse->x = mouse->x_max;
    1.59          } else if (mouse->x + xrel < 0) {
    1.60              mouse->x = 0;
    1.61          } else {
    1.62              mouse->x += xrel;
    1.63          }
    1.64 -        if (mouse->y + yrel > y_max) {
    1.65 -            mouse->y = y_max;
    1.66 +        if (mouse->y + yrel > mouse->y_max) {
    1.67 +            mouse->y = mouse->y_max;
    1.68          } else if (mouse->y + yrel < 0) {
    1.69              mouse->y = 0;
    1.70          } else {
    1.71 @@ -779,13 +786,6 @@
    1.72  }
    1.73  
    1.74  void
    1.75 -SDL_UpdateCoordinates(int x, int y)
    1.76 -{
    1.77 -    x_max = x;
    1.78 -    y_max = y;
    1.79 -}
    1.80 -
    1.81 -void
    1.82  SDL_ChangeEnd(int id, int end)
    1.83  {
    1.84      int index = SDL_GetMouseIndexId(id);