comparison test/testwm.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
173 printf("Posting internal quit request\n"); 173 printf("Posting internal quit request\n");
174 event.type = SDL_USEREVENT; 174 event.type = SDL_USEREVENT;
175 SDL_PushEvent(&event); 175 SDL_PushEvent(&event);
176 } 176 }
177 177
178 static int SDLCALL(*old_filterfunc) (void *, SDL_Event *);
179 static void *old_filterdata;
180
178 int SDLCALL 181 int SDLCALL
179 FilterEvents(void *userdata, SDL_Event * event) 182 FilterEvents(void *userdata, SDL_Event * event)
180 { 183 {
181 static int reallyquit = 0; 184 static int reallyquit = 0;
185
186 if (old_filterfunc) {
187 old_filterfunc(old_filterdata, event);
188 }
182 189
183 switch (event->type) { 190 switch (event->type) {
184 191
185 case SDL_ACTIVEEVENT: 192 case SDL_ACTIVEEVENT:
186 /* See what happened */ 193 /* See what happened */
342 if (SetVideoMode(w, h) < 0) { 349 if (SetVideoMode(w, h) < 0) {
343 quit(1); 350 quit(1);
344 } 351 }
345 352
346 /* Set an event filter that discards everything but QUIT */ 353 /* Set an event filter that discards everything but QUIT */
354 SDL_GetEventFilter(&old_filterfunc, &old_filterdata);
347 SDL_SetEventFilter(FilterEvents, NULL); 355 SDL_SetEventFilter(FilterEvents, NULL);
348 356
349 /* Ignore key up events, they don't even get filtered */ 357 /* Ignore key up events, they don't even get filtered */
350 SDL_EventState(SDL_KEYUP, SDL_IGNORE); 358 SDL_EventState(SDL_KEYUP, SDL_IGNORE);
351 359