Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Be explicit about what display you're querying. The default display i…

…s 0.
  • Loading branch information
slouken committed Feb 10, 2011
1 parent b0d89bd commit 0b9dcbb622c322469af1ed18d1725184f0591ca5
Showing with 90 additions and 166 deletions.
  1. +13 −38 include/SDL_video.h
  2. +13 −19 src/SDL_compat.c
  3. +0 −8 src/video/SDL_sysvideo.h
  4. +51 −83 src/video/SDL_video.c
  5. +1 −1 src/video/x11/SDL_x11opengl.c
  6. +3 −5 test/common.c
  7. +1 −1 test/testgl2.c
  8. +5 −6 test/testime.c
  9. +3 −5 test/testvidinfo.c
@@ -236,7 +236,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
* \brief Returns the number of available video displays.
*
* \sa SDL_GetDisplayBounds()
* \sa SDL_SelectVideoDisplay()
*/
extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);

@@ -248,34 +247,14 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
*
* \sa SDL_GetNumVideoDisplays()
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int index, SDL_Rect * rect);
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);

/**
* \brief Set the index of the currently selected display.
*
* \return 0 on success, or -1 if the index is out of range.
*
* \sa SDL_GetNumVideoDisplays()
* \sa SDL_GetCurrentVideoDisplay()
*/
extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index);

/**
* \brief Get the index of the currently selected display.
*
* \return The index of the currently selected display.
*
* \sa SDL_GetNumVideoDisplays()
* \sa SDL_SelectVideoDisplay()
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentVideoDisplay(void);

/**
* \brief Returns the number of available display modes for the current display.
* \brief Returns the number of available display modes.
*
* \sa SDL_GetDisplayMode()
*/
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);

/**
* \brief Fill in information about a specific display mode.
@@ -288,19 +267,18 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void);
*
* \sa SDL_GetNumDisplayModes()
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int index,
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
SDL_DisplayMode * mode);

/**
* \brief Fill in information about the desktop display mode for the current
* display.
* \brief Fill in information about the desktop display mode.
*/
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode);
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode);

/**
* \brief Fill in information about the current display mode.
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode);


/**
@@ -323,16 +301,13 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode);
* \sa SDL_GetNumDisplayModes()
* \sa SDL_GetDisplayMode()
*/
extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const
SDL_DisplayMode
* mode,
SDL_DisplayMode
* closest);
extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);

/**
* \brief Set the display mode used when a fullscreen window is visible
* on the currently selected display. By default the window's
* dimensions and the desktop format and refresh rate are used.
* \brief Set the display mode used when a fullscreen window is visible.
*
* By default the window's dimensions and the desktop format and refresh rate
* are used.
*
* \param mode The mode to use, or NULL for the default mode.
*
@@ -347,7 +322,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,

/**
* \brief Fill in information about the display mode used when a fullscreen
* window is visible on the currently selected display.
* window is visible.
*
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_SetWindowFullscreen()
@@ -71,15 +71,17 @@ SDL_VideoDriverName(char *namebuf, int maxlen)
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 @@ SDL_GetVideoInfo(void)
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 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags)
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 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
return NULL;
}

SelectVideoDisplay();

if (!(flags & SDL_FULLSCREEN)) {
return (SDL_Rect **) (-1);
}
@@ -160,11 +156,11 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags)
/* 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 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y)
}
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 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
}
}

SelectVideoDisplay();

SDL_GetDesktopDisplayMode(&desktop_mode);
SDL_GetDesktopDisplayMode(GetVideoDisplay(), &desktop_mode);

if (width == 0) {
width = desktop_mode.w;
@@ -322,18 +322,10 @@ extern VideoBootStrap Android_bootstrap;
extern VideoBootStrap DUMMY_bootstrap;
#endif

#define SDL_CurrentDisplay (&_this->displays[_this->current_display])

extern SDL_VideoDevice *SDL_GetVideoDevice(void);
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);

extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);

0 comments on commit 0b9dcbb

Please sign in to comment.