Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
The valid mouse coordinates actually range from 0 to w-1 and h-1
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Feb 21, 2011
1 parent 235c084 commit e03bd2b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/events/SDL_mouse.c
Expand Up @@ -153,18 +153,22 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
}

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;
}

Expand Down

0 comments on commit e03bd2b

Please sign in to comment.