Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #666
Browse files Browse the repository at this point in the history
Don't let the event queue overflow with resize events
  • Loading branch information
slouken committed Dec 16, 2009
1 parent 2e21c8a commit 689c38e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/events/SDL_windowevents.c
Expand Up @@ -28,6 +28,21 @@
#include "SDL_mouse_c.h"
#include "../video/SDL_sysvideo.h"


static int
RemovePendingSizeEvents(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.windowID == new_event->window.windowID) {
/* We're about to post a new size event, drop the old one */
return 0;
}
return 1;
}

int
SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
int data2)
Expand Down Expand Up @@ -138,6 +153,12 @@ SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
event.window.data1 = data1;
event.window.data2 = data2;
event.window.windowID = windowID;

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

posted = (SDL_PushEvent(&event) > 0);
}
return (posted);
Expand Down

0 comments on commit 689c38e

Please sign in to comment.