From: Holger Schemel Date: Wed, 31 Jan 2018 18:51:19 +0000 (+0100) Subject: moved waiting for and filtering events to separate function X-Git-Tag: 4.0.1.1~6 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ff96039fa2e69d11a4fb72df8d070d4ff5477d5e;p=rocksndiamonds.git moved waiting for and filtering events to separate function --- diff --git a/src/events.c b/src/events.c index 10b866d4..10950bd9 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; }