Added support for SDL 1.2 environment variables:
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Dec 2009 08:43:12 +0000
changeset 3518 abefdc334970
parent 3517 e7eec78e4b92
child 3519 1374f9275de9
Added support for SDL 1.2 environment variables: SDL_VIDEO_FULLSCREEN_DISPLAY, SDL_VIDEO_FULLSCREEN_HEAD
src/SDL_compat.c
--- a/src/SDL_compat.c	Thu Dec 03 08:33:39 2009 +0000
+++ b/src/SDL_compat.c	Thu Dec 03 08:43:12 2009 +0000
@@ -64,12 +64,26 @@
     return NULL;
 }
 
+static void
+SelectVideoDisplay()
+{
+    const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
+    if ( !variable ) {
+        variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD");
+    }
+    if ( variable ) {
+        SDL_SelectVideoDisplay(SDL_atoi(variable));
+    }
+}
+
 const SDL_VideoInfo *
 SDL_GetVideoInfo(void)
 {
     static SDL_VideoInfo info;
     SDL_DisplayMode mode;
 
+    SelectVideoDisplay();
+
     /* Memory leak, compatibility code, who cares? */
     if (!info.vfmt && SDL_GetDesktopDisplayMode(&mode) == 0) {
         int bpp;
@@ -93,6 +107,8 @@
         return 0;
     }
 
+    SelectVideoDisplay();
+
     if (!(flags & SDL_FULLSCREEN)) {
         SDL_DisplayMode mode;
         SDL_GetDesktopDisplayMode(&mode);
@@ -124,6 +140,8 @@
         return NULL;
     }
 
+    SelectVideoDisplay();
+
     if (!(flags & SDL_FULLSCREEN)) {
         return (SDL_Rect **) (-1);
     }
@@ -495,6 +513,8 @@
         }
     }
 
+    SelectVideoDisplay();
+
     SDL_GetDesktopDisplayMode(&desktop_mode);
 
     if (width == 0) {