SDL_events_c.h File Reference
`#include "../SDL_internal.h"`
`#include "SDL_events.h"`
`#include "SDL_thread.h"`
`#include "SDL_clipboardevents_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_QuitInit (void)
int | SDL_SendQuit (void)
void | SDL_QuitQuit (void)
void | SDL_SendPendingQuit (void)

## Function Documentation

## SDL_QuitInit()

int SDL_QuitInit | ( | void |  | ) |

Definition at line 92 of file SDL_quit.c.

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

Referenced by SDL_InitSubSystem().

{
if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
return SDL_QuitInit_Internal();
}
return 0;
}
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
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:791
SDL_QuitInit_Internal
static int SDL_QuitInit_Internal(void)
Definition: SDL_quit.c:52

## SDL_QuitInterrupt()

void SDL_QuitInterrupt | ( | void |  | ) |

## SDL_QuitQuit()

void SDL_QuitQuit | ( | void |  | ) |

Definition at line 128 of file SDL_quit.c.

References disable_signals, and SDL_QuitQuit_Internal().

Referenced by SDL_QuitSubSystem().

{
if (!disable_signals) {
SDL_QuitQuit_Internal();
}
}
disable_signals
static SDL_bool disable_signals
Definition: SDL_quit.c:34
SDL_QuitQuit_Internal
static void SDL_QuitQuit_Internal(void)
Definition: SDL_quit.c:101

## SDL_SendAppEvent()

int SDL_SendAppEvent | ( | SDL_EventType | eventType | ) |

Definition at line 919 of file SDL_events.c.

References SDL_ENABLE, SDL_GetEventState, and SDL_PushEvent().

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

{
int posted;
posted = 0;
if (SDL_GetEventState(eventType) == SDL_ENABLE) {
SDL_Event event;
event.type = eventType;
posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
}
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:722
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:703
SDL_Event
General event structure.
Definition: SDL_events.h:525

## SDL_SendKeymapChangedEvent()

int SDL_SendKeymapChangedEvent | ( | void |  | ) |

Definition at line 950 of file SDL_events.c.

References SDL_KEYMAPCHANGED, and SDL_SendAppEvent().

{
return SDL_SendAppEvent(SDL_KEYMAPCHANGED);
}
SDL_SendAppEvent
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:919
SDL_KEYMAPCHANGED
Definition: SDL_events.h:97

## SDL_SendPendingQuit()

void SDL_SendPendingQuit | ( | void |  | ) |

Definition at line 144 of file SDL_quit.c.

References SDL_assert, SDL_SendQuit(), and send_quit_pending.

Referenced by SDL_PumpEvents().

{
if (send_quit_pending) {
SDL_SendQuit();
SDL_assert(!send_quit_pending);
}
}
send_quit_pending
static SDL_bool send_quit_pending
Definition: SDL_quit.c:35
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:137
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169

## SDL_SendQuit()

int SDL_SendQuit | ( | void |  | ) |

Definition at line 137 of file SDL_quit.c.

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

Referenced by SDL_SendPendingQuit(), and SDL_SendWindowEvent().

{
send_quit_pending = SDL_FALSE;
return SDL_SendAppEvent(SDL_QUIT);
}
SDL_FALSE
Definition: SDL_stdinc.h:141
SDL_QUIT
Definition: SDL_events.h:60
send_quit_pending
static SDL_bool send_quit_pending
Definition: SDL_quit.c:35
SDL_SendAppEvent
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:919

## SDL_SendSysWMEvent()

int SDL_SendSysWMEvent | ( | SDL_SysWMmsg * | message | ) |

Definition at line 933 of file SDL_events.c.

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

{
int posted;
posted = 0;
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
SDL_Event event;
SDL_memset(&event, 0, sizeof(event));
event.type = SDL_SYSWMEVENT;
event.syswm.msg = message;
posted = (SDL_PushEvent(&event) > 0);
}
/* Update internal event state */
return (posted);
}
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2483
SDL_SYSWMEVENT
Definition: SDL_events.h:90
SDL_ENABLE
#define SDL_ENABLE
Definition: SDL_events.h:722
SDL_GetEventState
#define SDL_GetEventState(type)
Definition: SDL_events.h:735
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
SDL_PushEvent
int SDL_PushEvent(SDL_Event *event)
Add an event to the event queue.
Definition: SDL_events.c:703
SDL_Event
General event structure.
Definition: SDL_events.h:525
SDL_memset
#define SDL_memset
Definition: SDL_dynapi_overrides.h:386

## SDL_StartEventLoop()

int SDL_StartEventLoop | ( | void |  | ) |

Definition at line 391 of file SDL_events.c.

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

Referenced by SDL_InitSubSystem().

{
/* We'll leave the event queue alone, since we might have gotten
some important events at launch (like SDL_DROPFILE)
FIXME: Does this introduce any other bugs with events at startup?
*/
/* Create the lock and set ourselves active */
#if !SDL_THREADS_DISABLED
if (!SDL_EventQ.lock) {
SDL_EventQ.lock = SDL_CreateMutex();
if (SDL_EventQ.lock == NULL) {
return -1;
}
}
if (!SDL_event_watchers_lock) {
SDL_event_watchers_lock = SDL_CreateMutex();
if (SDL_event_watchers_lock == NULL) {
return -1;
}
}
#endif /* !SDL_THREADS_DISABLED */
/* Process most event types */
SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
SDL_AtomicSet(&SDL_EventQ.active, 1);
return 0;
}
SDL_SYSWMEVENT
Definition: SDL_events.h:90
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_EventQ
static struct @22 SDL_EventQ
SDL_EventState
Uint8 SDL_EventState(Uint32 type, int state)
Definition: SDL_events.c:864
SDL_DISABLE
#define SDL_DISABLE
Definition: SDL_events.h:721
NULL
#define NULL
Definition: begin_code.h:164
SDL_TEXTINPUT
Definition: SDL_events.h:96
SDL_event_watchers_lock
static SDL_mutex * SDL_event_watchers_lock
Definition: SDL_events.c:47
SDL_AtomicSet
#define SDL_AtomicSet
Definition: SDL_dynapi_overrides.h:67
SDL_TEXTEDITING
Definition: SDL_events.h:95

## SDL_StopEventLoop()

void SDL_StopEventLoop | ( | void |  | ) |

Definition at line 317 of file SDL_events.c.

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

Referenced by SDL_QuitSubSystem().

{
const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS");
int i;
SDL_EventEntry *entry;
SDL_SysWMEntry *wmmsg;
if (SDL_EventQ.lock) {
SDL_LockMutex(SDL_EventQ.lock);
}
SDL_AtomicSet(&SDL_EventQ.active, 0);
if (report && SDL_atoi(report)) {
SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n",
SDL_EventQ.max_events_seen);
}
/* Clean out EventQ */
for (entry = SDL_EventQ.head; entry; ) {
SDL_EventEntry *next = entry->next;
SDL_free(entry);
entry = next;
}
for (entry = SDL_EventQ.free; entry; ) {
SDL_EventEntry *next = entry->next;
SDL_free(entry);
entry = next;
}
for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; ) {
SDL_SysWMEntry *next = wmmsg->next;
SDL_free(wmmsg);
wmmsg = next;
}
for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg; ) {
SDL_SysWMEntry *next = wmmsg->next;
SDL_free(wmmsg);
wmmsg = next;
}
SDL_AtomicSet(&SDL_EventQ.count, 0);
SDL_EventQ.max_events_seen = 0;
SDL_EventQ.head = NULL;
SDL_EventQ.tail = NULL;
SDL_EventQ.free = NULL;
SDL_EventQ.wmmsg_used = NULL;
SDL_EventQ.wmmsg_free = NULL;
/* Clear disabled event state */
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
SDL_free(SDL_disabled_events[i]);
SDL_disabled_events[i] = NULL;
}
if (SDL_event_watchers_lock) {
SDL_DestroyMutex(SDL_event_watchers_lock);
SDL_event_watchers_lock = NULL;
}
if (SDL_event_watchers) {
SDL_free(SDL_event_watchers);
SDL_event_watchers = NULL;
SDL_event_watchers_count = 0;
}
SDL_zero(SDL_EventOK);
if (SDL_EventQ.lock) {
SDL_UnlockMutex(SDL_EventQ.lock);
SDL_DestroyMutex(SDL_EventQ.lock);
SDL_EventQ.lock = NULL;
}
}
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
SDL_event_watchers
static SDL_EventWatcher * SDL_event_watchers
Definition: SDL_events.c:49
SDL_EventEntry::next
struct _SDL_EventEntry * next
Definition: SDL_events.c:67
SDL_event_watchers_count
static int SDL_event_watchers_count
Definition: SDL_events.c:50
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_SysWMEntry
Definition: SDL_events.c:70
SDL_EventQ
static struct @22 SDL_EventQ
SDL_SysWMEntry::next
struct _SDL_SysWMEntry * next
Definition: SDL_events.c:73
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_EventEntry
Definition: SDL_events.c:62
SDL_atoi
#define SDL_atoi
Definition: SDL_dynapi_overrides.h:410
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
NULL
#define NULL
Definition: begin_code.h:164
SDL_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
SDL_disabled_events
static SDL_DisabledEventBlock * SDL_disabled_events[256]
Definition: SDL_events.c:58
SDL_event_watchers_lock
static SDL_mutex * SDL_event_watchers_lock
Definition: SDL_events.c:47
SDL_AtomicSet
#define SDL_AtomicSet
Definition: SDL_dynapi_overrides.h:67
SDL_EventOK
static SDL_EventWatcher SDL_EventOK
Definition: SDL_events.c:48
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93