Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_events.c @ 3685:64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 21 Jan 2010 06:21:52 +0000 |
parents | 62d4992e5a92 |
children | f7b03b6838cb |
comparison
equal
deleted
inserted
replaced
3684:cc564f08884f | 3685:64ce267332c6 |
---|---|
44 | 44 |
45 static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys); | 45 static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys); |
46 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); | 46 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); |
47 | 47 |
48 static void | 48 static void |
49 DirectFB_SetContext(_THIS, SDL_WindowID id) | 49 DirectFB_SetContext(_THIS, SDL_Window *window) |
50 { | 50 { |
51 #if (DFB_VERSION_ATLEAST(1,0,0)) | 51 #if (DFB_VERSION_ATLEAST(1,0,0)) |
52 /* FIXME: does not work on 1.0/1.2 with radeon driver | 52 /* FIXME: does not work on 1.0/1.2 with radeon driver |
53 * the approach did work with the matrox driver | 53 * the approach did work with the matrox driver |
54 * This has simply no effect. | 54 * This has simply no effect. |
55 */ | 55 */ |
56 | 56 |
57 SDL_Window *window = SDL_GetWindowFromID(id); | 57 SDL_Window *window = SDL_GetWindowFromID(id); |
58 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | 58 SDL_VideoDisplay *display = window->display; |
59 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; | 59 DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; |
60 int ret; | 60 int ret; |
61 | 61 |
62 if (dispdata->vidIDinuse) | 62 if (dispdata->vidIDinuse) |
63 SDL_DFB_CHECKERR(dispdata->vidlayer->SwitchContext(dispdata->vidlayer, | 63 SDL_DFB_CHECKERR(dispdata->vidlayer->SwitchContext(dispdata->vidlayer, |
68 #endif | 68 #endif |
69 | 69 |
70 } | 70 } |
71 | 71 |
72 static void | 72 static void |
73 FocusAllMice(_THIS, SDL_WindowID id) | 73 FocusAllMice(_THIS, SDL_Window *window) |
74 { | 74 { |
75 SDL_DFB_DEVICEDATA(_this); | 75 SDL_DFB_DEVICEDATA(_this); |
76 int index; | 76 int index; |
77 | 77 |
78 for (index = 0; index < devdata->num_mice; index++) | 78 for (index = 0; index < devdata->num_mice; index++) |
79 SDL_SetMouseFocus(devdata->mouse_id[index], id); | 79 SDL_SetMouseFocus(devdata->mouse_id[index], id); |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 static void | 83 static void |
84 FocusAllKeyboards(_THIS, SDL_WindowID id) | 84 FocusAllKeyboards(_THIS, SDL_Window *window) |
85 { | 85 { |
86 SDL_DFB_DEVICEDATA(_this); | 86 SDL_DFB_DEVICEDATA(_this); |
87 int index; | 87 int index; |
88 | 88 |
89 for (index = 0; index < devdata->num_keyboard; index++) | 89 for (index = 0; index < devdata->num_keyboard; index++) |
175 } | 175 } |
176 } | 176 } |
177 break; | 177 break; |
178 case DWET_MOTION: | 178 case DWET_MOTION: |
179 if (ClientXY(p, &evt->x, &evt->y)) { | 179 if (ClientXY(p, &evt->x, &evt->y)) { |
180 SDL_Window *window = SDL_GetWindowFromID(p->sdl_id); | 180 SDL_Window *window = p->window; |
181 if (!devdata->use_linux_input) { | 181 if (!devdata->use_linux_input) { |
182 if (!(flags & SDL_WINDOW_INPUT_GRABBED)) | 182 if (!(flags & SDL_WINDOW_INPUT_GRABBED)) |
183 SDL_SendMouseMotion(devdata->mouse_id[0], 0, | 183 SDL_SendMouseMotion(devdata->mouse_id[0], 0, |
184 evt->x, evt->y, 0); | 184 evt->x, evt->y, 0); |
185 } else { | 185 } else { |
191 MotionAllMice(_this, evt->x, evt->y); | 191 MotionAllMice(_this, evt->x, evt->y); |
192 cnt = 0; | 192 cnt = 0; |
193 } | 193 } |
194 } | 194 } |
195 if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) | 195 if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) |
196 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, | 196 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, |
197 0); | 197 0); |
198 } | 198 } |
199 break; | 199 break; |
200 case DWET_KEYDOWN: | 200 case DWET_KEYDOWN: |
201 if (!devdata->use_linux_input) { | 201 if (!devdata->use_linux_input) { |
216 SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode); | 216 SDL_SendKeyboardKey(0, SDL_RELEASED, keysym.scancode); |
217 } | 217 } |
218 break; | 218 break; |
219 case DWET_POSITION: | 219 case DWET_POSITION: |
220 if (ClientXY(p, &evt->x, &evt->y)) { | 220 if (ClientXY(p, &evt->x, &evt->y)) { |
221 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_MOVED, | 221 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, |
222 evt->x, evt->y); | 222 evt->x, evt->y); |
223 } | 223 } |
224 break; | 224 break; |
225 case DWET_POSITION_SIZE: | 225 case DWET_POSITION_SIZE: |
226 if (ClientXY(p, &evt->x, &evt->y)) { | 226 if (ClientXY(p, &evt->x, &evt->y)) { |
227 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_MOVED, | 227 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_MOVED, |
228 evt->x, evt->y); | 228 evt->x, evt->y); |
229 } | 229 } |
230 /* fall throught */ | 230 /* fall throught */ |
231 case DWET_SIZE: | 231 case DWET_SIZE: |
232 // FIXME: what about < 0 | 232 // FIXME: what about < 0 |
233 evt->w -= (p->theme.right_size + p->theme.left_size); | 233 evt->w -= (p->theme.right_size + p->theme.left_size); |
234 evt->h -= | 234 evt->h -= |
235 (p->theme.top_size + p->theme.bottom_size + | 235 (p->theme.top_size + p->theme.bottom_size + |
236 p->theme.caption_size); | 236 p->theme.caption_size); |
237 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_RESIZED, | 237 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_RESIZED, |
238 evt->w, evt->h); | 238 evt->w, evt->h); |
239 break; | 239 break; |
240 case DWET_CLOSE: | 240 case DWET_CLOSE: |
241 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, 0); | 241 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_CLOSE, 0, 0); |
242 break; | 242 break; |
243 case DWET_GOTFOCUS: | 243 case DWET_GOTFOCUS: |
244 DirectFB_SetContext(_this, p->sdl_id); | 244 DirectFB_SetContext(_this, p->window); |
245 FocusAllKeyboards(_this, p->sdl_id); | 245 FocusAllKeyboards(_this, p->window); |
246 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_FOCUS_GAINED, | 246 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_GAINED, |
247 0, 0); | 247 0, 0); |
248 break; | 248 break; |
249 case DWET_LOSTFOCUS: | 249 case DWET_LOSTFOCUS: |
250 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); | 250 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); |
251 FocusAllKeyboards(_this, 0); | 251 FocusAllKeyboards(_this, 0); |
252 break; | 252 break; |
253 case DWET_ENTER: | 253 case DWET_ENTER: |
254 /* SDL_DirectFB_ReshowCursor(_this, 0); */ | 254 /* SDL_DirectFB_ReshowCursor(_this, 0); */ |
255 FocusAllMice(_this, p->sdl_id); | 255 FocusAllMice(_this, p->window); |
256 // FIXME: when do we really enter ? | 256 // FIXME: when do we really enter ? |
257 if (ClientXY(p, &evt->x, &evt->y)) | 257 if (ClientXY(p, &evt->x, &evt->y)) |
258 MotionAllMice(_this, evt->x, evt->y); | 258 MotionAllMice(_this, evt->x, evt->y); |
259 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, 0); | 259 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_ENTER, 0, 0); |
260 break; | 260 break; |
261 case DWET_LEAVE: | 261 case DWET_LEAVE: |
262 SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_LEAVE, 0, 0); | 262 SDL_SendWindowEvent(p->window, SDL_WINDOWEVENT_LEAVE, 0, 0); |
263 FocusAllMice(_this, 0); | 263 FocusAllMice(_this, 0); |
264 /* SDL_DirectFB_ReshowCursor(_this, 1); */ | 264 /* SDL_DirectFB_ReshowCursor(_this, 1); */ |
265 break; | 265 break; |
266 default: | 266 default: |
267 ; | 267 ; |
370 DirectFB_PumpEventsWindow(_THIS) | 370 DirectFB_PumpEventsWindow(_THIS) |
371 { | 371 { |
372 SDL_DFB_DEVICEDATA(_this); | 372 SDL_DFB_DEVICEDATA(_this); |
373 DFB_WindowData *p; | 373 DFB_WindowData *p; |
374 DFBInputEvent ievt; | 374 DFBInputEvent ievt; |
375 Sint32 /* SDL_WindowID */ grabbed_window; | 375 SDL_Window *grabbed_window; |
376 | 376 |
377 grabbed_window = -1; | 377 grabbed_window = NULL; |
378 | 378 |
379 for (p = devdata->firstwin; p != NULL; p = p->next) { | 379 for (p = devdata->firstwin; p != NULL; p = p->next) { |
380 DFBWindowEvent evt; | 380 DFBWindowEvent evt; |
381 SDL_Window *w = SDL_GetWindowFromID(p->sdl_id); | 381 SDL_Window *w = SDL_GetWindowFromID(p->window); |
382 | 382 |
383 if (w->flags & SDL_WINDOW_INPUT_GRABBED) { | 383 if (w->flags & SDL_WINDOW_INPUT_GRABBED) { |
384 grabbed_window = p->sdl_id; | 384 grabbed_window = w; |
385 } | 385 } |
386 | 386 |
387 while (p->eventbuffer->GetEvent(p->eventbuffer, | 387 while (p->eventbuffer->GetEvent(p->eventbuffer, |
388 DFB_EVENT(&evt)) == DFB_OK) { | 388 DFB_EVENT(&evt)) == DFB_OK) { |
389 if (!DirectFB_WM_ProcessEvent(_this, w, &evt)) | 389 if (!DirectFB_WM_ProcessEvent(_this, w, &evt)) |