X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=2998066b98230577aae3198ddbc0b861877646bc;hb=c7bda2237780e82311e5ede18042f3619b257f8a;hp=10b866d433f5d72a8cbde3275db3516317af5a0e;hpb=88a1829af8ca41b6e581f209002022b2483b86df;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 10b866d4..2998066b 100644 --- a/src/events.c +++ b/src/events.c @@ -128,6 +128,19 @@ static boolean SkipPressedMouseMotionEvent(const Event *event) return FALSE; } +static boolean WaitEventFiltered(Event *event) +{ + WaitEvent(event); + + if (!FilterEvents(event)) + return FALSE; + + if (SkipPressedMouseMotionEvent(event)) + return FALSE; + + return TRUE; +} + /* this is especially needed for event modifications for the Android target: if mouse coordinates should be modified in the event filter function, using a properly installed SDL event filter does not work, because in @@ -139,20 +152,8 @@ static boolean SkipPressedMouseMotionEvent(const Event *event) boolean NextValidEvent(Event *event) { while (PendingEvent()) - { - boolean handle_this_event = FALSE; - - WaitEvent(event); - - if (FilterEvents(event)) - handle_this_event = TRUE; - - if (SkipPressedMouseMotionEvent(event)) - handle_this_event = FALSE; - - if (handle_this_event) + if (WaitEventFiltered(event)) return TRUE; - } return FALSE; } @@ -340,12 +341,10 @@ void EventLoop(void) void ClearEventQueue() { - while (PendingEvent()) - { - Event event; - - WaitEvent(&event); + Event event; + while (NextValidEvent(&event)) + { switch (event.type) { case EVENT_BUTTONRELEASE: @@ -392,7 +391,8 @@ void SleepWhileUnmapped() { Event event; - WaitEvent(&event); + if (!WaitEventFiltered(&event)) + continue; switch (event.type) {