Filter both SIZE_CHANGED and RESIZED on any SIZE_CHANGED

This commit is contained in:
Ethan Lee 2018-08-13 12:52:52 -04:00
parent 95579f5f19
commit de9f5415b3
1 changed files with 4 additions and 20 deletions

View File

@ -28,26 +28,13 @@
static int SDLCALL static int SDLCALL
RemovePendingResizedEvents(void * userdata, SDL_Event *event) RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event)
{ {
SDL_Event *new_event = (SDL_Event *)userdata; SDL_Event *new_event = (SDL_Event *)userdata;
if (event->type == SDL_WINDOWEVENT && if (event->type == SDL_WINDOWEVENT &&
event->window.event == SDL_WINDOWEVENT_RESIZED && (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED ||
event->window.windowID == new_event->window.windowID) { event->window.event == SDL_WINDOWEVENT_RESIZED) &&
/* We're about to post a new size event, drop the old one */
return 0;
}
return 1;
}
static int SDLCALL
RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event)
{
SDL_Event *new_event = (SDL_Event *)userdata;
if (event->type == SDL_WINDOWEVENT &&
event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
event->window.windowID == new_event->window.windowID) { event->window.windowID == new_event->window.windowID) {
/* We're about to post a new size event, drop the old one */ /* We're about to post a new size event, drop the old one */
return 0; return 0;
@ -199,11 +186,8 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
event.window.windowID = window->id; event.window.windowID = window->id;
/* Fixes queue overflow with resize events that aren't processed */ /* Fixes queue overflow with resize events that aren't processed */
if (windowevent == SDL_WINDOWEVENT_RESIZED) {
SDL_FilterEvents(RemovePendingResizedEvents, &event);
}
if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) { if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
SDL_FilterEvents(RemovePendingSizeChangedEvents, &event); SDL_FilterEvents(RemovePendingSizeChangedAndResizedEvents, &event);
} }
if (windowevent == SDL_WINDOWEVENT_MOVED) { if (windowevent == SDL_WINDOWEVENT_MOVED) {
SDL_FilterEvents(RemovePendingMoveEvents, &event); SDL_FilterEvents(RemovePendingMoveEvents, &event);