Window move events have the same problem as size events on Windows
authorSam Lantinga <slouken@libsdl.org>
Wed, 19 Jan 2011 16:02:15 -0800
changeset 5042 8c39b82dc7b0
parent 5041 3ce345cc46f8
child 5043 da347bfed240
Window move events have the same problem as size events on Windows
src/events/SDL_windowevents.c
--- a/src/events/SDL_windowevents.c	Wed Jan 19 15:28:01 2011 -0800
+++ b/src/events/SDL_windowevents.c	Wed Jan 19 16:02:15 2011 -0800
@@ -43,6 +43,20 @@
     return 1;
 }
 
+static int
+RemovePendingMoveEvents(void * userdata, SDL_Event *event)
+{
+    SDL_Event *new_event = (SDL_Event *)userdata;
+
+    if (event->type == SDL_WINDOWEVENT &&
+        event->window.event == SDL_WINDOWEVENT_MOVED &&
+        event->window.windowID == new_event->window.windowID) {
+        /* We're about to post a new move event, drop the old one */
+        return 0;
+    }
+    return 1;
+}
+
 int
 SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
                     int data2)
@@ -156,6 +170,9 @@
         if (windowevent == SDL_WINDOWEVENT_RESIZED) {
             SDL_FilterEvents(RemovePendingSizeEvents, &event);
         }
+        if (windowevent == SDL_WINDOWEVENT_MOVED) {
+            SDL_FilterEvents(RemovePendingMoveEvents, &event);
+        }
 
         posted = (SDL_PushEvent(&event) > 0);
     }