SDL: Don't pass the sentinel event to event callbacks

From 63979f04c83eb03a0e45946031d9f19ec54f356e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 3 May 2024 09:00:41 -0700
Subject: [PATCH] Don't pass the sentinel event to event callbacks

This is just for internal use and we don't need to incur the overhead of calling callback and watchers for this event.
---
 src/events/SDL_events.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 58bdfcdce1e58..02091ac1ea082 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -1248,7 +1248,8 @@ int SDL_PushEvent(SDL_Event *event)
         event->common.timestamp = SDL_GetTicksNS();
     }
 
-    if (SDL_EventOK.callback || SDL_event_watchers_count > 0) {
+    if ((SDL_EventOK.callback || SDL_event_watchers_count > 0) &&
+        (event->common.type != SDL_EVENT_POLL_SENTINEL)) {
         SDL_LockMutex(SDL_event_watchers_lock);
         {
             if (SDL_EventOK.callback && !SDL_EventOK.callback(SDL_EventOK.userdata, event)) {