Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_modes.c @ 3023:d72a0dd80e8b
DirectFB cleanups & simple window manager
- use SDL_getenv, not getenv ...
- no more support for 0.9.25 - not even mentioned any longer on directfb.org
- fix fullscreen issues
- add a simple window manager unless the directfb team comes up with a working wm.
The driver has support for a very, very basic window manager you may
want to use when runnning with "wm=default". Use
export SDL_DIRECTFB_WM=1
to enable basic window borders including icon support. In order to have the window title rendered,
you need to have the following font installed:
/usr/share/fonts/truetype/freefont/FreeSans.ttf
author | Couriersud <couriersud@arcor.de> |
---|---|
date | Sun, 11 Jan 2009 23:49:23 +0000 |
parents | 8cc00819c8d6 |
children | 490f3e4fe753 |
comparison
equal
deleted
inserted
replaced
3022:db20dde98dd3 | 3023:d72a0dd80e8b |
---|---|
202 SDL_DFB_DEVICEDATA(_this); | 202 SDL_DFB_DEVICEDATA(_this); |
203 DFBDisplayLayerConfig config; | 203 DFBDisplayLayerConfig config; |
204 DFBDisplayLayerConfigFlags failed; | 204 DFBDisplayLayerConfigFlags failed; |
205 int ret; | 205 int ret; |
206 | 206 |
207 SDL_DFB_CHECKERR(data->layer-> | 207 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, |
208 SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE)); | 208 DLSCL_ADMINISTRATIVE)); |
209 config.width = mode->w; | 209 config.width = mode->w; |
210 config.height = mode->h; | 210 config.height = mode->h; |
211 config.pixelformat = SDLToDFBPixelFormat(mode->format); | 211 config.pixelformat = SDLToDFBPixelFormat(mode->format); |
212 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; | 212 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; |
213 if (devdata->use_yuv_underlays) { | 213 if (devdata->use_yuv_underlays) { |
214 config.flags |= DLCONF_OPTIONS; | 214 config.flags |= DLCONF_OPTIONS; |
215 config.options = DLOP_ALPHACHANNEL; | 215 config.options = DLOP_ALPHACHANNEL; |
216 } | 216 } |
217 failed = 0; | 217 failed = 0; |
218 data->layer->TestConfiguration(data->layer, &config, &failed); | 218 data->layer->TestConfiguration(data->layer, &config, &failed); |
219 SDL_DFB_CHECKERR(data->layer-> | 219 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, |
220 SetCooperativeLevel(data->layer, DLSCL_SHARED)); | 220 DLSCL_SHARED)); |
221 if (failed == 0) | 221 if (failed == 0) |
222 SDL_AddDisplayMode(_this->current_display, mode); | 222 SDL_AddDisplayMode(_this->current_display, mode); |
223 else | 223 else |
224 SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w, mode->h, | 224 SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w, |
225 failed); | 225 mode->h, failed); |
226 | 226 |
227 return; | 227 return; |
228 error: | 228 error: |
229 return; | 229 return; |
230 } | 230 } |
233 DirectFB_InitModes(_THIS) | 233 DirectFB_InitModes(_THIS) |
234 { | 234 { |
235 SDL_DFB_DEVICEDATA(_this); | 235 SDL_DFB_DEVICEDATA(_this); |
236 IDirectFBDisplayLayer *layer = NULL; | 236 IDirectFBDisplayLayer *layer = NULL; |
237 SDL_VideoDisplay display; | 237 SDL_VideoDisplay display; |
238 DFB_DisplayData *dispdata; | 238 DFB_DisplayData *dispdata = NULL; |
239 SDL_DisplayMode mode; | 239 SDL_DisplayMode mode; |
240 #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23) | |
241 DFBCardCapabilities caps; | |
242 #else | |
243 DFBGraphicsDeviceDescription caps; | 240 DFBGraphicsDeviceDescription caps; |
244 #endif | |
245 DFBDisplayLayerConfig dlc; | 241 DFBDisplayLayerConfig dlc; |
246 struct scn_callback_t *screencbdata; | 242 struct scn_callback_t *screencbdata; |
247 | 243 |
248 int tcw[DFB_MAX_SCREENS]; | 244 int tcw[DFB_MAX_SCREENS]; |
249 int tch[DFB_MAX_SCREENS]; | 245 int tch[DFB_MAX_SCREENS]; |
257 for (i = 0; i < DFB_MAX_SCREENS; i++) { | 253 for (i = 0; i < DFB_MAX_SCREENS; i++) { |
258 screencbdata->gralayer[i] = -1; | 254 screencbdata->gralayer[i] = -1; |
259 screencbdata->vidlayer[i] = -1; | 255 screencbdata->vidlayer[i] = -1; |
260 } | 256 } |
261 | 257 |
262 SDL_DFB_CHECKERR(devdata->dfb-> | 258 SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &cbScreens, |
263 EnumScreens(devdata->dfb, &cbScreens, screencbdata)); | 259 screencbdata)); |
264 | 260 |
265 for (i = 0; i < screencbdata->numscreens; i++) { | 261 for (i = 0; i < screencbdata->numscreens; i++) { |
266 IDirectFBScreen *screen; | 262 IDirectFBScreen *screen; |
267 | 263 |
268 SDL_DFB_CHECKERR(devdata->dfb-> | 264 SDL_DFB_CHECKERR(devdata->dfb->GetScreen(devdata->dfb, |
269 GetScreen(devdata->dfb, screencbdata->screenid[i], | 265 screencbdata->screenid |
270 &screen)); | 266 [i], &screen)); |
271 | 267 |
272 screencbdata->aux = i; | 268 screencbdata->aux = i; |
273 SDL_DFB_CHECKERR(screen-> | 269 SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &cbLayers, |
274 EnumDisplayLayers(screen, &cbLayers, screencbdata)); | 270 screencbdata)); |
275 #if (DIRECTFB_MAJOR_VERSION >= 1) | |
276 screen->GetSize(screen, &tcw[i], &tch[i]); | 271 screen->GetSize(screen, &tcw[i], &tch[i]); |
277 #else | |
278 /* FIXME: this is only used to center windows | |
279 * Should be done otherwise, e.g. get surface from layer | |
280 */ | |
281 tcw[i] = 800; | |
282 tch[i] = 600; | |
283 #endif | |
284 screen->Release(screen); | 272 screen->Release(screen); |
285 } | 273 } |
286 | 274 |
287 /* Query card capabilities */ | 275 /* Query card capabilities */ |
288 | 276 |
291 SDL_DFB_DEBUG("SDL directfb video driver - %s %s\n", __DATE__, __TIME__); | 279 SDL_DFB_DEBUG("SDL directfb video driver - %s %s\n", __DATE__, __TIME__); |
292 SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor); | 280 SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor); |
293 SDL_DFB_DEBUG("Found %d screens\n", screencbdata->numscreens); | 281 SDL_DFB_DEBUG("Found %d screens\n", screencbdata->numscreens); |
294 | 282 |
295 for (i = 0; i < screencbdata->numscreens; i++) { | 283 for (i = 0; i < screencbdata->numscreens; i++) { |
296 SDL_DFB_CHECKERR(devdata->dfb-> | 284 SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb, |
297 GetDisplayLayer(devdata->dfb, | 285 screencbdata->gralayer |
298 screencbdata->gralayer[i], &layer)); | 286 [i], &layer)); |
299 | 287 |
300 SDL_DFB_CHECKERR(layer-> | 288 SDL_DFB_CHECKERR(layer->SetCooperativeLevel(layer, |
301 SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE)); | 289 DLSCL_ADMINISTRATIVE)); |
302 layer->EnableCursor(layer, 1); | 290 layer->EnableCursor(layer, 1); |
303 SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0)); | 291 SDL_DFB_CHECKERR(layer->SetCursorOpacity(layer, 0xC0)); |
304 | 292 |
305 if (devdata->use_yuv_underlays) { | 293 if (devdata->use_yuv_underlays) { |
306 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_OPTIONS; | 294 dlc.flags = DLCONF_PIXELFORMAT | DLCONF_OPTIONS; |
379 int ret; | 367 int ret; |
380 | 368 |
381 data.nummodes = 0; | 369 data.nummodes = 0; |
382 /* Enumerate the available fullscreen modes */ | 370 /* Enumerate the available fullscreen modes */ |
383 SDL_DFB_CALLOC(data.modelist, DFB_MAX_MODES, sizeof(SDL_DisplayMode)); | 371 SDL_DFB_CALLOC(data.modelist, DFB_MAX_MODES, sizeof(SDL_DisplayMode)); |
384 SDL_DFB_CHECKERR(devdata->dfb-> | 372 SDL_DFB_CHECKERR(devdata->dfb->EnumVideoModes(devdata->dfb, |
385 EnumVideoModes(devdata->dfb, EnumModesCallback, &data)); | 373 EnumModesCallback, &data)); |
386 | 374 |
387 for (i = 0; i < data.nummodes; ++i) { | 375 for (i = 0; i < data.nummodes; ++i) { |
388 mode = data.modelist[i]; | 376 mode = data.modelist[i]; |
389 | 377 |
390 mode.format = SDL_PIXELFORMAT_ARGB8888; | 378 mode.format = SDL_PIXELFORMAT_ARGB8888; |
417 DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata; | 405 DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata; |
418 DFBDisplayLayerConfig config, rconfig; | 406 DFBDisplayLayerConfig config, rconfig; |
419 DFBDisplayLayerConfigFlags fail = 0; | 407 DFBDisplayLayerConfigFlags fail = 0; |
420 DFBResult ret; | 408 DFBResult ret; |
421 | 409 |
422 SDL_DFB_CHECKERR(data->layer-> | 410 SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, |
423 SetCooperativeLevel(data->layer, DLSCL_ADMINISTRATIVE)); | 411 DLSCL_ADMINISTRATIVE)); |
424 | 412 |
425 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &config)); | 413 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &config)); |
426 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; | 414 config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; |
427 if (mode->format != SDL_PIXELFORMAT_UNKNOWN) { | 415 if (mode->format != SDL_PIXELFORMAT_UNKNOWN) { |
428 config.flags |= DLCONF_PIXELFORMAT; | 416 config.flags |= DLCONF_PIXELFORMAT; |
438 } | 426 } |
439 | 427 |
440 data->layer->TestConfiguration(data->layer, &config, &fail); | 428 data->layer->TestConfiguration(data->layer, &config, &fail); |
441 | 429 |
442 if (fail & | 430 if (fail & |
443 (DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_OPTIONS)) | 431 (DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | |
444 { | 432 DLCONF_OPTIONS)) { |
445 SDL_DFB_ERR("Error setting mode %dx%d-%x\n", mode->w, mode->h, | 433 SDL_DFB_ERR("Error setting mode %dx%d-%x\n", mode->w, mode->h, |
446 mode->format); | 434 mode->format); |
447 return -1; | 435 return -1; |
448 } | 436 } |
449 | 437 |
451 config.flags &= ~fail; | 439 config.flags &= ~fail; |
452 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); | 440 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); |
453 #if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2) | 441 #if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2) |
454 /* Need to call this twice ! */ | 442 /* Need to call this twice ! */ |
455 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); | 443 SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); |
456 //SDL_DFB_CHECKERR(data->layer->SetSourceRectangle(data->layer, 0, 0, config.width, config.height)); | |
457 #endif | 444 #endif |
458 | 445 |
459 /* Double check */ | 446 /* Double check */ |
460 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &rconfig)); | 447 SDL_DFB_CHECKERR(data->layer->GetConfiguration(data->layer, &rconfig)); |
461 SDL_DFB_CHECKERR(data->layer-> | 448 SDL_DFB_CHECKERR(data-> |
462 SetCooperativeLevel(data->layer, DLSCL_SHARED)); | 449 layer->SetCooperativeLevel(data->layer, DLSCL_SHARED)); |
463 | 450 |
464 if ((config.width != rconfig.width) || | 451 if ((config.width != rconfig.width) || (config.height != rconfig.height) |
465 (config.height != rconfig.height) || | 452 || ((mode->format != SDL_PIXELFORMAT_UNKNOWN) |
466 ((mode->format != SDL_PIXELFORMAT_UNKNOWN) | 453 && (config.pixelformat != rconfig.pixelformat))) { |
467 && (config.pixelformat != rconfig.pixelformat))) { | |
468 SDL_DFB_ERR("Error setting mode %dx%d-%x\n", mode->w, mode->h, | 454 SDL_DFB_ERR("Error setting mode %dx%d-%x\n", mode->w, mode->h, |
469 mode->format); | 455 mode->format); |
470 return -1; | 456 return -1; |
471 } | 457 } |
472 | 458 |
481 } | 467 } |
482 | 468 |
483 void | 469 void |
484 DirectFB_QuitModes(_THIS) | 470 DirectFB_QuitModes(_THIS) |
485 { | 471 { |
486 DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata; | 472 //DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata; |
487 SDL_DisplayMode tmode; | 473 SDL_DisplayMode tmode; |
488 DFBResult ret; | 474 DFBResult ret; |
489 int i; | 475 int i; |
490 | 476 |
491 SDL_SelectVideoDisplay(0); | 477 SDL_SelectVideoDisplay(0); |
500 for (i = 0; i < SDL_GetNumVideoDisplays(); i++) { | 486 for (i = 0; i < SDL_GetNumVideoDisplays(); i++) { |
501 DFB_DisplayData *dispdata = | 487 DFB_DisplayData *dispdata = |
502 (DFB_DisplayData *) _this->displays[i].driverdata; | 488 (DFB_DisplayData *) _this->displays[i].driverdata; |
503 | 489 |
504 if (dispdata->layer) { | 490 if (dispdata->layer) { |
505 SDL_DFB_CHECK(dispdata->layer-> | 491 SDL_DFB_CHECK(dispdata-> |
506 SetCooperativeLevel(dispdata->layer, | 492 layer->SetCooperativeLevel(dispdata->layer, |
507 DLSCL_ADMINISTRATIVE)); | 493 DLSCL_ADMINISTRATIVE)); |
508 SDL_DFB_CHECK(dispdata->layer-> | 494 SDL_DFB_CHECK(dispdata-> |
509 SetCursorOpacity(dispdata->layer, 0x00)); | 495 layer->SetCursorOpacity(dispdata->layer, 0x00)); |
510 SDL_DFB_CHECK(dispdata->layer-> | 496 SDL_DFB_CHECK(dispdata-> |
511 SetCooperativeLevel(dispdata->layer, DLSCL_SHARED)); | 497 layer->SetCooperativeLevel(dispdata->layer, |
498 DLSCL_SHARED)); | |
512 } | 499 } |
513 | 500 |
514 SDL_DFB_RELEASE(dispdata->layer); | 501 SDL_DFB_RELEASE(dispdata->layer); |
515 SDL_DFB_RELEASE(dispdata->vidlayer); | 502 SDL_DFB_RELEASE(dispdata->vidlayer); |
516 | 503 |