From a2f730d2dddc42f877c869434556cb0f66fb8c82 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Mon, 21 Oct 2024 12:28:14 -0400 Subject: [PATCH] Process window events when an event filter is active If a client registers an event filter, it would stop receiving all window events due to the filter handler function causing an early exit. Fixes a FIXME. --- src/sdl2_compat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c index fec7f25..4e601af 100644 --- a/src/sdl2_compat.c +++ b/src/sdl2_compat.c @@ -1610,6 +1610,7 @@ static bool SDLCALL EventFilter3to2(void *userdata, SDL_Event *event3) { SDL2_Event event2; /* note that event filters do not receive events as const! So we have to convert or copy it for each one! */ + bool post_event = true; GestureProcessEvent(event3); /* this might need to generate new gesture events from touch input. */ @@ -1625,11 +1626,10 @@ EventFilter3to2(void *userdata, SDL_Event *event3) } if (EventFilter2) { - /* !!! FIXME: this needs to not return if the filter gives its blessing, as we still have more to do. */ - return EventFilter2(EventFilterUserData2, Event3to2(event3, &event2)); + post_event = !!EventFilter2(EventFilterUserData2, Event3to2(event3, &event2)); } - if (EventWatchers2 != NULL) { + if (post_event && EventWatchers2 != NULL) { EventFilterWrapperData *i; SDL3_LockMutex(EventWatchListMutex); for (i = EventWatchers2; i != NULL; i = i->next) { @@ -1712,7 +1712,7 @@ EventFilter3to2(void *userdata, SDL_Event *event3) default: break; } - return true; + return post_event; } static void CheckEventFilter(void)