diff src/SDL_compat.c @ 5249:762e40fb8e28

Be explicit about what display you're querying. The default display is 0.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 10 Feb 2011 12:14:37 -0800
parents 3a8a452b49f0
children f908e06b3c96
line wrap: on
line diff
--- a/src/SDL_compat.c	Thu Feb 10 11:39:08 2011 -0800
+++ b/src/SDL_compat.c	Thu Feb 10 12:14:37 2011 -0800
@@ -71,15 +71,17 @@
     return NULL;
 }
 
-static void
-SelectVideoDisplay()
+static int
+GetVideoDisplay()
 {
     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));
+        SDL_atoi(variable);
+    } else {
+        return 0;
     }
 }
 
@@ -89,10 +91,8 @@
     static SDL_VideoInfo info;
     SDL_DisplayMode mode;
 
-    SelectVideoDisplay();
-
     /* Memory leak, compatibility code, who cares? */
-    if (!info.vfmt && SDL_GetDesktopDisplayMode(&mode) == 0) {
+    if (!info.vfmt && SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode) == 0) {
         int bpp;
         Uint32 Rmask, Gmask, Bmask, Amask;
 
@@ -114,17 +114,15 @@
         return 0;
     }
 
-    SelectVideoDisplay();
-
     if (!(flags & SDL_FULLSCREEN)) {
         SDL_DisplayMode mode;
-        SDL_GetDesktopDisplayMode(&mode);
+        SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode);
         return SDL_BITSPERPIXEL(mode.format);
     }
 
-    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
+    for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) {
         SDL_DisplayMode mode;
-        SDL_GetDisplayMode(i, &mode);
+        SDL_GetDisplayMode(GetVideoDisplay(), i, &mode);
         if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
             if (!mode.format) {
                 return bpp;
@@ -147,8 +145,6 @@
         return NULL;
     }
 
-    SelectVideoDisplay();
-
     if (!(flags & SDL_FULLSCREEN)) {
         return (SDL_Rect **) (-1);
     }
@@ -160,11 +156,11 @@
     /* Memory leak, but this is a compatibility function, who cares? */
     nmodes = 0;
     modes = NULL;
-    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
+    for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) {
         SDL_DisplayMode mode;
         int bpp;
 
-        SDL_GetDisplayMode(i, &mode);
+        SDL_GetDisplayMode(GetVideoDisplay(), i, &mode);
         if (!mode.w || !mode.h) {
             return (SDL_Rect **) (-1);
         }
@@ -342,7 +338,7 @@
     }
     if (center) {
         SDL_DisplayMode mode;
-        SDL_GetDesktopDisplayMode(&mode);
+        SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode);
         *x = (mode.w - w) / 2;
         *y = (mode.h - h) / 2;
     }
@@ -453,9 +449,7 @@
         }
     }
 
-    SelectVideoDisplay();
-
-    SDL_GetDesktopDisplayMode(&desktop_mode);
+    SDL_GetDesktopDisplayMode(GetVideoDisplay(), &desktop_mode);
 
     if (width == 0) {
         width = desktop_mode.w;