There's no reason to add extra code to notify the mice of window size changes.
authorSam Lantinga <slouken@libsdl.org>
Sun, 07 Dec 2008 21:53:28 +0000
changeset 2849523b10db69f8
parent 2848 8a3aa505ecba
child 2850 43691ef70176
There's no reason to add extra code to notify the mice of window size changes.
Just query the window size when we care about it. :)
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/events/SDL_windowevents.c
src/video/SDL_video.c
     1.1 --- a/src/events/SDL_mouse.c	Sun Dec 07 07:16:40 2008 +0000
     1.2 +++ b/src/events/SDL_mouse.c	Sun Dec 07 21:53:28 2008 +0000
     1.3 @@ -364,21 +364,6 @@
     1.4          if (!focus) {
     1.5              SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
     1.6          }
     1.7 -        SDL_GetWindowSize(windowID, &mouse->x_max, &mouse->y_max);
     1.8 -    }
     1.9 -}
    1.10 -
    1.11 -void
    1.12 -SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h)
    1.13 -{
    1.14 -    int i;
    1.15 -
    1.16 -    for (i = 0; i < SDL_num_mice; ++i) {
    1.17 -        SDL_Mouse *mouse = SDL_GetMouse(i);
    1.18 -        if (mouse && mouse->focus == windowID) {
    1.19 -            mouse->x_max = w;
    1.20 -            mouse->y_max = h;
    1.21 -        }
    1.22      }
    1.23  }
    1.24  
    1.25 @@ -458,15 +443,19 @@
    1.26      } else {
    1.27          /* while using the relative mode and many windows, we have to be
    1.28             sure that the pointers find themselves inside the windows */
    1.29 -        if (mouse->x + xrel > mouse->x_max) {
    1.30 -            mouse->x = mouse->x_max;
    1.31 +        int x_max, y_max;
    1.32 +
    1.33 +        SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
    1.34 +
    1.35 +        if (mouse->x + xrel > x_max) {
    1.36 +            mouse->x = x_max;
    1.37          } else if (mouse->x + xrel < 0) {
    1.38              mouse->x = 0;
    1.39          } else {
    1.40              mouse->x += xrel;
    1.41          }
    1.42 -        if (mouse->y + yrel > mouse->y_max) {
    1.43 -            mouse->y = mouse->y_max;
    1.44 +        if (mouse->y + yrel > y_max) {
    1.45 +            mouse->y = y_max;
    1.46          } else if (mouse->y + yrel < 0) {
    1.47              mouse->y = 0;
    1.48          } else {
     2.1 --- a/src/events/SDL_mouse_c.h	Sun Dec 07 07:16:40 2008 +0000
     2.2 +++ b/src/events/SDL_mouse_c.h	Sun Dec 07 21:53:28 2008 +0000
     2.3 @@ -66,8 +66,8 @@
     2.4      /* Data common to all mice */
     2.5      SDL_WindowID focus;
     2.6      int which;
     2.7 -    int x, x_max;
     2.8 -    int y, y_max;
     2.9 +    int x;
    2.10 +    int y;
    2.11      int z;                      /* for future use */
    2.12      int xdelta;
    2.13      int ydelta;
    2.14 @@ -112,9 +112,6 @@
    2.15  /* Set the mouse focus window */
    2.16  extern void SDL_SetMouseFocus(int id, SDL_WindowID windowID);
    2.17  
    2.18 -/* Set the size of the mouse focus window */
    2.19 -extern void SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h);
    2.20 -
    2.21  /* Send a mouse motion event for a mouse */
    2.22  extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
    2.23  
     3.1 --- a/src/events/SDL_windowevents.c	Sun Dec 07 07:16:40 2008 +0000
     3.2 +++ b/src/events/SDL_windowevents.c	Sun Dec 07 21:53:28 2008 +0000
     3.3 @@ -74,7 +74,6 @@
     3.4          window->w = data1;
     3.5          window->h = data2;
     3.6          SDL_OnWindowResized(window);
     3.7 -        SDL_SetMouseFocusSize(windowID, window->w, window->h);
     3.8          break;
     3.9      case SDL_WINDOWEVENT_MINIMIZED:
    3.10          if (window->flags & SDL_WINDOW_MINIMIZED) {
     4.1 --- a/src/video/SDL_video.c	Sun Dec 07 07:16:40 2008 +0000
     4.2 +++ b/src/video/SDL_video.c	Sun Dec 07 21:53:28 2008 +0000
     4.3 @@ -1046,6 +1046,7 @@
     4.4      if (_this->SetWindowSize) {
     4.5          _this->SetWindowSize(_this, window);
     4.6      }
     4.7 +    SDL_OnWindowResized(window);
     4.8  }
     4.9  
    4.10  void
    4.11 @@ -1054,13 +1055,19 @@
    4.12      SDL_Window *window = SDL_GetWindowFromID(windowID);
    4.13  
    4.14      if (!window) {
    4.15 -        return;
    4.16 -    }
    4.17 -    if (w) {
    4.18 -        *w = window->w;
    4.19 -    }
    4.20 -    if (h) {
    4.21 -        *h = window->h;
    4.22 +        if (w) {
    4.23 +            *w = window->w;
    4.24 +        }
    4.25 +        if (h) {
    4.26 +            *h = window->h;
    4.27 +        }
    4.28 +    } else {
    4.29 +        if (w) {
    4.30 +            *w = 0;
    4.31 +        }
    4.32 +        if (h) {
    4.33 +            *h = 0;
    4.34 +        }
    4.35      }
    4.36  }
    4.37