comparison src/events/SDL_events.c @ 1731:875c3cf1a12c SDL-1.3

SDL_PushEvent() calls the event filter code, and has a return value to tell whether or not the event was actually pushed. SDL_GetEventFilter() now returns an SDL_bool instead of the filter function.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 08 Jul 2006 20:07:08 +0000
parents 6c63fc2bd986
children
comparison
equal deleted inserted replaced
1730:e70477157db9 1731:875c3cf1a12c
433 } 433 }
434 434
435 int 435 int
436 SDL_PushEvent(SDL_Event * event) 436 SDL_PushEvent(SDL_Event * event)
437 { 437 {
438 if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0) 438 if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
439 return 0;
440 }
441 if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0) {
439 return -1; 442 return -1;
440 return 0; 443 }
444 return 1;
441 } 445 }
442 446
443 void 447 void
444 SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) 448 SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
445 { 449 {
449 SDL_EventOK = filter; 453 SDL_EventOK = filter;
450 SDL_EventOKParam = userdata; 454 SDL_EventOKParam = userdata;
451 while (SDL_PollEvent(&bitbucket) > 0); 455 while (SDL_PollEvent(&bitbucket) > 0);
452 } 456 }
453 457
454 SDL_EventFilter 458 SDL_bool
455 SDL_GetEventFilter(void **userdata) 459 SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata)
456 { 460 {
461 if (filter) {
462 *filter = SDL_EventOK;
463 }
457 if (userdata) { 464 if (userdata) {
458 *userdata = SDL_EventOKParam; 465 *userdata = SDL_EventOKParam;
459 } 466 }
460 return (SDL_EventOK); 467 return SDL_EventOK ? SDL_TRUE : SDL_FALSE;
461 } 468 }
462 469
463 void 470 void
464 SDL_FilterEvents(SDL_EventFilter filter, void *userdata) 471 SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
465 { 472 {
534 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { 541 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
535 SDL_Event event; 542 SDL_Event event;
536 SDL_memset(&event, 0, sizeof(event)); 543 SDL_memset(&event, 0, sizeof(event));
537 event.type = SDL_SYSWMEVENT; 544 event.type = SDL_SYSWMEVENT;
538 event.syswm.msg = message; 545 event.syswm.msg = message;
539 if ((SDL_EventOK == NULL) 546 posted = (SDL_PushEvent(&event) > 0);
540 || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
541 posted = 1;
542 SDL_PushEvent(&event);
543 }
544 } 547 }
545 /* Update internal event state */ 548 /* Update internal event state */
546 return (posted); 549 return (posted);
547 } 550 }
548 551