SDL  2.0
SDL_events_c.h File Reference
#include "../SDL_internal.h"
#include "SDL_events.h"
#include "SDL_thread.h"
#include "../video/SDL_sysvideo.h"
#include "SDL_clipboardevents_c.h"
#include "SDL_displayevents_c.h"
#include "SDL_dropevents_c.h"
#include "SDL_gesture_c.h"
#include "SDL_keyboard_c.h"
#include "SDL_mouse_c.h"
#include "SDL_touch_c.h"
#include "SDL_windowevents_c.h"
+ Include dependency graph for SDL_events_c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int SDL_StartEventLoop (void)
 
void SDL_StopEventLoop (void)
 
void SDL_QuitInterrupt (void)
 
int SDL_SendAppEvent (SDL_EventType eventType)
 
int SDL_SendSysWMEvent (SDL_SysWMmsg *message)
 
int SDL_SendKeymapChangedEvent (void)
 
int SDL_SendQuit (void)
 
int SDL_EventsInit (void)
 
void SDL_EventsQuit (void)
 
void SDL_SendPendingSignalEvents (void)
 
int SDL_QuitInit (void)
 
void SDL_QuitQuit (void)
 

Function Documentation

◆ SDL_EventsInit()

int SDL_EventsInit ( void  )

◆ SDL_EventsQuit()

◆ SDL_QuitInit()

int SDL_QuitInit ( void  )

Definition at line 154 of file SDL_quit.c.

155 {
156 #ifdef HAVE_SIGNAL_SUPPORT
158  return SDL_QuitInit_Internal();
159  }
160 #endif
161  return 0;
162 }

References SDL_FALSE, SDL_GetHintBoolean, SDL_HINT_NO_SIGNAL_HANDLERS, and SDL_QuitInit_Internal().

Referenced by SDL_EventsInit().

◆ SDL_QuitInterrupt()

void SDL_QuitInterrupt ( void  )

◆ SDL_QuitQuit()

void SDL_QuitQuit ( void  )

Definition at line 165 of file SDL_quit.c.

166 {
167 #ifdef HAVE_SIGNAL_SUPPORT
168  if (!disable_signals) {
170  }
171 #endif
172 }

References disable_signals, and SDL_QuitQuit_Internal().

Referenced by SDL_EventsQuit().

◆ SDL_SendAppEvent()

int SDL_SendAppEvent ( SDL_EventType  eventType)

Definition at line 972 of file SDL_events.c.

973 {
974  int posted;
975 
976  posted = 0;
977  if (SDL_GetEventState(eventType) == SDL_ENABLE) {
979  event.type = eventType;
980  posted = (SDL_PushEvent(&event) > 0);
981  }
982  return (posted);
983 }

References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().

Referenced by SDL_OnApplicationDidBecomeActive(), SDL_OnApplicationDidEnterBackground(), SDL_OnApplicationDidReceiveMemoryWarning(), SDL_OnApplicationWillEnterForeground(), SDL_OnApplicationWillResignActive(), SDL_OnApplicationWillTerminate(), SDL_SendKeymapChangedEvent(), and SDL_SendQuit().

◆ SDL_SendKeymapChangedEvent()

int SDL_SendKeymapChangedEvent ( void  )

Definition at line 1003 of file SDL_events.c.

1004 {
1006 }

References SDL_KEYMAPCHANGED, and SDL_SendAppEvent().

◆ SDL_SendPendingSignalEvents()

void SDL_SendPendingSignalEvents ( void  )

Definition at line 175 of file SDL_quit.c.

176 {
177 #ifdef HAVE_SIGNAL_SUPPORT
178  if (send_quit_pending) {
179  SDL_SendQuit();
181  }
182 
183  #ifdef SDL_BACKGROUNDING_SIGNAL
184  if (send_backgrounding_pending) {
185  send_backgrounding_pending = SDL_FALSE;
187  }
188  #endif
189 
190  #ifdef SDL_FOREGROUNDING_SIGNAL
191  if (send_foregrounding_pending) {
192  send_foregrounding_pending = SDL_FALSE;
194  }
195  #endif
196 #endif
197 }

References SDL_assert, SDL_FALSE, SDL_OnApplicationDidBecomeActive, SDL_OnApplicationWillResignActive, SDL_SendQuit(), and send_quit_pending.

Referenced by SDL_PumpEvents().

◆ SDL_SendQuit()

int SDL_SendQuit ( void  )

Definition at line 201 of file SDL_quit.c.

202 {
203 #ifdef HAVE_SIGNAL_SUPPORT
205 #endif
206  return SDL_SendAppEvent(SDL_QUIT);
207 }

References SDL_FALSE, SDL_QUIT, SDL_SendAppEvent(), and send_quit_pending.

Referenced by SDL_SendPendingSignalEvents(), and SDL_SendWindowEvent().

◆ SDL_SendSysWMEvent()

int SDL_SendSysWMEvent ( SDL_SysWMmsg message)

Definition at line 986 of file SDL_events.c.

987 {
988  int posted;
989 
990  posted = 0;
993  SDL_memset(&event, 0, sizeof(event));
994  event.type = SDL_SYSWMEVENT;
995  event.syswm.msg = message;
996  posted = (SDL_PushEvent(&event) > 0);
997  }
998  /* Update internal event state */
999  return (posted);
1000 }

References SDL_ENABLE, SDL_GetEventState, SDL_memset, SDL_PushEvent(), and SDL_SYSWMEVENT.

◆ SDL_StartEventLoop()

int SDL_StartEventLoop ( void  )

Definition at line 421 of file SDL_events.c.

422 {
423  /* We'll leave the event queue alone, since we might have gotten
424  some important events at launch (like SDL_DROPFILE)
425 
426  FIXME: Does this introduce any other bugs with events at startup?
427  */
428 
429  /* Create the lock and set ourselves active */
430 #if !SDL_THREADS_DISABLED
431  if (!SDL_EventQ.lock) {
432  SDL_EventQ.lock = SDL_CreateMutex();
433  if (SDL_EventQ.lock == NULL) {
434  return -1;
435  }
436  }
437 
440  if (SDL_event_watchers_lock == NULL) {
441  return -1;
442  }
443  }
444 #endif /* !SDL_THREADS_DISABLED */
445 
446  /* Process most event types */
450 #if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */
453 #endif
454 
455  SDL_AtomicSet(&SDL_EventQ.active, 1);
456 
457  return 0;
458 }

References NULL, SDL_AtomicSet, SDL_CreateMutex, SDL_DISABLE, SDL_DROPFILE, SDL_DROPTEXT, SDL_event_watchers_lock, SDL_EventQ, SDL_EventState(), SDL_SYSWMEVENT, SDL_TEXTEDITING, and SDL_TEXTINPUT.

Referenced by SDL_EventsInit().

◆ SDL_StopEventLoop()

void SDL_StopEventLoop ( void  )

Definition at line 347 of file SDL_events.c.

348 {
349  const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS");
350  int i;
351  SDL_EventEntry *entry;
352  SDL_SysWMEntry *wmmsg;
353 
354  if (SDL_EventQ.lock) {
356  }
357 
358  SDL_AtomicSet(&SDL_EventQ.active, 0);
359 
360  if (report && SDL_atoi(report)) {
361  SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n",
362  SDL_EventQ.max_events_seen);
363  }
364 
365  /* Clean out EventQ */
366  for (entry = SDL_EventQ.head; entry; ) {
367  SDL_EventEntry *next = entry->next;
368  SDL_free(entry);
369  entry = next;
370  }
371  for (entry = SDL_EventQ.free; entry; ) {
372  SDL_EventEntry *next = entry->next;
373  SDL_free(entry);
374  entry = next;
375  }
376  for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; ) {
377  SDL_SysWMEntry *next = wmmsg->next;
378  SDL_free(wmmsg);
379  wmmsg = next;
380  }
381  for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg; ) {
382  SDL_SysWMEntry *next = wmmsg->next;
383  SDL_free(wmmsg);
384  wmmsg = next;
385  }
386 
387  SDL_AtomicSet(&SDL_EventQ.count, 0);
388  SDL_EventQ.max_events_seen = 0;
389  SDL_EventQ.head = NULL;
390  SDL_EventQ.tail = NULL;
391  SDL_EventQ.free = NULL;
392  SDL_EventQ.wmmsg_used = NULL;
393  SDL_EventQ.wmmsg_free = NULL;
394 
395  /* Clear disabled event state */
396  for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
399  }
400 
404  }
405  if (SDL_event_watchers) {
409  }
411 
412  if (SDL_EventQ.lock) {
415  SDL_EventQ.lock = NULL;
416  }
417 }

References i, SDL_EventEntry::next, SDL_SysWMEntry::next, NULL, SDL_arraysize, SDL_atoi, SDL_AtomicSet, SDL_DestroyMutex, SDL_disabled_events, SDL_event_watchers, SDL_event_watchers_count, SDL_event_watchers_lock, SDL_EventOK, SDL_EventQ, SDL_free, SDL_GetHint, SDL_LockMutex, SDL_Log, SDL_UnlockMutex, and SDL_zero.

Referenced by SDL_EventsQuit().

SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:418
SDL_SysWMEntry
Definition: SDL_events.c:76
SDL_memset
#define SDL_memset
Definition: SDL_dynapi_overrides.h:386
disable_signals
static SDL_bool disable_signals
Definition: SDL_quit.c:39
SDL_QuitQuit_Internal
static void SDL_QuitQuit_Internal(void)
Definition: SDL_quit.c:138
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_event_watchers_count
static int SDL_event_watchers_count
Definition: SDL_events.c:55
NULL
#define NULL
Definition: begin_code.h:167
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2486
SDL_TEXTEDITING
@ SDL_TEXTEDITING
Definition: SDL_events.h:98
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:760
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_EventEntry
Definition: SDL_events.c:68
SDL_QuitQuit
void SDL_QuitQuit(void)
Definition: SDL_quit.c:165
SDL_event_watchers_lock
static SDL_mutex * SDL_event_watchers_lock
Definition: SDL_events.c:52
SDL_EventQ
static struct @16 SDL_EventQ
SDL_PushEvent
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:748
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2652
SDL_SysWMEntry::next
struct _SDL_SysWMEntry * next
Definition: SDL_events.c:78
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:773
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
SDL_TEXTINPUT
@ SDL_TEXTINPUT
Definition: SDL_events.h:99
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_DROPTEXT
@ SDL_DROPTEXT
Definition: SDL_events.h:142
SDL_QUIT
@ SDL_QUIT
Definition: SDL_events.h:60
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:201
SDL_QuitInit
int SDL_QuitInit(void)
Definition: SDL_quit.c:154
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_DISABLE
#define SDL_DISABLE
Definition: SDL_events.h:759
SDL_KEYMAPCHANGED
@ SDL_KEYMAPCHANGED
Definition: SDL_events.h:100
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_atoi
#define SDL_atoi
Definition: SDL_dynapi_overrides.h:410
SDL_HINT_NO_SIGNAL_HANDLERS
#define SDL_HINT_NO_SIGNAL_HANDLERS
Tell SDL not to catch the SIGINT or SIGTERM signals.
Definition: SDL_hints.h:1007
SDL_AddHintCallback
#define SDL_AddHintCallback
Definition: SDL_dynapi_overrides.h:192
SDL_EventState
Uint8 SDL_EventState(Uint32 type, int state)
Definition: SDL_events.c:909
SDL_EventOK
static SDL_EventWatcher SDL_EventOK
Definition: SDL_events.c:53
SDL_HINT_EVENT_LOGGING
#define SDL_HINT_EVENT_LOGGING
A variable controlling whether SDL logs all events pushed onto its internal queue.
Definition: SDL_hints.h:1193
SDL_disabled_events
static SDL_DisabledEventBlock * SDL_disabled_events[256]
Definition: SDL_events.c:63
SDL_StopEventLoop
void SDL_StopEventLoop(void)
Definition: SDL_events.c:347
SDL_event_watchers
static SDL_EventWatcher * SDL_event_watchers
Definition: SDL_events.c:54
SDL_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
SDL_QuitInit_Internal
static int SDL_QuitInit_Internal(void)
Definition: SDL_quit.c:118
SDL_SYSWMEVENT
@ SDL_SYSWMEVENT
Definition: SDL_events.h:93
SDL_EventEntry::next
struct _SDL_EventEntry * next
Definition: SDL_events.c:72
SDL_OnApplicationWillResignActive
#define SDL_OnApplicationWillResignActive
Definition: SDL_dynapi_overrides.h:744
SDL_Event
General event structure.
Definition: SDL_events.h:559
send_quit_pending
static SDL_bool send_quit_pending
Definition: SDL_quit.c:40
SDL_EventLoggingChanged
static void SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_events.c:99
SDL_DelHintCallback
#define SDL_DelHintCallback
Definition: SDL_dynapi_overrides.h:193
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_AtomicSet
#define SDL_AtomicSet
Definition: SDL_dynapi_overrides.h:67
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
SDL_SendAppEvent
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:972
SDL_DROPFILE
@ SDL_DROPFILE
Definition: SDL_events.h:141
SDL_OnApplicationDidBecomeActive
#define SDL_OnApplicationDidBecomeActive
Definition: SDL_dynapi_overrides.h:747
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_StartEventLoop
int SDL_StartEventLoop(void)
Definition: SDL_events.c:421