comparison src/SDL_compat.c @ 1722:5daa04d862f1 SDL-1.3

Added a userdata parameter for event filters. Added a function to filter the existing queued events. Added explicit support for relative mouse mode to the API.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 30 Jun 2006 08:18:44 +0000
parents a1ebb17f9c52
children 6c63fc2bd986
comparison
equal deleted inserted replaced
1721:1cc762cafff8 1722:5daa04d862f1
151 modes[nmodes] = NULL; 151 modes[nmodes] = NULL;
152 } 152 }
153 return modes; 153 return modes;
154 } 154 }
155 155
156 static int (*orig_eventfilter) (SDL_Event * event); 156 static SDL_EventFilter orig_eventfilter;
157 static void *orig_eventfilterparam;
157 158
158 static int 159 static int
159 SDL_CompatEventFilter(SDL_Event * event) 160 SDL_CompatEventFilter(void *userdata, SDL_Event * event)
160 { 161 {
161 SDL_Event fake; 162 SDL_Event fake;
162 163
163 switch (event->type) { 164 switch (event->type) {
164 case SDL_WINDOWEVENT: 165 case SDL_WINDOWEVENT:
225 } 226 }
226 break; 227 break;
227 } 228 }
228 } 229 }
229 if (orig_eventfilter) { 230 if (orig_eventfilter) {
230 return orig_eventfilter(event); 231 return orig_eventfilter(orig_eventfilterparam, event);
231 } else { 232 } else {
232 return 1; 233 return 1;
233 } 234 }
234 } 235 }
235 236
249 } 250 }
250 251
251 SDL_Surface * 252 SDL_Surface *
252 SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) 253 SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
253 { 254 {
254 int (*filter) (SDL_Event * event); 255 SDL_EventFilter filter;
256 void *filterparam;
255 const SDL_DisplayMode *desktop_mode; 257 const SDL_DisplayMode *desktop_mode;
256 SDL_DisplayMode mode; 258 SDL_DisplayMode mode;
257 Uint32 window_flags; 259 Uint32 window_flags;
258 Uint32 desktop_format; 260 Uint32 desktop_format;
259 Uint32 desired_format; 261 Uint32 desired_format;
278 SDL_VideoSurface = NULL; 280 SDL_VideoSurface = NULL;
279 } 281 }
280 SDL_DestroyWindow(SDL_VideoWindow); 282 SDL_DestroyWindow(SDL_VideoWindow);
281 283
282 /* Set up the event filter */ 284 /* Set up the event filter */
283 filter = SDL_GetEventFilter(); 285 filter = SDL_GetEventFilter(&filterparam);
284 if (filter != SDL_CompatEventFilter) { 286 if (filter != SDL_CompatEventFilter) {
285 orig_eventfilter = filter; 287 orig_eventfilter = filter;
286 } 288 orig_eventfilterparam = filterparam;
287 SDL_SetEventFilter(SDL_CompatEventFilter); 289 }
290 SDL_SetEventFilter(SDL_CompatEventFilter, NULL);
288 291
289 /* Create a new window */ 292 /* Create a new window */
290 window_flags = SDL_WINDOW_SHOWN; 293 window_flags = SDL_WINDOW_SHOWN;
291 if (flags & SDL_FULLSCREEN) { 294 if (flags & SDL_FULLSCREEN) {
292 window_flags |= SDL_WINDOW_FULLSCREEN; 295 window_flags |= SDL_WINDOW_FULLSCREEN;