comparison 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
comparison
equal deleted inserted replaced
1721:1cc762cafff8 1722:5daa04d862f1
23 23
24 /* Window event handling code for SDL */ 24 /* Window event handling code for SDL */
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 "../video/SDL_sysvideo.h"
28 29
29 int 30 int
30 SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1, 31 SDL_PrivateWindowEvent(SDL_WindowID windowID, Uint8 windowevent, int data1,
31 int data2) 32 int data2)
32 { 33 {
33 int posted; 34 int posted;
35 SDL_Window *window;
36
37 window = SDL_GetWindowFromID(windowID);
38 if (!window) {
39 return 0;
40 }
41 switch (windowevent) {
42 case SDL_WINDOWEVENT_SHOWN:
43 if (window->flags & SDL_WINDOW_SHOWN) {
44 return 0;
45 }
46 window->flags |= SDL_WINDOW_SHOWN;
47 break;
48 case SDL_WINDOWEVENT_HIDDEN:
49 if (!(window->flags & SDL_WINDOW_SHOWN)) {
50 return 0;
51 }
52 window->flags &= ~SDL_WINDOW_SHOWN;
53 break;
54 case SDL_WINDOWEVENT_MINIMIZED:
55 if (window->flags & SDL_WINDOW_MINIMIZED) {
56 return 0;
57 }
58 window->flags |= SDL_WINDOW_MINIMIZED;
59 break;
60 case SDL_WINDOWEVENT_MAXIMIZED:
61 if (window->flags & SDL_WINDOW_MAXIMIZED) {
62 return 0;
63 }
64 window->flags |= SDL_WINDOW_MAXIMIZED;
65 break;
66 case SDL_WINDOWEVENT_RESTORED:
67 if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) {
68 return 0;
69 }
70 window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED);
71 break;
72 case SDL_WINDOWEVENT_ENTER:
73 if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
74 return 0;
75 }
76 window->flags |= SDL_WINDOW_MOUSE_FOCUS;
77 break;
78 case SDL_WINDOWEVENT_LEAVE:
79 if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
80 return 0;
81 }
82 window->flags &= ~SDL_WINDOW_MOUSE_FOCUS;
83 break;
84 case SDL_WINDOWEVENT_FOCUS_GAINED:
85 if (window->flags & SDL_WINDOW_KEYBOARD_FOCUS) {
86 return 0;
87 }
88 window->flags |= SDL_WINDOW_KEYBOARD_FOCUS;
89 break;
90 case SDL_WINDOWEVENT_FOCUS_LOST:
91 if (!(window->flags & SDL_WINDOW_KEYBOARD_FOCUS)) {
92 return 0;
93 }
94 window->flags &= ~SDL_WINDOW_KEYBOARD_FOCUS;
95 break;
96 }
34 97
35 /* Post the event, if desired */ 98 /* Post the event, if desired */
36 posted = 0; 99 posted = 0;
37 if (SDL_ProcessEvents[SDL_WINDOWEVENT] == SDL_ENABLE) { 100 if (SDL_ProcessEvents[SDL_WINDOWEVENT] == SDL_ENABLE) {
38 SDL_Event event; 101 SDL_Event event;
39 event.type = SDL_WINDOWEVENT; 102 event.type = SDL_WINDOWEVENT;
40 event.window.event = windowevent; 103 event.window.event = windowevent;
41 event.window.data1 = data1; 104 event.window.data1 = data1;
42 event.window.data2 = data2; 105 event.window.data2 = data2;
43 event.window.windowID = windowID; 106 event.window.windowID = windowID;
44 if ((SDL_EventOK == NULL) || (*SDL_EventOK) (&event)) { 107 if ((SDL_EventOK == NULL)
108 || (*SDL_EventOK) (SDL_EventOKParam, &event)) {
45 posted = 1; 109 posted = 1;
46 SDL_PushEvent(&event); 110 SDL_PushEvent(&event);
47 } 111 }
48 } 112 }
49 return (posted); 113 return (posted);