Allow events at startup so we don't lose important events like SDL_DROPFILE
This commit is contained in:
parent
40117e88dc
commit
211e6c359c
1 changed files with 10 additions and 8 deletions
|
@ -63,7 +63,7 @@ static struct
|
||||||
SDL_Event event[MAXEVENTS];
|
SDL_Event event[MAXEVENTS];
|
||||||
int wmmsg_next;
|
int wmmsg_next;
|
||||||
struct SDL_SysWMmsg wmmsg[MAXEVENTS];
|
struct SDL_SysWMmsg wmmsg[MAXEVENTS];
|
||||||
} SDL_EventQ;
|
} SDL_EventQ = { NULL, 1 };
|
||||||
|
|
||||||
|
|
||||||
static __inline__ SDL_bool
|
static __inline__ SDL_bool
|
||||||
|
@ -117,18 +117,21 @@ SDL_StopEventLoop(void)
|
||||||
int
|
int
|
||||||
SDL_StartEventLoop(void)
|
SDL_StartEventLoop(void)
|
||||||
{
|
{
|
||||||
/* Clean out the event queue */
|
/* We'll leave the event queue alone, since we might have gotten
|
||||||
SDL_EventQ.lock = NULL;
|
some important events at launch (like SDL_DROPFILE)
|
||||||
SDL_StopEventLoop();
|
|
||||||
|
FIXME: Does this introduce any other bugs with events at startup?
|
||||||
|
*/
|
||||||
|
|
||||||
/* No filter to start with, process most event types */
|
/* No filter to start with, process most event types */
|
||||||
SDL_EventOK = NULL;
|
SDL_EventOK = NULL;
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
|
|
||||||
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
|
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
|
||||||
|
|
||||||
/* Create the lock and set ourselves active */
|
/* Create the lock and set ourselves active */
|
||||||
#if !SDL_THREADS_DISABLED
|
#if !SDL_THREADS_DISABLED
|
||||||
SDL_EventQ.lock = SDL_CreateMutex();
|
if (!SDL_EventQ.lock) {
|
||||||
|
SDL_EventQ.lock = SDL_CreateMutex();
|
||||||
|
}
|
||||||
if (SDL_EventQ.lock == NULL) {
|
if (SDL_EventQ.lock == NULL) {
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +210,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
|
||||||
}
|
}
|
||||||
/* Lock the event queue */
|
/* Lock the event queue */
|
||||||
used = 0;
|
used = 0;
|
||||||
if (SDL_mutexP(SDL_EventQ.lock) == 0) {
|
if (!SDL_EventQ.lock || SDL_mutexP(SDL_EventQ.lock) == 0) {
|
||||||
if (action == SDL_ADDEVENT) {
|
if (action == SDL_ADDEVENT) {
|
||||||
for (i = 0; i < numevents; ++i) {
|
for (i = 0; i < numevents; ++i) {
|
||||||
used += SDL_AddEvent(&events[i]);
|
used += SDL_AddEvent(&events[i]);
|
||||||
|
@ -374,7 +377,6 @@ SDL_PushEvent(SDL_Event * event)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GestureProcessEvent(event);
|
SDL_GestureProcessEvent(event);
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue