update sdl Merge commit '4d48f9d23713d94b861da7b5d41baf2a41334994'
This commit is contained in:
45
external/sdl/SDL/src/events/SDL_mouse.c
vendored
45
external/sdl/SDL/src/events/SDL_mouse.c
vendored
@@ -162,7 +162,7 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
int SDL_InitMouse(void)
|
||||
int SDL_PreInitMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
@@ -203,8 +203,17 @@ int SDL_InitMouse(void)
|
||||
mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */
|
||||
|
||||
mouse->cursor_shown = SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!mouse->CreateCursor) {
|
||||
void SDL_PostInitMouse(void)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
/* Create a dummy mouse cursor for video backends that don't support true cursors,
|
||||
* so that mouse grab and focus functionality will work.
|
||||
*/
|
||||
if (!mouse->def_cursor) {
|
||||
SDL_Surface *surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (surface) {
|
||||
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||
@@ -212,14 +221,29 @@ int SDL_InitMouse(void)
|
||||
SDL_DestroySurface(surface);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
if (cursor == mouse->def_cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
SDL_Cursor *default_cursor = mouse->def_cursor;
|
||||
|
||||
if (mouse->cur_cursor == mouse->def_cursor) {
|
||||
mouse->cur_cursor = NULL;
|
||||
}
|
||||
mouse->def_cursor = NULL;
|
||||
|
||||
SDL_DestroyCursor(default_cursor);
|
||||
}
|
||||
|
||||
mouse->def_cursor = cursor;
|
||||
|
||||
if (!mouse->cur_cursor) {
|
||||
SDL_SetCursor(cursor);
|
||||
}
|
||||
@@ -845,6 +869,10 @@ void SDL_QuitMouse(void)
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
SDL_ShowCursor();
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
SDL_SetDefaultCursor(NULL);
|
||||
}
|
||||
|
||||
cursor = mouse->cursors;
|
||||
while (cursor) {
|
||||
next = cursor->next;
|
||||
@@ -854,15 +882,6 @@ void SDL_QuitMouse(void)
|
||||
mouse->cursors = NULL;
|
||||
mouse->cur_cursor = NULL;
|
||||
|
||||
if (mouse->def_cursor) {
|
||||
if (mouse->FreeCursor) {
|
||||
mouse->FreeCursor(mouse->def_cursor);
|
||||
} else {
|
||||
SDL_free(mouse->def_cursor);
|
||||
}
|
||||
mouse->def_cursor = NULL;
|
||||
}
|
||||
|
||||
if (mouse->sources) {
|
||||
SDL_free(mouse->sources);
|
||||
mouse->sources = NULL;
|
||||
@@ -1377,7 +1396,7 @@ void SDL_DestroyCursor(SDL_Cursor *cursor)
|
||||
mouse->cursors = curr->next;
|
||||
}
|
||||
|
||||
if (mouse->FreeCursor) {
|
||||
if (mouse->FreeCursor && curr->driverdata) {
|
||||
mouse->FreeCursor(curr);
|
||||
} else {
|
||||
SDL_free(curr);
|
||||
|
||||
Reference in New Issue
Block a user