sdl2-compat: Process window and display events when an event filter is active

From 0283b2dbf8387966430d155511347cf096f49103 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Mon, 21 Oct 2024 12:28:14 -0400
Subject: [PATCH] Process window and display events when an event filter is
 active

If a client registers an event filter, window and display events would no longer be converted and delivered due to the conversion handler returning early.

Fixes a FIXME, as well as client bugs caused by non-delivery of window and display events.
---
 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)