X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=f4e690f82c2ddbe6b6d3f3aba10df575f4bc9025;hb=d2098db6b7b0cee3b43e341c012beec5bc6ef6bd;hp=1e2ca16841661450886d719a2f701e0c8eea49be;hpb=2ae6ae8ed951e87fcba7c363705cd6ddea8de91c;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 1e2ca168..f4e690f8 100644 --- a/src/events.c +++ b/src/events.c @@ -45,6 +45,23 @@ int FilterMouseMotionEvents(const Event *event) return 1; } +/* this is only really needed for non-SDL targets to filter unwanted events; + when using SDL with properly installed event filter, this function can be + replaced with a simple "NextEvent()" call, but it doesn't hurt either */ + +static boolean NextValidEvent(Event *event) +{ + while (PendingEvent()) + { + NextEvent(event); + + if (FilterMouseMotionEvents(event)) + return TRUE; + } + + return FALSE; +} + void EventLoop(void) { while(1) @@ -53,9 +70,7 @@ void EventLoop(void) { Event event; - NextEvent(&event); - - if (FilterMouseMotionEvents(&event)) + if (NextValidEvent(&event)) { switch(event.type) {