diff src/video/directfb/SDL_DirectFB_modes.c @ 3500:4b594623401b

Work in progress on multi-display support: * Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one. * The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 05:57:15 +0000
parents 490f3e4fe753
children 58c1b9ec7074
line wrap: on
line diff
--- a/src/video/directfb/SDL_DirectFB_modes.c	Mon Nov 30 21:04:25 2009 +0000
+++ b/src/video/directfb/SDL_DirectFB_modes.c	Tue Dec 01 05:57:15 2009 +0000
@@ -197,7 +197,7 @@
 }
 
 static void
-CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
+CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, SDL_DisplayMode * mode)
 {
     SDL_DFB_DEVICEDATA(_this);
     DFBDisplayLayerConfig config;
@@ -219,7 +219,7 @@
     SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
                                                       DLSCL_SHARED));
     if (failed == 0)
-        SDL_AddDisplayMode(_this->current_display, mode);
+        SDL_AddDisplayMode(display, mode);
     else
         SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
                       mode->h, failed);
@@ -356,11 +356,10 @@
 }
 
 void
-DirectFB_GetDisplayModes(_THIS)
+DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
 {
     SDL_DFB_DEVICEDATA(_this);
-    DFB_DisplayData *dispdata =
-        (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
+    DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
     SDL_DisplayMode mode;
     struct modes_callback_t data;
     int i;
@@ -376,25 +375,23 @@
         mode = data.modelist[i];
 
         mode.format = SDL_PIXELFORMAT_ARGB8888;
-        CheckSetDisplayMode(_this, dispdata, &mode);
+        CheckSetDisplayMode(_this, display, dispdata, &mode);
         mode.format = SDL_PIXELFORMAT_RGB888;
-        CheckSetDisplayMode(_this, dispdata, &mode);
+        CheckSetDisplayMode(_this, display, dispdata, &mode);
         mode.format = SDL_PIXELFORMAT_RGB24;
-        CheckSetDisplayMode(_this, dispdata, &mode);
+        CheckSetDisplayMode(_this, display, dispdata, &mode);
         mode.format = SDL_PIXELFORMAT_RGB565;
-        CheckSetDisplayMode(_this, dispdata, &mode);
+        CheckSetDisplayMode(_this, display, dispdata, &mode);
         mode.format = SDL_PIXELFORMAT_INDEX8;
-        CheckSetDisplayMode(_this, dispdata, &mode);
+        CheckSetDisplayMode(_this, display, dispdata, &mode);
     }
-    SDL_DFB_FREE(data.modelist);
-    return;
-  error:
+
     SDL_DFB_FREE(data.modelist);
     return;
 }
 
 int
-DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
+DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
 {
     /*
      * FIXME: video mode switch is currently broken for 1.2.0
@@ -402,7 +399,7 @@
      */
 
     SDL_DFB_DEVICEDATA(_this);
-    DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
+    DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
     DFBDisplayLayerConfig config, rconfig;
     DFBDisplayLayerConfigFlags fail = 0;
     DFBResult ret;
@@ -459,7 +456,7 @@
     data->pixelformat = rconfig.pixelformat;
     data->cw = config.width;
     data->ch = config.height;
-    SDL_CurrentDisplay.current_mode = *mode;
+    display->current_mode = *mode;
 
     return 0;
   error:
@@ -474,18 +471,16 @@
     DFBResult ret;
     int i;
 
-    SDL_SelectVideoDisplay(0);
-
-    SDL_GetDesktopDisplayMode(&tmode);
-    tmode.format = SDL_PIXELFORMAT_UNKNOWN;
-    DirectFB_SetDisplayMode(_this, &tmode);
+    for (i = 0; i < _this->num_displays; ++i) {
+        SDL_VideoDisplay *display = &_this->displays[i];
+        DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
 
-    SDL_GetDesktopDisplayMode(&tmode);
-    DirectFB_SetDisplayMode(_this, &tmode);
+        SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
+        tmode.format = SDL_PIXELFORMAT_UNKNOWN;
+        DirectFB_SetDisplayMode(_this, display, &tmode);
 
-    for (i = 0; i < SDL_GetNumVideoDisplays(); i++) {
-        DFB_DisplayData *dispdata =
-            (DFB_DisplayData *) _this->displays[i].driverdata;
+        SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
+        DirectFB_SetDisplayMode(_this, display, &tmode);
 
         if (dispdata->layer) {
             SDL_DFB_CHECK(dispdata->