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

966 {
967  int posted;
968 
969  posted = 0;
970  if (SDL_GetEventState(eventType) == SDL_ENABLE) {
972  event.type = eventType;
973  posted = (SDL_PushEvent(&event) > 0);
974  }
975  return (posted);
976 }

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

997 {
999 }

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

980 {
981  int posted;
982 
983  posted = 0;
986  SDL_memset(&event, 0, sizeof(event));
987  event.type = SDL_SYSWMEVENT;
988  event.syswm.msg = message;
989  posted = (SDL_PushEvent(&event) > 0);
990  }
991  /* Update internal event state */
992  return (posted);
993 }

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

◆ SDL_StartEventLoop()

int SDL_StartEventLoop ( void  )

Definition at line 414 of file SDL_events.c.

415 {
416  /* We'll leave the event queue alone, since we might have gotten
417  some important events at launch (like SDL_DROPFILE)
418 
419  FIXME: Does this introduce any other bugs with events at startup?
420  */
421 
422  /* Create the lock and set ourselves active */
423 #if !SDL_THREADS_DISABLED
424  if (!SDL_EventQ.lock) {
425  SDL_EventQ.lock = SDL_CreateMutex();
426  if (SDL_EventQ.lock == NULL) {
427  return -1;
428  }
429  }
430 
433  if (SDL_event_watchers_lock == NULL) {
434  return -1;
435  }
436  }
437 #endif /* !SDL_THREADS_DISABLED */
438 
439  /* Process most event types */
443 #if 0 /* Leave these events enabled so apps can respond to items being dragged onto them at startup */
446 #endif
447 
448  SDL_AtomicSet(&SDL_EventQ.active, 1);
449 
450  return 0;
451 }

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

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

References i, _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:416
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:48
NULL
#define NULL
Definition: begin_code.h:167
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2483
SDL_OnApplicationWillResignActive
void SDL_OnApplicationWillResignActive(void)
Definition: SDL_video.c:4042
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:759
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
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:45
SDL_PushEvent
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:741
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:772
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_EventQ
static struct @23 SDL_EventQ
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_DISABLE
#define SDL_DISABLE
Definition: SDL_events.h:758
SDL_OnApplicationDidBecomeActive
void SDL_OnApplicationDidBecomeActive(void)
Definition: SDL_video.c:4064
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:923
SDL_AddHintCallback
#define SDL_AddHintCallback
Definition: SDL_dynapi_overrides.h:192
SDL_EventState
Uint8 SDL_EventState(Uint32 type, int state)
Definition: SDL_events.c:902
SDL_EventOK
static SDL_EventWatcher SDL_EventOK
Definition: SDL_events.c:46
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:1109
SDL_disabled_events
static SDL_DisabledEventBlock * SDL_disabled_events[256]
Definition: SDL_events.c:56
SDL_StopEventLoop
void SDL_StopEventLoop(void)
Definition: SDL_events.c:340
SDL_event_watchers
static SDL_EventWatcher * SDL_event_watchers
Definition: SDL_events.c:47
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_Event
General event structure.
Definition: SDL_events.h:557
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:92
SDL_DelHintCallback
#define SDL_DelHintCallback
Definition: SDL_dynapi_overrides.h:193
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:965
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_DROPFILE
@ SDL_DROPFILE
Definition: SDL_events.h:141
SDL_StartEventLoop
int SDL_StartEventLoop(void)
Definition: SDL_events.c:414