From 67c1e7f4768ec606a66aaa690563272a00f14906 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 12 Apr 2013 22:57:06 -0400 Subject: [PATCH] Implemented SDL_EventState() and SDL_WaitEvent(), other minor cleanups. --- src/SDL12_compat.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c index c10c01287..1d91da120 100644 --- a/src/SDL12_compat.c +++ b/src/SDL12_compat.c @@ -36,7 +36,6 @@ //#include "render/SDL_yuv_sw_c.h" // !!! IMPLEMENT_ME SDL_ConvertSurface -// !!! IMPLEMENT_ME SDL_EventState // !!! IMPLEMENT_ME SDL_GL_GetAttribute // !!! IMPLEMENT_ME SDL_GL_Lock // !!! IMPLEMENT_ME SDL_GL_SetAttribute @@ -54,7 +53,6 @@ // !!! IMPLEMENT_ME SDL_SoftStretch // !!! IMPLEMENT_ME SDL_UnlockSurface // !!! IMPLEMENT_ME SDL_UpperBlit -// !!! IMPLEMENT_ME SDL_WaitEvent // !!! IMPLEMENT_ME X11_KeyToUnicode @@ -336,6 +334,7 @@ static int VideoDisplayIndex = 0; static int CDRomInit = 0; static SDL12_EventFilter EventFilter12 = NULL; static SDL12_Cursor *CurrentCursor = NULL; +static Uint8 EventStates[SDL12_NUMEVENTS]; // !!! FIXME: need a mutex for the event queue. @@ -467,7 +466,8 @@ DoSDLInit(const int justsubs, Uint32 sdl12flags) EventQueuePool[SDL12_MAXEVENTS-1].next = NULL; EventQueueHead = EventQueueTail = NULL; EventQueueAvailable = EventQueuePool; - + SDL_memset(EventStates, SDL_ENABLE, sizeof (EventStates)); /* on by default */ + EventStates[SDL12_SYSWMEVENT] = SDL_IGNORE; /* off by default. */ SDL20_SetEventFilter(EventFilter20to12, NULL); VideoDisplayIndex = GetVideoDisplay(); } @@ -790,12 +790,28 @@ EventFilter20to12(void *data, SDL_Event *event20) return 0; /* drop everything else. */ } - if ((!EventFilter12) || (EventFilter12(&event12))) - SDL_PushEvent(&event12); + if (EventStates[event12->type] != SDL_IGNORE) + { + if ((!EventFilter12) || (EventFilter12(&event12))) + SDL_PushEvent(event12); + } return 0; /* always drop it from the 2.0 event queue. */ } +Uint8 +SDL_EventState(Uint8 type, int state) +{ + /* the values of "state" match between 1.2 and 2.0 */ + const Uint8 retval = EventStates[type]; + SDL12_Event e; + + if (state != SDL_QUERY) + EventStates[type] = state; + if (state == SDL_IGNORE) /* drop existing events of this type. */ + while (SDL_PeepEvents(&e, 1, SDL_GETEVENT, (1<