comparison src/events/SDL_events.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 6e7ec5cb83c3
children 5daa04d862f1
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
60 /* Thread functions */ 60 /* Thread functions */
61 static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */ 61 static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */
62 static Uint32 event_thread; /* The event thread id */ 62 static Uint32 event_thread; /* The event thread id */
63 63
64 void 64 void
65 SDL_Lock_EventThread (void) 65 SDL_Lock_EventThread(void)
66 { 66 {
67 if (SDL_EventThread && (SDL_ThreadID () != event_thread)) { 67 if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
68 /* Grab lock and spin until we're sure event thread stopped */ 68 /* Grab lock and spin until we're sure event thread stopped */
69 SDL_mutexP (SDL_EventLock.lock); 69 SDL_mutexP(SDL_EventLock.lock);
70 while (!SDL_EventLock.safe) { 70 while (!SDL_EventLock.safe) {
71 SDL_Delay (1); 71 SDL_Delay(1);
72 } 72 }
73 } 73 }
74 } 74 }
75 void 75 void
76 SDL_Unlock_EventThread (void) 76 SDL_Unlock_EventThread(void)
77 { 77 {
78 if (SDL_EventThread && (SDL_ThreadID () != event_thread)) { 78 if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
79 SDL_mutexV (SDL_EventLock.lock); 79 SDL_mutexV(SDL_EventLock.lock);
80 } 80 }
81 } 81 }
82 82
83 #ifdef __OS2__ 83 #ifdef __OS2__
84 /* 84 /*
90 #include <os2.h> 90 #include <os2.h>
91 #include <time.h> 91 #include <time.h>
92 #endif 92 #endif
93 93
94 static int SDLCALL 94 static int SDLCALL
95 SDL_GobbleEvents (void *unused) 95 SDL_GobbleEvents(void *unused)
96 { 96 {
97 event_thread = SDL_ThreadID (); 97 event_thread = SDL_ThreadID();
98 98
99 #ifdef __OS2__ 99 #ifdef __OS2__
100 #ifdef USE_DOSSETPRIORITY 100 #ifdef USE_DOSSETPRIORITY
101 /* Increase thread priority, so it will process events in time for sure! */ 101 /* Increase thread priority, so it will process events in time for sure! */
102 DosSetPriority (PRTYS_THREAD, PRTYC_REGULAR, +16, 0); 102 DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, +16, 0);
103 #endif 103 #endif
104 #endif 104 #endif
105 105
106 while (SDL_EventQ.active) { 106 while (SDL_EventQ.active) {
107 SDL_VideoDevice *_this = SDL_GetVideoDevice (); 107 SDL_VideoDevice *_this = SDL_GetVideoDevice();
108 108
109 /* Get events from the video subsystem */ 109 /* Get events from the video subsystem */
110 if (_this) { 110 if (_this) {
111 _this->PumpEvents (_this); 111 _this->PumpEvents(_this);
112 } 112 }
113 113
114 /* Queue pending key-repeat events */ 114 /* Queue pending key-repeat events */
115 SDL_CheckKeyRepeat (); 115 SDL_CheckKeyRepeat();
116 116
117 #if !SDL_JOYSTICK_DISABLED 117 #if !SDL_JOYSTICK_DISABLED
118 /* Check for joystick state change */ 118 /* Check for joystick state change */
119 if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) { 119 if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) {
120 SDL_JoystickUpdate (); 120 SDL_JoystickUpdate();
121 } 121 }
122 #endif 122 #endif
123 123
124 /* Give up the CPU for the rest of our timeslice */ 124 /* Give up the CPU for the rest of our timeslice */
125 SDL_EventLock.safe = 1; 125 SDL_EventLock.safe = 1;
126 if (SDL_timer_running) { 126 if (SDL_timer_running) {
127 SDL_ThreadedTimerCheck (); 127 SDL_ThreadedTimerCheck();
128 } 128 }
129 SDL_Delay (1); 129 SDL_Delay(1);
130 130
131 /* Check for event locking. 131 /* Check for event locking.
132 On the P of the lock mutex, if the lock is held, this thread 132 On the P of the lock mutex, if the lock is held, this thread
133 will wait until the lock is released before continuing. The 133 will wait until the lock is released before continuing. The
134 safe flag will be set, meaning that the other thread can go 134 safe flag will be set, meaning that the other thread can go
135 about it's business. The safe flag is reset before the V, 135 about it's business. The safe flag is reset before the V,
136 so as soon as the mutex is free, other threads can see that 136 so as soon as the mutex is free, other threads can see that
137 it's not safe to interfere with the event thread. 137 it's not safe to interfere with the event thread.
138 */ 138 */
139 SDL_mutexP (SDL_EventLock.lock); 139 SDL_mutexP(SDL_EventLock.lock);
140 SDL_EventLock.safe = 0; 140 SDL_EventLock.safe = 0;
141 SDL_mutexV (SDL_EventLock.lock); 141 SDL_mutexV(SDL_EventLock.lock);
142 } 142 }
143 SDL_SetTimerThreaded (0); 143 SDL_SetTimerThreaded(0);
144 event_thread = 0; 144 event_thread = 0;
145 return (0); 145 return (0);
146 } 146 }
147 147
148 static int 148 static int
149 SDL_StartEventThread (Uint32 flags) 149 SDL_StartEventThread(Uint32 flags)
150 { 150 {
151 /* Reset everything to zero */ 151 /* Reset everything to zero */
152 SDL_EventThread = NULL; 152 SDL_EventThread = NULL;
153 SDL_memset (&SDL_EventLock, 0, sizeof (SDL_EventLock)); 153 SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
154 154
155 /* Create the lock and set ourselves active */ 155 /* Create the lock and set ourselves active */
156 #if !SDL_THREADS_DISABLED 156 #if !SDL_THREADS_DISABLED
157 SDL_EventQ.lock = SDL_CreateMutex (); 157 SDL_EventQ.lock = SDL_CreateMutex();
158 if (SDL_EventQ.lock == NULL) { 158 if (SDL_EventQ.lock == NULL) {
159 #ifdef __MACOS__ /* MacOS classic you can't multithread, so no lock needed */ 159 #ifdef __MACOS__ /* MacOS classic you can't multithread, so no lock needed */
160 ; 160 ;
161 #else 161 #else
162 return (-1); 162 return (-1);
164 } 164 }
165 #endif /* !SDL_THREADS_DISABLED */ 165 #endif /* !SDL_THREADS_DISABLED */
166 SDL_EventQ.active = 1; 166 SDL_EventQ.active = 1;
167 167
168 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { 168 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
169 SDL_EventLock.lock = SDL_CreateMutex (); 169 SDL_EventLock.lock = SDL_CreateMutex();
170 if (SDL_EventLock.lock == NULL) { 170 if (SDL_EventLock.lock == NULL) {
171 return (-1); 171 return (-1);
172 } 172 }
173 SDL_EventLock.safe = 0; 173 SDL_EventLock.safe = 0;
174 174
175 /* The event thread will handle timers too */ 175 /* The event thread will handle timers too */
176 SDL_SetTimerThreaded (2); 176 SDL_SetTimerThreaded(2);
177 #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) 177 #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
178 #undef SDL_CreateThread 178 #undef SDL_CreateThread
179 SDL_EventThread = 179 SDL_EventThread =
180 SDL_CreateThread (SDL_GobbleEvents, NULL, NULL, NULL); 180 SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
181 #else 181 #else
182 SDL_EventThread = SDL_CreateThread (SDL_GobbleEvents, NULL); 182 SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
183 #endif 183 #endif
184 if (SDL_EventThread == NULL) { 184 if (SDL_EventThread == NULL) {
185 return (-1); 185 return (-1);
186 } 186 }
187 } else { 187 } else {
189 } 189 }
190 return (0); 190 return (0);
191 } 191 }
192 192
193 static void 193 static void
194 SDL_StopEventThread (void) 194 SDL_StopEventThread(void)
195 { 195 {
196 SDL_EventQ.active = 0; 196 SDL_EventQ.active = 0;
197 if (SDL_EventThread) { 197 if (SDL_EventThread) {
198 SDL_WaitThread (SDL_EventThread, NULL); 198 SDL_WaitThread(SDL_EventThread, NULL);
199 SDL_EventThread = NULL; 199 SDL_EventThread = NULL;
200 SDL_DestroyMutex (SDL_EventLock.lock); 200 SDL_DestroyMutex(SDL_EventLock.lock);
201 } 201 }
202 #ifndef IPOD 202 #ifndef IPOD
203 SDL_DestroyMutex (SDL_EventQ.lock); 203 SDL_DestroyMutex(SDL_EventQ.lock);
204 #endif 204 #endif
205 } 205 }
206 206
207 Uint32 207 Uint32
208 SDL_EventThreadID (void) 208 SDL_EventThreadID(void)
209 { 209 {
210 return (event_thread); 210 return (event_thread);
211 } 211 }
212 212
213 /* Public functions */ 213 /* Public functions */
214 214
215 void 215 void
216 SDL_StopEventLoop (void) 216 SDL_StopEventLoop(void)
217 { 217 {
218 /* Halt the event thread, if running */ 218 /* Halt the event thread, if running */
219 SDL_StopEventThread (); 219 SDL_StopEventThread();
220 220
221 /* Shutdown event handlers */ 221 /* Shutdown event handlers */
222 SDL_KeyboardQuit (); 222 SDL_KeyboardQuit();
223 SDL_MouseQuit (); 223 SDL_MouseQuit();
224 SDL_QuitQuit (); 224 SDL_QuitQuit();
225 225
226 /* Clean out EventQ */ 226 /* Clean out EventQ */
227 SDL_EventQ.head = 0; 227 SDL_EventQ.head = 0;
228 SDL_EventQ.tail = 0; 228 SDL_EventQ.tail = 0;
229 SDL_EventQ.wmmsg_next = 0; 229 SDL_EventQ.wmmsg_next = 0;
230 } 230 }
231 231
232 /* This function (and associated calls) may be called more than once */ 232 /* This function (and associated calls) may be called more than once */
233 int 233 int
234 SDL_StartEventLoop (Uint32 flags) 234 SDL_StartEventLoop(Uint32 flags)
235 { 235 {
236 int retcode; 236 int retcode;
237 237
238 /* Clean out the event queue */ 238 /* Clean out the event queue */
239 SDL_EventThread = NULL; 239 SDL_EventThread = NULL;
240 SDL_EventQ.lock = NULL; 240 SDL_EventQ.lock = NULL;
241 SDL_StopEventLoop (); 241 SDL_StopEventLoop();
242 242
243 /* No filter to start with, process most event types */ 243 /* No filter to start with, process most event types */
244 SDL_EventOK = NULL; 244 SDL_EventOK = NULL;
245 SDL_memset (SDL_ProcessEvents, SDL_ENABLE, sizeof (SDL_ProcessEvents)); 245 SDL_memset(SDL_ProcessEvents, SDL_ENABLE, sizeof(SDL_ProcessEvents));
246 SDL_eventstate = ~0; 246 SDL_eventstate = ~0;
247 /* It's not save to call SDL_EventState() yet */ 247 /* It's not save to call SDL_EventState() yet */
248 SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); 248 SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT);
249 SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE; 249 SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE;
250 250
251 /* Initialize event handlers */ 251 /* Initialize event handlers */
252 retcode = 0; 252 retcode = 0;
253 retcode += SDL_KeyboardInit (); 253 retcode += SDL_KeyboardInit();
254 retcode += SDL_MouseInit (); 254 retcode += SDL_MouseInit();
255 retcode += SDL_QuitInit (); 255 retcode += SDL_QuitInit();
256 if (retcode < 0) { 256 if (retcode < 0) {
257 /* We don't expect them to fail, but... */ 257 /* We don't expect them to fail, but... */
258 return (-1); 258 return (-1);
259 } 259 }
260 260
261 /* Create the lock and event thread */ 261 /* Create the lock and event thread */
262 if (SDL_StartEventThread (flags) < 0) { 262 if (SDL_StartEventThread(flags) < 0) {
263 SDL_StopEventLoop (); 263 SDL_StopEventLoop();
264 return (-1); 264 return (-1);
265 } 265 }
266 return (0); 266 return (0);
267 } 267 }
268 268
269 269
270 /* Add an event to the event queue -- called with the queue locked */ 270 /* Add an event to the event queue -- called with the queue locked */
271 static int 271 static int
272 SDL_AddEvent (SDL_Event * event) 272 SDL_AddEvent(SDL_Event * event)
273 { 273 {
274 int tail, added; 274 int tail, added;
275 275
276 tail = (SDL_EventQ.tail + 1) % MAXEVENTS; 276 tail = (SDL_EventQ.tail + 1) % MAXEVENTS;
277 if (tail == SDL_EventQ.head) { 277 if (tail == SDL_EventQ.head) {
294 } 294 }
295 295
296 /* Cut an event, and return the next valid spot, or the tail */ 296 /* Cut an event, and return the next valid spot, or the tail */
297 /* -- called with the queue locked */ 297 /* -- called with the queue locked */
298 static int 298 static int
299 SDL_CutEvent (int spot) 299 SDL_CutEvent(int spot)
300 { 300 {
301 if (spot == SDL_EventQ.head) { 301 if (spot == SDL_EventQ.head) {
302 SDL_EventQ.head = (SDL_EventQ.head + 1) % MAXEVENTS; 302 SDL_EventQ.head = (SDL_EventQ.head + 1) % MAXEVENTS;
303 return (SDL_EventQ.head); 303 return (SDL_EventQ.head);
304 } else if ((spot + 1) % MAXEVENTS == SDL_EventQ.tail) { 304 } else if ((spot + 1) % MAXEVENTS == SDL_EventQ.tail) {
322 /* NOTREACHED */ 322 /* NOTREACHED */
323 } 323 }
324 324
325 /* Lock the event queue, take a peep at it, and unlock it */ 325 /* Lock the event queue, take a peep at it, and unlock it */
326 int 326 int
327 SDL_PeepEvents (SDL_Event * events, int numevents, SDL_eventaction action, 327 SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
328 Uint32 mask) 328 Uint32 mask)
329 { 329 {
330 int i, used; 330 int i, used;
331 331
332 /* Don't look after we've quit */ 332 /* Don't look after we've quit */
333 if (!SDL_EventQ.active) { 333 if (!SDL_EventQ.active) {
334 return (-1); 334 return (-1);
335 } 335 }
336 /* Lock the event queue */ 336 /* Lock the event queue */
337 used = 0; 337 used = 0;
338 if (SDL_mutexP (SDL_EventQ.lock) == 0) { 338 if (SDL_mutexP(SDL_EventQ.lock) == 0) {
339 if (action == SDL_ADDEVENT) { 339 if (action == SDL_ADDEVENT) {
340 for (i = 0; i < numevents; ++i) { 340 for (i = 0; i < numevents; ++i) {
341 used += SDL_AddEvent (&events[i]); 341 used += SDL_AddEvent(&events[i]);
342 } 342 }
343 } else { 343 } else {
344 SDL_Event tmpevent; 344 SDL_Event tmpevent;
345 int spot; 345 int spot;
346 346
350 numevents = 1; 350 numevents = 1;
351 events = &tmpevent; 351 events = &tmpevent;
352 } 352 }
353 spot = SDL_EventQ.head; 353 spot = SDL_EventQ.head;
354 while ((used < numevents) && (spot != SDL_EventQ.tail)) { 354 while ((used < numevents) && (spot != SDL_EventQ.tail)) {
355 if (mask & SDL_EVENTMASK (SDL_EventQ.event[spot].type)) { 355 if (mask & SDL_EVENTMASK(SDL_EventQ.event[spot].type)) {
356 events[used++] = SDL_EventQ.event[spot]; 356 events[used++] = SDL_EventQ.event[spot];
357 if (action == SDL_GETEVENT) { 357 if (action == SDL_GETEVENT) {
358 spot = SDL_CutEvent (spot); 358 spot = SDL_CutEvent(spot);
359 } else { 359 } else {
360 spot = (spot + 1) % MAXEVENTS; 360 spot = (spot + 1) % MAXEVENTS;
361 } 361 }
362 } else { 362 } else {
363 spot = (spot + 1) % MAXEVENTS; 363 spot = (spot + 1) % MAXEVENTS;
364 } 364 }
365 } 365 }
366 } 366 }
367 SDL_mutexV (SDL_EventQ.lock); 367 SDL_mutexV(SDL_EventQ.lock);
368 } else { 368 } else {
369 SDL_SetError ("Couldn't lock event queue"); 369 SDL_SetError("Couldn't lock event queue");
370 used = -1; 370 used = -1;
371 } 371 }
372 return (used); 372 return (used);
373 } 373 }
374 374
375 /* Run the system dependent event loops */ 375 /* Run the system dependent event loops */
376 void 376 void
377 SDL_PumpEvents (void) 377 SDL_PumpEvents(void)
378 { 378 {
379 if (!SDL_EventThread) { 379 if (!SDL_EventThread) {
380 SDL_VideoDevice *_this = SDL_GetVideoDevice (); 380 SDL_VideoDevice *_this = SDL_GetVideoDevice();
381 381
382 /* Get events from the video subsystem */ 382 /* Get events from the video subsystem */
383 if (_this) { 383 if (_this) {
384 _this->PumpEvents (_this); 384 _this->PumpEvents(_this);
385 } 385 }
386 386
387 /* Queue pending key-repeat events */ 387 /* Queue pending key-repeat events */
388 SDL_CheckKeyRepeat (); 388 SDL_CheckKeyRepeat();
389 389
390 #if !SDL_JOYSTICK_DISABLED 390 #if !SDL_JOYSTICK_DISABLED
391 /* Check for joystick state change */ 391 /* Check for joystick state change */
392 if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) { 392 if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) {
393 SDL_JoystickUpdate (); 393 SDL_JoystickUpdate();
394 } 394 }
395 #endif 395 #endif
396 } 396 }
397 } 397 }
398 398
399 /* Public functions */ 399 /* Public functions */
400 400
401 int 401 int
402 SDL_PollEvent (SDL_Event * event) 402 SDL_PollEvent(SDL_Event * event)
403 { 403 {
404 SDL_PumpEvents (); 404 SDL_PumpEvents();
405 405
406 /* We can't return -1, just return 0 (no event) on error */ 406 /* We can't return -1, just return 0 (no event) on error */
407 if (SDL_PeepEvents (event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0) 407 if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS) <= 0)
408 return 0; 408 return 0;
409 return 1; 409 return 1;
410 } 410 }
411 411
412 int 412 int
413 SDL_WaitEvent (SDL_Event * event) 413 SDL_WaitEvent(SDL_Event * event)
414 { 414 {
415 while (1) { 415 while (1) {
416 SDL_PumpEvents (); 416 SDL_PumpEvents();
417 switch (SDL_PeepEvents (event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) { 417 switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) {
418 case -1: 418 case -1:
419 return 0; 419 return 0;
420 case 1: 420 case 1:
421 return 1; 421 return 1;
422 case 0: 422 case 0:
423 SDL_Delay (10); 423 SDL_Delay(10);
424 } 424 }
425 } 425 }
426 } 426 }
427 427
428 int 428 int
429 SDL_PushEvent (SDL_Event * event) 429 SDL_PushEvent(SDL_Event * event)
430 { 430 {
431 if (SDL_PeepEvents (event, 1, SDL_ADDEVENT, 0) <= 0) 431 if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0)
432 return -1; 432 return -1;
433 return 0; 433 return 0;
434 } 434 }
435 435
436 void 436 void
437 SDL_SetEventFilter (SDL_EventFilter filter) 437 SDL_SetEventFilter(SDL_EventFilter filter)
438 { 438 {
439 SDL_Event bitbucket; 439 SDL_Event bitbucket;
440 440
441 /* Set filter and discard pending events */ 441 /* Set filter and discard pending events */
442 SDL_EventOK = filter; 442 SDL_EventOK = filter;
443 while (SDL_PollEvent (&bitbucket) > 0); 443 while (SDL_PollEvent(&bitbucket) > 0);
444 } 444 }
445 445
446 SDL_EventFilter 446 SDL_EventFilter
447 SDL_GetEventFilter (void) 447 SDL_GetEventFilter(void)
448 { 448 {
449 return (SDL_EventOK); 449 return (SDL_EventOK);
450 } 450 }
451 451
452 Uint8 452 Uint8
453 SDL_EventState (Uint8 type, int state) 453 SDL_EventState(Uint8 type, int state)
454 { 454 {
455 SDL_Event bitbucket; 455 SDL_Event bitbucket;
456 Uint8 current_state; 456 Uint8 current_state;
457 457
458 /* If SDL_ALLEVENTS was specified... */ 458 /* If SDL_ALLEVENTS was specified... */
467 SDL_eventstate |= (0x00000001 << (type)); 467 SDL_eventstate |= (0x00000001 << (type));
468 } else { 468 } else {
469 SDL_eventstate &= ~(0x00000001 << (type)); 469 SDL_eventstate &= ~(0x00000001 << (type));
470 } 470 }
471 } 471 }
472 while (SDL_PollEvent (&bitbucket) > 0); 472 while (SDL_PollEvent(&bitbucket) > 0);
473 return (current_state); 473 return (current_state);
474 } 474 }
475 475
476 /* Just set the state for one event type */ 476 /* Just set the state for one event type */
477 current_state = SDL_ProcessEvents[type]; 477 current_state = SDL_ProcessEvents[type];
483 if (state == SDL_ENABLE) { 483 if (state == SDL_ENABLE) {
484 SDL_eventstate |= (0x00000001 << (type)); 484 SDL_eventstate |= (0x00000001 << (type));
485 } else { 485 } else {
486 SDL_eventstate &= ~(0x00000001 << (type)); 486 SDL_eventstate &= ~(0x00000001 << (type));
487 } 487 }
488 while (SDL_PollEvent (&bitbucket) > 0); 488 while (SDL_PollEvent(&bitbucket) > 0);
489 break; 489 break;
490 default: 490 default:
491 /* Querying state? */ 491 /* Querying state? */
492 break; 492 break;
493 } 493 }
495 } 495 }
496 496
497 /* This is a generic event handler. 497 /* This is a generic event handler.
498 */ 498 */
499 int 499 int
500 SDL_PrivateSysWMEvent (SDL_SysWMmsg * message) 500 SDL_PrivateSysWMEvent(SDL_SysWMmsg * message)
501 { 501 {
502 int posted; 502 int posted;
503 503
504 posted = 0; 504 posted = 0;
505 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { 505 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
506 SDL_Event event; 506 SDL_Event event;
507 SDL_memset (&event, 0, sizeof (event)); 507 SDL_memset(&event, 0, sizeof(event));
508 event.type = SDL_SYSWMEVENT; 508 event.type = SDL_SYSWMEVENT;
509 event.syswm.msg = message; 509 event.syswm.msg = message;
510 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { 510 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) {
511 posted = 1; 511 posted = 1;
512 SDL_PushEvent (&event); 512 SDL_PushEvent(&event);
513 } 513 }
514 } 514 }
515 /* Update internal event state */ 515 /* Update internal event state */
516 return (posted); 516 return (posted);
517 } 517 }