Check video driver mouse cursor pointers before using them

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402234
This commit is contained in:
Patrice Mandin 2006-11-19 14:07:32 +00:00
parent 8061a35dcf
commit ae2275c2b4

View file

@ -188,7 +188,7 @@ void SDL_SetCursor (SDL_Cursor *cursor)
it needs to hide the old cursor before (possibly) it needs to hide the old cursor before (possibly)
showing the new one. (But don't erase NULL cursor) showing the new one. (But don't erase NULL cursor)
*/ */
if ( SDL_cursor ) { if ( SDL_cursor && video->ShowWMCursor ) {
video->ShowWMCursor(this, NULL); video->ShowWMCursor(this, NULL);
} }
} }
@ -198,8 +198,11 @@ void SDL_SetCursor (SDL_Cursor *cursor)
/* Draw the new mouse cursor */ /* Draw the new mouse cursor */
if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) { if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
/* Use window manager cursor if possible */ /* Use window manager cursor if possible */
if ( SDL_cursor->wm_cursor && int show_wm_cursor = 0;
video->ShowWMCursor(this, SDL_cursor->wm_cursor) ) { 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; SDL_cursorstate &= ~CURSOR_USINGSW;
} else { } else {
SDL_cursorstate |= CURSOR_USINGSW; SDL_cursorstate |= CURSOR_USINGSW;
@ -219,10 +222,12 @@ void SDL_SetCursor (SDL_Cursor *cursor)
SDL_EraseCursor(SDL_VideoSurface); SDL_EraseCursor(SDL_VideoSurface);
} else { } else {
if ( video ) { if ( video ) {
if ( video->ShowWMCursor ) {
video->ShowWMCursor(this, NULL); video->ShowWMCursor(this, NULL);
} }
} }
} }
}
SDL_UnlockCursor(); SDL_UnlockCursor();
} }
@ -248,8 +253,10 @@ void SDL_FreeCursor (SDL_Cursor *cursor)
SDL_free(cursor->save[0]); SDL_free(cursor->save[0]);
} }
if ( video && cursor->wm_cursor ) { if ( video && cursor->wm_cursor ) {
if ( video->FreeWMCursor ) {
video->FreeWMCursor(this, cursor->wm_cursor); video->FreeWMCursor(this, cursor->wm_cursor);
} }
}
SDL_free(cursor); SDL_free(cursor);
} }
} }