Fixes #2611 #2610, Touch events cause crash on Android, thanks Alvin & Sylvain

This bug was introduced on this rev: https://hg.libsdl.org/SDL/rev/42f6bd8c8575
This commit is contained in:
Gabriel Jacobo 2014-06-28 12:36:44 -03:00
parent 02e9f81ebe
commit 1ed1f7f2e3
2 changed files with 5 additions and 5 deletions

View File

@ -142,7 +142,7 @@ SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate)
SDL_Mouse *mouse = SDL_GetMouse(); SDL_Mouse *mouse = SDL_GetMouse();
SDL_bool inWindow = SDL_TRUE; SDL_bool inWindow = SDL_TRUE;
if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0) { if (window != NULL && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
int w, h; int w, h;
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
if (x < 0 || y < 0 || x >= w || y >= h) { if (x < 0 || y < 0 || x >= w || y >= h) {

View File

@ -86,9 +86,9 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
/* Primary pointer down */ /* Primary pointer down */
Android_GetWindowCoordinates(x, y, &window_x, &window_y); Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */ /* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y); SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
/* send mouse down event */ /* send mouse down event */
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
pointerFingerID = fingerId; pointerFingerID = fingerId;
case ACTION_POINTER_DOWN: case ACTION_POINTER_DOWN:
/* Non primary pointer down */ /* Non primary pointer down */
@ -100,7 +100,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
Android_GetWindowCoordinates(x, y, &window_x, &window_y); Android_GetWindowCoordinates(x, y, &window_x, &window_y);
/* send moved event */ /* send moved event */
SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y); SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
} }
SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p); SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
break; break;
@ -109,7 +109,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
/* Primary pointer up */ /* Primary pointer up */
/* send mouse up */ /* send mouse up */
pointerFingerID = (SDL_FingerID) 0; pointerFingerID = (SDL_FingerID) 0;
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
case ACTION_POINTER_UP: case ACTION_POINTER_UP:
/* Non primary pointer up */ /* Non primary pointer up */
SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p); SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);