Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Allow events at startup so we don't lose important events like SDL_DR…
Browse files Browse the repository at this point in the history
…OPFILE
  • Loading branch information
slouken committed Oct 14, 2012
1 parent b827827 commit 5552b4c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/events/SDL_events.c
Expand Up @@ -63,7 +63,7 @@ static struct
SDL_Event event[MAXEVENTS];
int wmmsg_next;
struct SDL_SysWMmsg wmmsg[MAXEVENTS];
} SDL_EventQ;
} SDL_EventQ = { NULL, 1 };


static __inline__ SDL_bool
Expand Down Expand Up @@ -117,18 +117,21 @@ SDL_StopEventLoop(void)
int
SDL_StartEventLoop(void)
{
/* Clean out the event queue */
SDL_EventQ.lock = NULL;
SDL_StopEventLoop();
/* 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?
*/

/* No filter to start with, process most event types */
SDL_EventOK = NULL;
SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);

/* Create the lock and set ourselves active */
#if !SDL_THREADS_DISABLED
SDL_EventQ.lock = SDL_CreateMutex();
if (!SDL_EventQ.lock) {
SDL_EventQ.lock = SDL_CreateMutex();
}
if (SDL_EventQ.lock == NULL) {
return (-1);
}
Expand Down Expand Up @@ -207,7 +210,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
}
/* Lock the event queue */
used = 0;
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
if (!SDL_EventQ.lock || SDL_mutexP(SDL_EventQ.lock) == 0) {
if (action == SDL_ADDEVENT) {
for (i = 0; i < numevents; ++i) {
used += SDL_AddEvent(&events[i]);
Expand Down Expand Up @@ -374,7 +377,6 @@ SDL_PushEvent(SDL_Event * event)
}

SDL_GestureProcessEvent(event);


return 1;
}
Expand Down

0 comments on commit 5552b4c

Please sign in to comment.