src/events/SDL_windowevents.c
changeset 6512 4beb596ccfae
parent 6138 4c64952a58fb
child 6885 700f1b25f77f
equal deleted inserted replaced
6511:41253d43a2cf 6512:4beb596ccfae
    27 #include "SDL_mouse_c.h"
    27 #include "SDL_mouse_c.h"
    28 #include "../video/SDL_sysvideo.h"
    28 #include "../video/SDL_sysvideo.h"
    29 
    29 
    30 
    30 
    31 static int
    31 static int
    32 RemovePendingSizeEvents(void * userdata, SDL_Event *event)
    32 RemovePendingResizedEvents(void * userdata, SDL_Event *event)
    33 {
    33 {
    34     SDL_Event *new_event = (SDL_Event *)userdata;
    34     SDL_Event *new_event = (SDL_Event *)userdata;
    35 
    35 
    36     if (event->type == SDL_WINDOWEVENT &&
    36     if (event->type == SDL_WINDOWEVENT &&
    37         (event->window.event == SDL_WINDOWEVENT_RESIZED ||
    37         event->window.event == SDL_WINDOWEVENT_RESIZED &&
    38          event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) &&
    38         event->window.windowID == new_event->window.windowID) {
       
    39         /* We're about to post a new size event, drop the old one */
       
    40         return 0;
       
    41     }
       
    42     return 1;
       
    43 }
       
    44 
       
    45 static int
       
    46 RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event)
       
    47 {
       
    48     SDL_Event *new_event = (SDL_Event *)userdata;
       
    49 
       
    50     if (event->type == SDL_WINDOWEVENT &&
       
    51         event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED &&
    39         event->window.windowID == new_event->window.windowID) {
    52         event->window.windowID == new_event->window.windowID) {
    40         /* We're about to post a new size event, drop the old one */
    53         /* We're about to post a new size event, drop the old one */
    41         return 0;
    54         return 0;
    42     }
    55     }
    43     return 1;
    56     return 1;
   167         event.window.data1 = data1;
   180         event.window.data1 = data1;
   168         event.window.data2 = data2;
   181         event.window.data2 = data2;
   169         event.window.windowID = window->id;
   182         event.window.windowID = window->id;
   170 
   183 
   171         /* Fixes queue overflow with resize events that aren't processed */
   184         /* Fixes queue overflow with resize events that aren't processed */
   172         if (windowevent == SDL_WINDOWEVENT_RESIZED ||
   185         if (windowevent == SDL_WINDOWEVENT_RESIZED) {
   173             windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
   186             SDL_FilterEvents(RemovePendingResizedEvents, &event);
   174             SDL_FilterEvents(RemovePendingSizeEvents, &event);
   187         }
       
   188         if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) {
       
   189             SDL_FilterEvents(RemovePendingSizeChangedEvents, &event);
   175         }
   190         }
   176         if (windowevent == SDL_WINDOWEVENT_MOVED) {
   191         if (windowevent == SDL_WINDOWEVENT_MOVED) {
   177             SDL_FilterEvents(RemovePendingMoveEvents, &event);
   192             SDL_FilterEvents(RemovePendingMoveEvents, &event);
   178         }
   193         }
   179 
   194