comparison src/video/directfb/SDL_DirectFB_window.c @ 5202:164f20ba08eb

Updated the DirectFB support, from Couriersud attached is a working directfb driver diff which works with the current changes. There are a number of changes around it as well, e.g. configure.in. The directfb renderdriver right now still depends on a some "includes" from src/video/directfb. That's why it is not yet moved to the new render folder.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Feb 2011 16:07:10 -0800
parents b196d2758026
children 58265e606e4e
comparison
equal deleted inserted replaced
5201:7c3422025c35 5202:164f20ba08eb
16 License along with this library; if not, write to the Free Software 16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21
22 SDL1.3 DirectFB driver by couriersud@arcor.de
23
21 */ 24 */
22 #include "SDL_config.h"
23
24 #include "SDL_syswm.h"
25 #include "../SDL_sysvideo.h"
26 #include "../../events/SDL_keyboard_c.h"
27 #include "../../video/SDL_pixels_c.h"
28 25
29 #include "SDL_DirectFB_video.h" 26 #include "SDL_DirectFB_video.h"
27 #include "SDL_DirectFB_modes.h"
28 #include "SDL_DirectFB_window.h"
29 #include "SDL_DirectFB_shape.h"
30
30 #if SDL_DIRECTFB_OPENGL 31 #if SDL_DIRECTFB_OPENGL
31 #include "SDL_DirectFB_opengl.h" 32 #include "SDL_DirectFB_opengl.h"
32 #endif 33 #endif
33 34
34 static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window); 35 #include "SDL_syswm.h"
36
37 #include "../SDL_pixels_c.h"
35 38
36 int 39 int
37 DirectFB_CreateWindow(_THIS, SDL_Window * window) 40 DirectFB_CreateWindow(_THIS, SDL_Window * window)
38 { 41 {
39 SDL_DFB_DEVICEDATA(_this); 42 SDL_DFB_DEVICEDATA(_this);
40 SDL_DFB_DISPLAYDATA(_this, window); 43 SDL_DFB_DISPLAYDATA(window);
41 DFB_WindowData *windata = NULL; 44 DFB_WindowData *windata = NULL;
42 DFBWindowOptions wopts; 45 DFBWindowOptions wopts;
43 DFBWindowDescription desc; 46 DFBWindowDescription desc;
44 int x, y; 47 int x, y;
45 48 int bshaped = 0;
46 SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData)); 49
50 SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
47 windata = (DFB_WindowData *) window->driverdata; 51 windata = (DFB_WindowData *) window->driverdata;
48 52
49 windata->is_managed = devdata->has_own_wm; 53 windata->is_managed = devdata->has_own_wm;
50 54 #if 1
51 SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb, 55 SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb,
52 DFSCL_NORMAL)); 56 DFSCL_NORMAL));
53 SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, 57 SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer,
54 DLSCL_ADMINISTRATIVE)); 58 DLSCL_ADMINISTRATIVE));
55 59 #endif
60 /* FIXME ... ughh, ugly */
61 if (window->x == -1000 && window->y == -1000)
62 bshaped = 1;
63
56 /* Fill the window description. */ 64 /* Fill the window description. */
57 if (window->x == SDL_WINDOWPOS_CENTERED) { 65 if (window->x == SDL_WINDOWPOS_CENTERED) {
58 x = (dispdata->cw - window->w) / 2; 66 x = (dispdata->cw - window->w) / 2;
59 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { 67 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
60 x = 0; 68 x = 0;
61 } else { 69 } else {
62 x = window->x; 70 x = window->x;
63 } 71 }
72
64 if (window->y == SDL_WINDOWPOS_CENTERED) { 73 if (window->y == SDL_WINDOWPOS_CENTERED) {
65 y = (dispdata->ch - window->h) / 2; 74 y = (dispdata->ch - window->h) / 2;
66 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { 75 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
67 y = 0; 76 y = 0;
68 } else { 77 } else {
69 y = window->y; 78 y = window->y;
70 } 79 }
80
71 if (window->flags & SDL_WINDOW_FULLSCREEN) { 81 if (window->flags & SDL_WINDOW_FULLSCREEN) {
72 x = 0; 82 x = 0;
73 y = 0; 83 y = 0;
74 } 84 }
75 85
76 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); 86 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
77 87
78 /* Create Window */ 88 /* Create Window */
89 desc.caps = 0;
79 desc.flags = 90 desc.flags =
80 DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_POSX 91 DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS;
81 | DWDESC_POSY | DWDESC_SURFACE_CAPS; 92
93 if (bshaped) {
94 desc.flags |= DWDESC_CAPS;
95 desc.caps |= DWCAPS_ALPHACHANNEL;
96 }
97 else
98 {
99 desc.flags |= DWDESC_PIXELFORMAT;
100 }
101
102 if (!(window->flags & SDL_WINDOW_BORDERLESS))
103 desc.caps |= DWCAPS_NODECORATION;
104
82 desc.posx = x; 105 desc.posx = x;
83 desc.posy = y; 106 desc.posy = y;
84 desc.width = windata->size.w; 107 desc.width = windata->size.w;
85 desc.height = windata->size.h; 108 desc.height = windata->size.h;
86 desc.pixelformat = dispdata->pixelformat; 109 desc.pixelformat = dispdata->pixelformat;
87 desc.surface_caps = DSCAPS_PREMULTIPLIED; 110 desc.surface_caps = DSCAPS_PREMULTIPLIED;
88 111
89 /* Create the window. */ 112 /* Create the window. */
90 SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc, 113 SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
91 &windata->window)); 114 &windata->dfbwin));
92 115
93 /* Set Options */ 116 /* Set Options */
94 SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts)); 117 SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
95 118
96 if (window->flags & SDL_WINDOW_RESIZABLE) 119 /* explicit rescaling of surface */
97 wopts |= DWOP_SCALE; 120 wopts |= DWOP_SCALE;
98 else 121 if (window->flags & SDL_WINDOW_RESIZABLE) {
122 wopts &= ~DWOP_KEEP_SIZE;
123 }
124 else {
99 wopts |= DWOP_KEEP_SIZE; 125 wopts |= DWOP_KEEP_SIZE;
126 }
100 127
101 if (window->flags & SDL_WINDOW_FULLSCREEN) { 128 if (window->flags & SDL_WINDOW_FULLSCREEN) {
102 wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE; 129 wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE;
103 SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER)); 130 SDL_DFB_CHECK(windata->dfbwin->SetStackingClass(windata->dfbwin, DWSC_UPPER));
104 } 131 }
105 SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts)); 132
133 if (bshaped) {
134 wopts |= DWOP_SHAPED | DWOP_ALPHACHANNEL;
135 wopts &= ~DWOP_OPAQUE_REGION;
136 }
137
138 SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
106 139
107 /* See what we got */ 140 /* See what we got */
108 SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize 141 SDL_DFB_CHECK(DirectFB_WM_GetClientSize
109 (_this, window, &window->w, &window->h)); 142 (_this, window, &window->w, &window->h));
110 143
111 /* Get the window's surface. */ 144 /* Get the window's surface. */
112 SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window, 145 SDL_DFB_CHECKERR(windata->dfbwin->GetSurface(windata->dfbwin,
113 &windata->window_surface)); 146 &windata->window_surface));
147
114 /* And get a subsurface for rendering */ 148 /* And get a subsurface for rendering */
115 SDL_DFB_CHECKERR(windata->window_surface-> 149 SDL_DFB_CHECKERR(windata->window_surface->
116 GetSubSurface(windata->window_surface, &windata->client, 150 GetSubSurface(windata->window_surface, &windata->client,
117 &windata->surface)); 151 &windata->surface));
118 152
119 SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF)); 153 SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0xFF));
120 154
121 /* Create Eventbuffer */ 155 /* Create Eventbuffer */
122 SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window, 156
157 SDL_DFB_CHECKERR(windata->dfbwin->CreateEventBuffer(windata->dfbwin,
123 &windata-> 158 &windata->
124 eventbuffer)); 159 eventbuffer));
125 SDL_DFB_CHECKERR(windata->window-> 160 SDL_DFB_CHECKERR(windata->dfbwin->
126 EnableEvents(windata->window, DWET_ALL)); 161 EnableEvents(windata->dfbwin, DWET_ALL));
127 162
128 /* Create a font */ 163 /* Create a font */
129 /* FIXME: once during Video_Init */ 164 /* FIXME: once during Video_Init */
130 windata->font = NULL; 165 windata->font = NULL;
131 166
132 /* Make it the top most window. */ 167 /* Make it the top most window. */
133 SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window)); 168 SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
134 169
135 /* remember parent */ 170 /* remember parent */
136 windata->sdl_window = window; 171 //windata->sdlwin = window;
137 172
138 /* Add to list ... */ 173 /* Add to list ... */
139 174
140 windata->next = devdata->firstwin; 175 windata->next = devdata->firstwin;
141 windata->opacity = 0xFF; 176 windata->opacity = 0xFF;
142 devdata->firstwin = windata; 177 devdata->firstwin = window;
143 178
144 /* Draw Frame */ 179 /* Draw Frame */
145 DirectFB_WM_RedrawLayout(_this, window); 180 DirectFB_WM_RedrawLayout(_this, window);
146 181
147 return 0; 182 return 0;
148 error: 183 error:
149 SDL_DFB_RELEASE(windata->window); 184 SDL_DFB_RELEASE(windata->surface);
150 SDL_DFB_RELEASE(windata->surface); 185 SDL_DFB_RELEASE(windata->dfbwin);
151 return -1; 186 return -1;
152 } 187 }
153 188
154 int 189 int
155 DirectFB_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) 190 DirectFB_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
224 259
225 void 260 void
226 DirectFB_SetWindowPosition(_THIS, SDL_Window * window) 261 DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
227 { 262 {
228 SDL_DFB_WINDOWDATA(window); 263 SDL_DFB_WINDOWDATA(window);
264 SDL_DFB_DISPLAYDATA(window);
229 int x, y; 265 int x, y;
230 266
231 if (window->y == SDL_WINDOWPOS_UNDEFINED) 267 if (window->x == SDL_WINDOWPOS_CENTERED) {
268 x = (dispdata->cw - window->w) / 2;
269 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
270 x = 0;
271 } else {
272 x = window->x;
273 }
274
275 if (window->y == SDL_WINDOWPOS_CENTERED) {
276 y = (dispdata->ch - window->h) / 2;
277 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
232 y = 0; 278 y = 0;
233 else 279 } else {
234 y = window->y; 280 y = window->y;
235 281 }
236 if (window->x == SDL_WINDOWPOS_UNDEFINED)
237 x = 0;
238 else
239 x = window->x;
240 282
241 if (window->flags & SDL_WINDOW_FULLSCREEN) { 283 if (window->flags & SDL_WINDOW_FULLSCREEN) {
242 x = 0; 284 x = 0;
243 y = 0; 285 y = 0;
244 } 286 }
245 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); 287 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
246 SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y)); 288 SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, x, y));
247 } 289 }
248 290
249 void 291 void
250 DirectFB_SetWindowSize(_THIS, SDL_Window * window) 292 DirectFB_SetWindowSize(_THIS, SDL_Window * window)
251 { 293 {
252 //SDL_DFB_DEVICEDATA(_this); 294 SDL_DFB_WINDOWDATA(window);
253 SDL_DFB_WINDOWDATA(window); 295
296 if(SDL_IsShapedWindow(window))
297 DirectFB_ResizeWindowShape(window);
254 298
255 if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { 299 if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
256 int cw; 300 int cw;
257 int ch; 301 int ch;
258 302
259 /* Make sure all events are disabled for this operation ! */ 303 /* Make sure all events are disabled for this operation ! */
260 SDL_DFB_CHECKERR(windata->window->DisableEvents(windata->window, 304 SDL_DFB_CHECKERR(windata->dfbwin->DisableEvents(windata->dfbwin,
261 DWET_ALL)); 305 DWET_ALL));
262
263 SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch)); 306 SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch));
264 307
265 if (cw != window->w || ch != window->h) { 308 if (cw != window->w || ch != window->h) {
266 309
267 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); 310 DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h);
268 SDL_DFB_CHECKERR(windata->window->Resize(windata->window, 311 SDL_DFB_CHECKERR(windata->dfbwin->Resize(windata->dfbwin,
269 windata->size.w, 312 windata->size.w,
270 windata->size.h)); 313 windata->size.h));
271 } 314 }
272 315
273 SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize 316 SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
274 (_this, window, &window->w, &window->h)); 317 (_this, window, &window->w, &window->h));
275 DirectFB_AdjustWindowSurface(_this, window); 318 DirectFB_AdjustWindowSurface(window);
276 319
277 SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window, 320 SDL_DFB_CHECKERR(windata->dfbwin->EnableEvents(windata->dfbwin,
278 DWET_ALL)); 321 DWET_ALL));
279 322
280 } 323 }
281 return; 324 return;
282 error: 325 error:
283 SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL)); 326 SDL_DFB_CHECK(windata->dfbwin->EnableEvents(windata->dfbwin, DWET_ALL));
284 return; 327 return;
285 } 328 }
286 329
287 void 330 void
288 DirectFB_ShowWindow(_THIS, SDL_Window * window) 331 DirectFB_ShowWindow(_THIS, SDL_Window * window)
289 { 332 {
290 SDL_DFB_WINDOWDATA(window); 333 SDL_DFB_WINDOWDATA(window);
291 334
292 SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity)); 335 SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, windata->opacity));
293 336
294 } 337 }
295 338
296 void 339 void
297 DirectFB_HideWindow(_THIS, SDL_Window * window) 340 DirectFB_HideWindow(_THIS, SDL_Window * window)
298 { 341 {
299 SDL_DFB_WINDOWDATA(window); 342 SDL_DFB_WINDOWDATA(window);
300 343
301 SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity)); 344 SDL_DFB_CHECK(windata->dfbwin->GetOpacity(windata->dfbwin, &windata->opacity));
302 SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0)); 345 SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0));
303 } 346 }
304 347
305 void 348 void
306 DirectFB_RaiseWindow(_THIS, SDL_Window * window) 349 DirectFB_RaiseWindow(_THIS, SDL_Window * window)
307 { 350 {
308 SDL_DFB_WINDOWDATA(window); 351 SDL_DFB_WINDOWDATA(window);
309 352
310 SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window)); 353 SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin));
311 SDL_DFB_CHECK(windata->window->RequestFocus(windata->window)); 354 SDL_DFB_CHECK(windata->dfbwin->RequestFocus(windata->dfbwin));
312 } 355 }
313 356
314 void 357 void
315 DirectFB_MaximizeWindow(_THIS, SDL_Window * window) 358 DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
316 { 359 {
317 SDL_DFB_WINDOWDATA(window); 360 SDL_DFB_WINDOWDATA(window);
318 361 SDL_VideoDisplay *display = window->display;
319 if (windata->is_managed) { 362 DFBWindowOptions wopts;
320 DirectFB_WM_MaximizeWindow(_this, window); 363
321 } else 364 SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin,
322 SDL_Unsupported(); 365 &windata->restore.x, &windata->restore.y));
366 SDL_DFB_CHECK(windata->dfbwin->GetSize(windata->dfbwin, &windata->restore.w,
367 &windata->restore.h));
368
369 DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;
370
371 SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, 0, 0));
372 SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin,
373 display->current_mode.w, display->current_mode.h));
374
375 /* Set Options */
376 SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
377 wopts |= DWOP_KEEP_SIZE | DWOP_KEEP_POSITION;
378 SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
323 } 379 }
324 380
325 void 381 void
326 DirectFB_MinimizeWindow(_THIS, SDL_Window * window) 382 DirectFB_MinimizeWindow(_THIS, SDL_Window * window)
327 { 383 {
332 388
333 void 389 void
334 DirectFB_RestoreWindow(_THIS, SDL_Window * window) 390 DirectFB_RestoreWindow(_THIS, SDL_Window * window)
335 { 391 {
336 SDL_DFB_WINDOWDATA(window); 392 SDL_DFB_WINDOWDATA(window);
337 393 DFBWindowOptions wopts;
338 if (windata->is_managed) { 394
339 DirectFB_WM_RestoreWindow(_this, window); 395 /* Set Options */
340 } else 396 SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts));
341 SDL_Unsupported(); 397 wopts &= ~(DWOP_KEEP_SIZE | DWOP_KEEP_POSITION);
398 SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
399
400 /* Window layout */
401 DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
402 windata->restore.w, windata->restore.h);
403 SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, windata->restore.w,
404 windata->restore.h));
405 SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, windata->restore.x,
406 windata->restore.y));
407
408 if (!(window->flags & SDL_WINDOW_RESIZABLE))
409 wopts |= DWOP_KEEP_SIZE;
410
411 if (window->flags & SDL_WINDOW_FULLSCREEN)
412 wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_SIZE;
413 SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts));
414
415
342 } 416 }
343 417
344 void 418 void
345 DirectFB_SetWindowGrab(_THIS, SDL_Window * window) 419 DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
346 { 420 {
349 DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); 423 DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
350 424
351 if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) { 425 if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
352 if (gwindata != NULL) 426 if (gwindata != NULL)
353 { 427 {
354 SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window)); 428 SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
355 SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window)); 429 SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin));
356 } 430 }
357 SDL_DFB_CHECK(windata->window->GrabPointer(windata->window)); 431 SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin));
358 SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window)); 432 SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin));
359 devdata->grabbed_window = window; 433 devdata->grabbed_window = window;
360 } else { 434 } else {
361 SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window)); 435 SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
362 SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window)); 436 SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
363 devdata->grabbed_window = NULL; 437 devdata->grabbed_window = NULL;
364 } 438 }
365 } 439 }
366 440
367 void 441 void
370 SDL_DFB_DEVICEDATA(_this); 444 SDL_DFB_DEVICEDATA(_this);
371 SDL_DFB_WINDOWDATA(window); 445 SDL_DFB_WINDOWDATA(window);
372 DFB_WindowData *p; 446 DFB_WindowData *p;
373 447
374 /* Some cleanups */ 448 /* Some cleanups */
375 SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window)); 449 SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
376 SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window)); 450 SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
377 451
378 #if SDL_DIRECTFB_OPENGL 452 #if SDL_DIRECTFB_OPENGL
379 DirectFB_GL_DestroyWindowContexts(_this, window); 453 DirectFB_GL_DestroyWindowContexts(_this, window);
380 #endif 454 #endif
455
456 if (window->shaper)
457 {
458 SDL_ShapeData *data = window->shaper->driverdata;
459 SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface));
460 SDL_DFB_RELEASE(data->surface);
461 SDL_DFB_FREE(data);
462 SDL_DFB_FREE(window->shaper);
463 }
381 464
382 SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL)); 465 SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL));
383 SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface)); 466 SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface));
384 SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface)); 467 SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface));
385 SDL_DFB_RELEASE(windata->icon); 468 SDL_DFB_RELEASE(windata->icon);
386 SDL_DFB_RELEASE(windata->font); 469 SDL_DFB_RELEASE(windata->font);
387 SDL_DFB_RELEASE(windata->eventbuffer); 470 SDL_DFB_RELEASE(windata->eventbuffer);
388 SDL_DFB_RELEASE(windata->surface); 471 SDL_DFB_RELEASE(windata->surface);
389 SDL_DFB_RELEASE(windata->window_surface); 472 SDL_DFB_RELEASE(windata->window_surface);
390 473
391 SDL_DFB_RELEASE(windata->window); 474 SDL_DFB_RELEASE(windata->dfbwin);
392 475
393 /* Remove from list ... */ 476 /* Remove from list ... */
394 477
395 p = devdata->firstwin; 478 p = devdata->firstwin->driverdata;
396 while (p && p->next != windata) 479
397 p = p->next; 480 while (p && p->next != window)
481 p = (p->next ? p->next->driverdata : NULL);
398 if (p) 482 if (p)
399 p->next = windata->next; 483 p->next = windata->next;
400 else 484 else
401 devdata->firstwin = windata->next; 485 devdata->firstwin = windata->next;
402 SDL_free(windata); 486 SDL_free(windata);
405 489
406 SDL_bool 490 SDL_bool
407 DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window, 491 DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
408 struct SDL_SysWMinfo * info) 492 struct SDL_SysWMinfo * info)
409 { 493 {
410 SDL_Unsupported(); 494 SDL_DFB_DEVICEDATA(_this);
411 return SDL_FALSE; 495 SDL_DFB_WINDOWDATA(window);
412 } 496
413 497 if (info->version.major == SDL_MAJOR_VERSION &&
414 static void 498 info->version.minor == SDL_MINOR_VERSION) {
415 DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window) 499 info->subsystem = SDL_SYSWM_DIRECTFB;
500 info->info.dfb.dfb = devdata->dfb;
501 info->info.dfb.window = windata->dfbwin;
502 info->info.dfb.surface = windata->surface;
503 return SDL_TRUE;
504 } else {
505 SDL_SetError("Application not compiled with SDL %d.%d\n",
506 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
507 return SDL_FALSE;
508 }
509 }
510
511 void
512 DirectFB_AdjustWindowSurface(SDL_Window * window)
416 { 513 {
417 SDL_DFB_WINDOWDATA(window); 514 SDL_DFB_WINDOWDATA(window);
418 int adjust = windata->wm_needs_redraw; 515 int adjust = windata->wm_needs_redraw;
419 int cw, ch; 516 int cw, ch;
420 517
427 adjust = 1; 524 adjust = 1;
428 } 525 }
429 526
430 if (adjust) { 527 if (adjust) {
431 #if SDL_DIRECTFB_OPENGL 528 #if SDL_DIRECTFB_OPENGL
432 DirectFB_GL_FreeWindowContexts(_this, window); 529 DirectFB_GL_FreeWindowContexts(window->display->device, window);
433 #endif 530 #endif
434 531
435 #if DFB_VERSION_ATLEAST(1,2,1) 532 #if (DFB_VERSION_ATLEAST(1,2,1))
436 SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window, 533 SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
437 windata->size.w, 534 windata->size.w,
438 windata->size.h)); 535 windata->size.h));
439 SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface, 536 SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
440 windata-> 537 windata->
441 window_surface, 538 window_surface,
442 &windata->client)); 539 &windata->client));
443 #else 540 #else
444 DFBWindowOptions opts; 541 DFBWindowOptions opts;
445 542
446 SDL_DFB_CHECKERR(windata->window->GetOptions(windata->window, &opts)); 543 SDL_DFB_CHECKERR(windata->dfbwin->GetOptions(windata->dfbwin, &opts));
447 /* recreate subsurface */ 544 /* recreate subsurface */
448 SDL_DFB_RELEASE(windata->surface); 545 SDL_DFB_RELEASE(windata->surface);
449 546
450 if (opts & DWOP_SCALE) 547 if (opts & DWOP_SCALE)
451 SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window, 548 SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin,
452 windata->size.w, 549 windata->size.w,
453 windata->size.h)); 550 windata->size.h));
454 SDL_DFB_CHECKERR(windata->window_surface-> 551 SDL_DFB_CHECKERR(windata->window_surface->
455 GetSubSurface(windata->window_surface, 552 GetSubSurface(windata->window_surface,
456 &windata->client, &windata->surface)); 553 &windata->client, &windata->surface));
457 #endif 554 #endif
458 DirectFB_WM_RedrawLayout(_this, window); 555 DirectFB_WM_RedrawLayout(window->display->device, window);
459 556
460 #if SDL_DIRECTFB_OPENGL 557 #if SDL_DIRECTFB_OPENGL
461 DirectFB_GL_ReAllocWindowContexts(_this, window); 558 DirectFB_GL_ReAllocWindowContexts(window->display->device, window);
462 #endif 559 #endif
463 } 560 }
464 error: 561 error:
465 return; 562 return;
466 } 563 }