src/events/SDL_windowevents.c
branchSDL-1.3
changeset 1722 5daa04d862f1
parent 1668 4da1ee79c9af
child 1724 6c63fc2bd986
     1.1 --- a/src/events/SDL_windowevents.c	Fri Jun 30 05:50:35 2006 +0000
     1.2 +++ b/src/events/SDL_windowevents.c	Fri Jun 30 08:18:44 2006 +0000
     1.3 @@ -25,12 +25,75 @@
     1.4  
     1.5  #include "SDL_events.h"
     1.6  #include "SDL_events_c.h"
     1.7 +#include "../video/SDL_sysvideo.h"
     1.8  
     1.9  int
    1.10  SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
    1.11                         int data2)
    1.12  {
    1.13      int posted;
    1.14 +    SDL_Window *window;
    1.15 +
    1.16 +    window = SDL_GetWindowFromID(windowID);
    1.17 +    if (!window) {
    1.18 +        return 0;
    1.19 +    }
    1.20 +    switch (windowevent) {
    1.21 +    case SDL_WINDOWEVENT_SHOWN:
    1.22 +        if (window->flags & SDL_WINDOW_SHOWN) {
    1.23 +            return 0;
    1.24 +        }
    1.25 +        window->flags |= SDL_WINDOW_SHOWN;
    1.26 +        break;
    1.27 +    case SDL_WINDOWEVENT_HIDDEN:
    1.28 +        if (!(window->flags & SDL_WINDOW_SHOWN)) {
    1.29 +            return 0;
    1.30 +        }
    1.31 +        window->flags &= ~SDL_WINDOW_SHOWN;
    1.32 +        break;
    1.33 +    case SDL_WINDOWEVENT_MINIMIZED:
    1.34 +        if (window->flags & SDL_WINDOW_MINIMIZED) {
    1.35 +            return 0;
    1.36 +        }
    1.37 +        window->flags |= SDL_WINDOW_MINIMIZED;
    1.38 +        break;
    1.39 +    case SDL_WINDOWEVENT_MAXIMIZED:
    1.40 +        if (window->flags & SDL_WINDOW_MAXIMIZED) {
    1.41 +            return 0;
    1.42 +        }
    1.43 +        window->flags |= SDL_WINDOW_MAXIMIZED;
    1.44 +        break;
    1.45 +    case SDL_WINDOWEVENT_RESTORED:
    1.46 +        if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
    1.47 +            return 0;
    1.48 +        }
    1.49 +        window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED);
    1.50 +        break;
    1.51 +    case SDL_WINDOWEVENT_ENTER:
    1.52 +        if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
    1.53 +            return 0;
    1.54 +        }
    1.55 +        window->flags |= SDL_WINDOW_MOUSE_FOCUS;
    1.56 +        break;
    1.57 +    case SDL_WINDOWEVENT_LEAVE:
    1.58 +        if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
    1.59 +            return 0;
    1.60 +        }
    1.61 +        window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
    1.62 +        break;
    1.63 +    case SDL_WINDOWEVENT_FOCUS_GAINED:
    1.64 +        if (window->flags & SDL_WINDOW_KEYBOARD_FOCUS) {
    1.65 +            return 0;
    1.66 +        }
    1.67 +        window->flags |= SDL_WINDOW_KEYBOARD_FOCUS;
    1.68 +        break;
    1.69 +    case SDL_WINDOWEVENT_FOCUS_LOST:
    1.70 +        if (!(window->flags & SDL_WINDOW_KEYBOARD_FOCUS)) {
    1.71 +            return 0;
    1.72 +        }
    1.73 +        window->flags &= ~SDL_WINDOW_KEYBOARD_FOCUS;
    1.74 +        break;
    1.75 +    }
    1.76  
    1.77      /* Post the event, if desired */
    1.78      posted = 0;
    1.79 @@ -41,7 +104,8 @@
    1.80          event.window.data1 = data1;
    1.81          event.window.data2 = data2;
    1.82          event.window.windowID = windowID;
    1.83 -        if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) {
    1.84 +        if ((SDL_EventOK == NULL)
    1.85 +            || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
    1.86              posted = 1;
    1.87              SDL_PushEvent(&event);
    1.88          }