From 13dd2ccda82909adcc7a1d91644a241b75e5077a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 1 Oct 2016 13:38:30 -0700 Subject: [PATCH] Fixed bug 3161 - SDL_WINDOWEVENT_EXPOSED event possible queue overflow Marcel Bakker Observed when resizing or moving a window in Windows 7. Depending on how you resize/move your window , you may receive none or a lot of SDL_WINDOWEVENT_EXPOSED events , at the moment you release the mouse button. Maybe add this event to an already existing list of overflow candidates ? --- src/events/SDL_windowevents.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 785ea4e0c..b45015bd0 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -70,6 +70,20 @@ RemovePendingMoveEvents(void * userdata, SDL_Event *event) return 1; } +static int +RemovePendingExposedEvents(void * userdata, SDL_Event *event) +{ + SDL_Event *new_event = (SDL_Event *)userdata; + + if (event->type == SDL_WINDOWEVENT && + event->window.event == SDL_WINDOWEVENT_EXPOSED && + event->window.windowID == new_event->window.windowID) { + /* We're about to post a new exposed event, drop the old one */ + return 0; + } + return 1; +} + int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2) @@ -195,7 +209,9 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, if (windowevent == SDL_WINDOWEVENT_MOVED) { SDL_FilterEvents(RemovePendingMoveEvents, &event); } - + if (windowevent == SDL_WINDOWEVENT_EXPOSED) { + SDL_FilterEvents(RemovePendingExposedEvents, &event); + } posted = (SDL_PushEvent(&event) > 0); }