Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

WINDOW_RESIZED events shouldn't flush WINDOW_SIZE_CHANGED events and …

…vice versa.
  • Loading branch information
slouken committed Sep 29, 2012
1 parent 7f2fe06 commit 0ef51349a453afd7be856beff8c70d088babc9ef
Showing with 21 additions and 6 deletions.
  1. +21 −6 src/events/SDL_windowevents.c
@@ -29,13 +29,26 @@


static int
RemovePendingSizeEvents(void * userdata, SDL_Event *event)
RemovePendingResizedEvents(void * userdata, SDL_Event *event)
{
SDL_Event *new_event = (SDL_Event *)userdata;

if (event->type == SDL_WINDOWEVENT &&
(event->window.event == SDL_WINDOWEVENT_RESIZED ||
event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) &&
event->window.event == SDL_WINDOWEVENT_RESIZED &&
event->window.windowID == new_event->window.windowID) {
/* We're about to post a new size event, drop the old one */
return 0;
}
return 1;
}

static int
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) {
/* We're about to post a new size event, drop the old one */
return 0;
@@ -169,9 +182,11 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
event.window.windowID = window->id;

/* Fixes queue overflow with resize events that aren't processed */
if (windowevent == SDL_WINDOWEVENT_RESIZED ||
windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
SDL_FilterEvents(RemovePendingSizeEvents, &event);
if (windowevent == SDL_WINDOWEVENT_RESIZED) {
SDL_FilterEvents(RemovePendingResizedEvents, &event);
}
if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
SDL_FilterEvents(RemovePendingSizeChangedEvents, &event);
}
if (windowevent == SDL_WINDOWEVENT_MOVED) {
SDL_FilterEvents(RemovePendingMoveEvents, &event);

0 comments on commit 0ef5134

Please sign in to comment.