The valid mouse coordinates actually range from 0 to w-1 and h-1
authorSam Lantinga <slouken@libsdl.org>
Sun, 20 Feb 2011 23:51:59 -0800
changeset 5370 cb219a294ebf
parent 5369 e049a7b85fd1
child 5371 fc3d3d580777
The valid mouse coordinates actually range from 0 to w-1 and h-1
src/events/SDL_mouse.c
--- a/src/events/SDL_mouse.c	Sun Feb 20 23:51:31 2011 -0800
+++ b/src/events/SDL_mouse.c	Sun Feb 20 23:51:59 2011 -0800
@@ -153,18 +153,22 @@
     }
 
     SDL_GetWindowSize(mouse->focus, &x_max, &y_max);
+    --x_max;
+    --y_max;
 
     /* make sure that the pointers find themselves inside the windows */
     /* only check if mouse->xmax is set ! */
-    if (x_max && mouse->x > x_max) {
+    if (mouse->x > x_max) {
         mouse->x = x_max;
-    } else if (mouse->x < 0) {
+    }
+    if (mouse->x < 0) {
         mouse->x = 0;
     }
 
-    if (y_max && mouse->y > y_max) {
+    if (mouse->y > y_max) {
         mouse->y = y_max;
-    } else if (mouse->y < 0) {
+    }
+    if (mouse->y < 0) {
         mouse->y = 0;
     }