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); }