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

Fixed bug #666

Don't let the event queue overflow with resize events
  • Loading branch information
slouken committed Dec 16, 2009
1 parent 2e21c8a commit 689c38e1bd84813267e3063e0b612898938631a3
Showing with 21 additions and 0 deletions.
  1. +21 −0 src/events/SDL_windowevents.c
@@ -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)
@@ -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);

0 comments on commit 689c38e

Please sign in to comment.