Skip to content

Commit

Permalink
Fixed bug 3161 - SDL_WINDOWEVENT_EXPOSED event possible queue overflow
Browse files Browse the repository at this point in the history
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 ?
  • Loading branch information
slouken committed Oct 1, 2016
1 parent 614cb35 commit 13dd2cc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/events/SDL_windowevents.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 13dd2cc

Please sign in to comment.