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_SendLocaleChangedEvent (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  )

Definition at line 1078 of file SDL_events.c.

1079 {
1080 #if !SDL_JOYSTICK_DISABLED
1082 #endif
1083 #if !SDL_SENSOR_DISABLED
1085 #endif
1087  if (SDL_StartEventLoop() < 0) {
1089  return -1;
1090  }
1091 
1092  SDL_QuitInit();
1093 
1094  return 0;
1095 }
#define SDL_DelHintCallback
#define SDL_AddHintCallback
static void SDL_AutoUpdateSensorsChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_events.c:135
static void SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_events.c:147
static void SDL_AutoUpdateJoysticksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
Definition: SDL_events.c:111
int SDL_StartEventLoop(void)
Definition: SDL_events.c:469
int SDL_QuitInit(void)
Definition: SDL_quit.c:154
#define SDL_HINT_AUTO_UPDATE_JOYSTICKS
A variable controlling whether SDL updates joystick state when getting input events.
Definition: SDL_hints.h:1315
#define SDL_HINT_EVENT_LOGGING
A variable controlling whether SDL logs all events pushed onto its internal queue.
Definition: SDL_hints.h:1350
#define SDL_HINT_AUTO_UPDATE_SENSORS
A variable controlling whether SDL updates sensor state when getting input events.
Definition: SDL_hints.h:1328
#define NULL
Definition: begin_code.h:163

References NULL, SDL_AddHintCallback, SDL_AutoUpdateJoysticksChanged(), SDL_AutoUpdateSensorsChanged(), SDL_DelHintCallback, SDL_EventLoggingChanged(), SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_HINT_AUTO_UPDATE_SENSORS, SDL_HINT_EVENT_LOGGING, SDL_QuitInit(), and SDL_StartEventLoop().

Referenced by SDL_InitSubSystem().

◆ 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 }
#define SDL_GetHintBoolean
#define SDL_HINT_NO_SIGNAL_HANDLERS
Tell SDL not to catch the SIGINT or SIGTERM signals.
Definition: SDL_hints.h:1138
static int SDL_QuitInit_Internal(void)
Definition: SDL_quit.c:118
@ SDL_FALSE
Definition: SDL_stdinc.h:169

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 }
static SDL_bool disable_signals
Definition: SDL_quit.c:39
static void SDL_QuitQuit_Internal(void)
Definition: SDL_quit.c:138

References disable_signals, and SDL_QuitQuit_Internal().

Referenced by SDL_EventsQuit().

◆ SDL_SendAppEvent()

int SDL_SendAppEvent ( SDL_EventType  eventType)

Definition at line 1035 of file SDL_events.c.

1036 {
1037  int posted;
1038 
1039  posted = 0;
1040  if (SDL_GetEventState(eventType) == SDL_ENABLE) {
1041  SDL_Event event;
1042  event.type = eventType;
1043  posted = (SDL_PushEvent(&event) > 0);
1044  }
1045  return (posted);
1046 }
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:800
#define SDL_GetEventState(type)
Definition: SDL_events.h:808
#define SDL_ENABLE
Definition: SDL_events.h:795
struct _cl_event * event
General event structure.
Definition: SDL_events.h:592

References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().

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

◆ SDL_SendKeymapChangedEvent()

int SDL_SendKeymapChangedEvent ( void  )

Definition at line 1066 of file SDL_events.c.

1067 {
1069 }
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:1035
@ SDL_KEYMAPCHANGED
Definition: SDL_events.h:102

References SDL_KEYMAPCHANGED, and SDL_SendAppEvent().

◆ SDL_SendLocaleChangedEvent()

int SDL_SendLocaleChangedEvent ( void  )

Definition at line 1072 of file SDL_events.c.

1073 {
1075 }
@ SDL_LOCALECHANGED
Definition: SDL_events.h:88

References SDL_LOCALECHANGED, and SDL_SendAppEvent().

Referenced by SDL_BApp::MessageReceived().

◆ 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 }
#define SDL_assert(condition)
Definition: SDL_assert.h:171
#define SDL_OnApplicationWillResignActive
#define SDL_OnApplicationDidBecomeActive
static SDL_bool send_quit_pending
Definition: SDL_quit.c:40
int SDL_SendQuit(void)
Definition: SDL_quit.c:201

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 }
@ SDL_QUIT
Definition: SDL_events.h:60

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 1049 of file SDL_events.c.

1050 {
1051  int posted;
1052 
1053  posted = 0;
1055  SDL_Event event;
1056  SDL_memset(&event, 0, sizeof(event));
1057  event.type = SDL_SYSWMEVENT;
1058  event.syswm.msg = message;
1059  posted = (SDL_PushEvent(&event) > 0);
1060  }
1061  /* Update internal event state */
1062  return (posted);
1063 }
#define SDL_memset
@ SDL_SYSWMEVENT
Definition: SDL_events.h:95
GLuint GLsizei const GLchar * message

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

◆ SDL_StartEventLoop()

int SDL_StartEventLoop ( void  )

Definition at line 469 of file SDL_events.c.

470 {
471  /* We'll leave the event queue alone, since we might have gotten
472  some important events at launch (like SDL_DROPFILE)
473 
474  FIXME: Does this introduce any other bugs with events at startup?
475  */
476 
477  /* Create the lock and set ourselves active */
478 #if !SDL_THREADS_DISABLED
479  if (!SDL_EventQ.lock) {
480  SDL_EventQ.lock = SDL_CreateMutex();
481  if (SDL_EventQ.lock == NULL) {
482  return -1;
483  }
484  }
485 
488  if (SDL_event_watchers_lock == NULL) {
489  return -1;
490  }
491  }
492 #endif /* !SDL_THREADS_DISABLED */
493 
494  /* Process most event types */
498 #if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */
501 #endif
502 
503  SDL_AtomicSet(&SDL_EventQ.active, 1);
504 
505  return 0;
506 }
#define SDL_AtomicSet
#define SDL_CreateMutex
static SDL_mutex * SDL_event_watchers_lock
Definition: SDL_events.c:52
static struct @26 SDL_EventQ
Uint8 SDL_EventState(Uint32 type, int state)
Definition: SDL_events.c:961
@ SDL_TEXTEDITING
Definition: SDL_events.h:100
@ SDL_DROPTEXT
Definition: SDL_events.h:148
@ SDL_TEXTINPUT
Definition: SDL_events.h:101
@ SDL_DROPFILE
Definition: SDL_events.h:147
#define SDL_DISABLE
Definition: SDL_events.h:794

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 395 of file SDL_events.c.

396 {
397  const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS");
398  int i;
399  SDL_EventEntry *entry;
400  SDL_SysWMEntry *wmmsg;
401 
402  if (SDL_EventQ.lock) {
404  }
405 
406  SDL_AtomicSet(&SDL_EventQ.active, 0);
407 
408  if (report && SDL_atoi(report)) {
409  SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n",
410  SDL_EventQ.max_events_seen);
411  }
412 
413  /* Clean out EventQ */
414  for (entry = SDL_EventQ.head; entry; ) {
415  SDL_EventEntry *next = entry->next;
416  SDL_free(entry);
417  entry = next;
418  }
419  for (entry = SDL_EventQ.free; entry; ) {
420  SDL_EventEntry *next = entry->next;
421  SDL_free(entry);
422  entry = next;
423  }
424  for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; ) {
425  SDL_SysWMEntry *next = wmmsg->next;
426  SDL_free(wmmsg);
427  wmmsg = next;
428  }
429  for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg; ) {
430  SDL_SysWMEntry *next = wmmsg->next;
431  SDL_free(wmmsg);
432  wmmsg = next;
433  }
434 
435  SDL_AtomicSet(&SDL_EventQ.count, 0);
436  SDL_EventQ.max_events_seen = 0;
437  SDL_EventQ.head = NULL;
438  SDL_EventQ.tail = NULL;
439  SDL_EventQ.free = NULL;
440  SDL_EventQ.wmmsg_used = NULL;
441  SDL_EventQ.wmmsg_free = NULL;
442 
443  /* Clear disabled event state */
444  for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
447  }
448 
452  }
453  if (SDL_event_watchers) {
457  }
459 
460  if (SDL_EventQ.lock) {
463  SDL_EventQ.lock = NULL;
464  }
465 }
#define SDL_LockMutex
#define SDL_free
#define SDL_DestroyMutex
#define SDL_atoi
#define SDL_Log
#define SDL_GetHint
#define SDL_UnlockMutex
static int SDL_event_watchers_count
Definition: SDL_events.c:55
static SDL_EventWatcher * SDL_event_watchers
Definition: SDL_events.c:54
static SDL_DisabledEventBlock * SDL_disabled_events[256]
Definition: SDL_events.c:63
static SDL_EventWatcher SDL_EventOK
Definition: SDL_events.c:53
#define SDL_zero(x)
Definition: SDL_stdinc.h:426
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:121
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
Definition: SDL_events.c:68
struct _SDL_EventEntry * next
Definition: SDL_events.c:72
Definition: SDL_events.c:76
struct _SDL_SysWMEntry * next
Definition: SDL_events.c:78

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().