comparison src/video/SDL_cursor.c @ 3897:37dab4a917c4 SDL-1.2

Check video driver mouse cursor pointers before using them
author Patrice Mandin <patmandin@gmail.com>
date Sun, 19 Nov 2006 14:07:32 +0000
parents 5f52867ba65c
children a1b03ba2fcd0
comparison
equal deleted inserted replaced
3896:1a327643e741 3897:37dab4a917c4
186 } else if ( video->MoveWMCursor ) { 186 } else if ( video->MoveWMCursor ) {
187 /* If the video driver is moving the cursor directly, 187 /* If the video driver is moving the cursor directly,
188 it needs to hide the old cursor before (possibly) 188 it needs to hide the old cursor before (possibly)
189 showing the new one. (But don't erase NULL cursor) 189 showing the new one. (But don't erase NULL cursor)
190 */ 190 */
191 if ( SDL_cursor ) { 191 if ( SDL_cursor && video->ShowWMCursor ) {
192 video->ShowWMCursor(this, NULL); 192 video->ShowWMCursor(this, NULL);
193 } 193 }
194 } 194 }
195 SDL_cursor = cursor; 195 SDL_cursor = cursor;
196 } 196 }
197 197
198 /* Draw the new mouse cursor */ 198 /* Draw the new mouse cursor */
199 if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) { 199 if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
200 /* Use window manager cursor if possible */ 200 /* Use window manager cursor if possible */
201 if ( SDL_cursor->wm_cursor && 201 int show_wm_cursor = 0;
202 video->ShowWMCursor(this, SDL_cursor->wm_cursor) ) { 202 if ( SDL_cursor->wm_cursor && video->ShowWMCursor ) {
203 show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor);
204 }
205 if ( show_wm_cursor ) {
203 SDL_cursorstate &= ~CURSOR_USINGSW; 206 SDL_cursorstate &= ~CURSOR_USINGSW;
204 } else { 207 } else {
205 SDL_cursorstate |= CURSOR_USINGSW; 208 SDL_cursorstate |= CURSOR_USINGSW;
206 if ( video->ShowWMCursor ) { 209 if ( video->ShowWMCursor ) {
207 video->ShowWMCursor(this, NULL); 210 video->ShowWMCursor(this, NULL);
217 /* Erase window manager mouse (cursor not visible) */ 220 /* Erase window manager mouse (cursor not visible) */
218 if ( SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW) ) { 221 if ( SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW) ) {
219 SDL_EraseCursor(SDL_VideoSurface); 222 SDL_EraseCursor(SDL_VideoSurface);
220 } else { 223 } else {
221 if ( video ) { 224 if ( video ) {
222 video->ShowWMCursor(this, NULL); 225 if ( video->ShowWMCursor ) {
226 video->ShowWMCursor(this, NULL);
227 }
223 } 228 }
224 } 229 }
225 } 230 }
226 SDL_UnlockCursor(); 231 SDL_UnlockCursor();
227 } 232 }
246 } 251 }
247 if ( cursor->save[0] ) { 252 if ( cursor->save[0] ) {
248 SDL_free(cursor->save[0]); 253 SDL_free(cursor->save[0]);
249 } 254 }
250 if ( video && cursor->wm_cursor ) { 255 if ( video && cursor->wm_cursor ) {
251 video->FreeWMCursor(this, cursor->wm_cursor); 256 if ( video->FreeWMCursor ) {
257 video->FreeWMCursor(this, cursor->wm_cursor);
258 }
252 } 259 }
253 SDL_free(cursor); 260 SDL_free(cursor);
254 } 261 }
255 } 262 }
256 } 263 }