From e03bd2b1f04e66a114ccf60fa58625b77bee88b7 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 20 Feb 2011 23:51:59 -0800 Subject: [PATCH] The valid mouse coordinates actually range from 0 to w-1 and h-1 --- src/events/SDL_mouse.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index ad5f53bbe..6205c400d 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -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; }