Skip to content

Commit

Permalink
Process window events when an event filter is active
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Kontrabant committed Oct 21, 2024
1 parent 0603c7f commit a2f730d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sdl2_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand All @@ -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) {
Expand Down Expand Up @@ -1712,7 +1712,7 @@ EventFilter3to2(void *userdata, SDL_Event *event3)
default: break;
}

return true;
return post_event;
}

static void CheckEventFilter(void)
Expand Down

0 comments on commit a2f730d

Please sign in to comment.