WINDOW_RESIZED events shouldn't flush WINDOW_SIZE_CHANGED events and vice versa.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Sep 2012 01:10:53 -0700
changeset 6512 4beb596ccfae
parent 6511 41253d43a2cf
child 6513 c781fb99ce39
WINDOW_RESIZED events shouldn't flush WINDOW_SIZE_CHANGED events and vice versa.
src/events/SDL_windowevents.c
--- a/src/events/SDL_windowevents.c	Sat Sep 29 00:17:34 2012 -0700
+++ b/src/events/SDL_windowevents.c	Sat Sep 29 01:10:53 2012 -0700
@@ -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 @@
         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);