src/events/SDL_windowevents.c
changeset 3573 41cd18e05965
parent 3502 98a819296cdc
child 3685 64ce267332c6
equal deleted inserted replaced
3572:6bb9952d5029 3573:41cd18e05965
    25 
    25 
    26 #include "SDL_events.h"
    26 #include "SDL_events.h"
    27 #include "SDL_events_c.h"
    27 #include "SDL_events_c.h"
    28 #include "SDL_mouse_c.h"
    28 #include "SDL_mouse_c.h"
    29 #include "../video/SDL_sysvideo.h"
    29 #include "../video/SDL_sysvideo.h"
       
    30 
       
    31 
       
    32 static int
       
    33 RemovePendingSizeEvents(void * userdata, SDL_Event *event)
       
    34 {
       
    35     SDL_Event *new_event = (SDL_Event *)userdata;
       
    36 
       
    37     if (event->type == SDL_WINDOWEVENT &&
       
    38         event->window.event == SDL_WINDOWEVENT_RESIZED &&
       
    39         event->window.windowID == new_event->window.windowID) {
       
    40         /* We're about to post a new size event, drop the old one */
       
    41         return 0;
       
    42     }
       
    43     return 1;
       
    44 }
    30 
    45 
    31 int
    46 int
    32 SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
    47 SDL_SendWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
    33                     int data2)
    48                     int data2)
    34 {
    49 {
   136         event.type = SDL_WINDOWEVENT;
   151         event.type = SDL_WINDOWEVENT;
   137         event.window.event = windowevent;
   152         event.window.event = windowevent;
   138         event.window.data1 = data1;
   153         event.window.data1 = data1;
   139         event.window.data2 = data2;
   154         event.window.data2 = data2;
   140         event.window.windowID = windowID;
   155         event.window.windowID = windowID;
       
   156 
       
   157         /* Fixes queue overflow with resize events that aren't processed */
       
   158         if (windowevent == SDL_WINDOWEVENT_RESIZED) {
       
   159             SDL_FilterEvents(RemovePendingSizeEvents, &event);
       
   160         }
       
   161 
   141         posted = (SDL_PushEvent(&event) > 0);
   162         posted = (SDL_PushEvent(&event) > 0);
   142     }
   163     }
   143     return (posted);
   164     return (posted);
   144 }
   165 }
   145 
   166