Mercurial > sdl-ios-xcode
diff src/events/SDL_windowevents.c @ 1722:5daa04d862f1 SDL-1.3
Added a userdata parameter for event filters.
Added a function to filter the existing queued events.
Added explicit support for relative mouse mode to the API.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 30 Jun 2006 08:18:44 +0000 |
parents | 4da1ee79c9af |
children | 6c63fc2bd986 |
line wrap: on
line diff
--- a/src/events/SDL_windowevents.c Fri Jun 30 05:50:35 2006 +0000 +++ b/src/events/SDL_windowevents.c Fri Jun 30 08:18:44 2006 +0000 @@ -25,12 +25,75 @@ #include "SDL_events.h" #include "SDL_events_c.h" +#include "../video/SDL_sysvideo.h" int SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1, int data2) { int posted; + SDL_Window *window; + + window = SDL_GetWindowFromID(windowID); + if (!window) { + return 0; + } + switch (windowevent) { + case SDL_WINDOWEVENT_SHOWN: + if (window->flags & SDL_WINDOW_SHOWN) { + return 0; + } + window->flags |= SDL_WINDOW_SHOWN; + break; + case SDL_WINDOWEVENT_HIDDEN: + if (!(window->flags & SDL_WINDOW_SHOWN)) { + return 0; + } + window->flags &= ~SDL_WINDOW_SHOWN; + break; + case SDL_WINDOWEVENT_MINIMIZED: + if (window->flags & SDL_WINDOW_MINIMIZED) { + return 0; + } + window->flags |= SDL_WINDOW_MINIMIZED; + break; + case SDL_WINDOWEVENT_MAXIMIZED: + if (window->flags & SDL_WINDOW_MAXIMIZED) { + return 0; + } + window->flags |= SDL_WINDOW_MAXIMIZED; + break; + case SDL_WINDOWEVENT_RESTORED: + if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { + return 0; + } + window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED); + break; + case SDL_WINDOWEVENT_ENTER: + if (window->flags & SDL_WINDOW_MOUSE_FOCUS) { + return 0; + } + window->flags |= SDL_WINDOW_MOUSE_FOCUS; + break; + case SDL_WINDOWEVENT_LEAVE: + if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) { + return 0; + } + window->flags &= ~SDL_WINDOW_MOUSE_FOCUS; + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + if (window->flags & SDL_WINDOW_KEYBOARD_FOCUS) { + return 0; + } + window->flags |= SDL_WINDOW_KEYBOARD_FOCUS; + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + if (!(window->flags & SDL_WINDOW_KEYBOARD_FOCUS)) { + return 0; + } + window->flags &= ~SDL_WINDOW_KEYBOARD_FOCUS; + break; + } /* Post the event, if desired */ posted = 0; @@ -41,7 +104,8 @@ event.window.data1 = data1; event.window.data2 = data2; event.window.windowID = windowID; - if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { posted = 1; SDL_PushEvent(&event); }