Skip to content

Commit

Permalink
Check video driver mouse cursor pointers before using them
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Nov 19, 2006
1 parent 9247e22 commit 0d82592
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/video/SDL_cursor.c
Expand Up @@ -188,7 +188,7 @@ void SDL_SetCursor (SDL_Cursor *cursor)
it needs to hide the old cursor before (possibly)
showing the new one. (But don't erase NULL cursor)
*/
if ( SDL_cursor ) {
if ( SDL_cursor && video->ShowWMCursor ) {
video->ShowWMCursor(this, NULL);
}
}
Expand All @@ -198,8 +198,11 @@ void SDL_SetCursor (SDL_Cursor *cursor)
/* Draw the new mouse cursor */
if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
/* Use window manager cursor if possible */
if ( SDL_cursor->wm_cursor &&
video->ShowWMCursor(this, SDL_cursor->wm_cursor) ) {
int show_wm_cursor = 0;
if ( SDL_cursor->wm_cursor && video->ShowWMCursor ) {
show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor);
}
if ( show_wm_cursor ) {
SDL_cursorstate &= ~CURSOR_USINGSW;
} else {
SDL_cursorstate |= CURSOR_USINGSW;
Expand All @@ -219,7 +222,9 @@ void SDL_SetCursor (SDL_Cursor *cursor)
SDL_EraseCursor(SDL_VideoSurface);
} else {
if ( video ) {
video->ShowWMCursor(this, NULL);
if ( video->ShowWMCursor ) {
video->ShowWMCursor(this, NULL);
}
}
}
}
Expand Down Expand Up @@ -248,7 +253,9 @@ void SDL_FreeCursor (SDL_Cursor *cursor)
SDL_free(cursor->save[0]);
}
if ( video && cursor->wm_cursor ) {
video->FreeWMCursor(this, cursor->wm_cursor);
if ( video->FreeWMCursor ) {
video->FreeWMCursor(this, cursor->wm_cursor);
}
}
SDL_free(cursor);
}
Expand Down

0 comments on commit 0d82592

Please sign in to comment.