diff --git a/src/SDL_compat.c b/src/SDL_compat.c index b8d675151..798728a6d 100644 --- a/src/SDL_compat.c +++ b/src/SDL_compat.c @@ -64,12 +64,26 @@ SDL_VideoDriverName(char *namebuf, int maxlen) 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 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) return 0; } + SelectVideoDisplay(); + if (!(flags & SDL_FULLSCREEN)) { SDL_DisplayMode mode; SDL_GetDesktopDisplayMode(&mode); @@ -124,6 +140,8 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags) return NULL; } + SelectVideoDisplay(); + if (!(flags & SDL_FULLSCREEN)) { return (SDL_Rect **) (-1); } @@ -495,6 +513,8 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) } } + SelectVideoDisplay(); + SDL_GetDesktopDisplayMode(&desktop_mode); if (width == 0) {