Added SDL_GetCurrentVideoDisplay()
authorSam Lantinga <slouken@libsdl.org>
Wed, 02 Aug 2006 03:20:52 +0000
changeset 19632590b68531ef
parent 1962 c92e5f3e68d9
child 1964 071b6598d48f
Added SDL_GetCurrentVideoDisplay()
include/SDL_video.h
src/video/SDL_video.c
     1.1 --- a/include/SDL_video.h	Sun Jul 30 08:09:20 2006 +0000
     1.2 +++ b/include/SDL_video.h	Wed Aug 02 03:20:52 2006 +0000
     1.3 @@ -403,13 +403,24 @@
     1.4   *
     1.5   * \brief Set the index of the currently selected display.
     1.6   *
     1.7 + * \return 0 on success, or -1 if the index is out of range.
     1.8 + *
     1.9 + * \sa SDL_GetNumVideoDisplays()
    1.10 + * \sa SDL_GetCurrentVideoDisplay()
    1.11 + */
    1.12 +extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index);
    1.13 +
    1.14 +/**
    1.15 + * \fn int SDL_GetCurrentVideoDisplay(void)
    1.16 + *
    1.17 + * \brief Get the index of the currently selected display.
    1.18 + *
    1.19   * \return The index of the currently selected display.
    1.20   *
    1.21 - * \note You can query the currently selected display by passing an index of -1.
    1.22 - *
    1.23   * \sa SDL_GetNumVideoDisplays()
    1.24 + * \sa SDL_SelectVideoDisplay()
    1.25   */
    1.26 -extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index);
    1.27 +extern DECLSPEC int SDLCALL SDL_GetCurrentVideoDisplay(void);
    1.28  
    1.29  /**
    1.30   * \fn int SDL_GetNumDisplayModes(void)
     2.1 --- a/src/video/SDL_video.c	Sun Jul 30 08:09:20 2006 +0000
     2.2 +++ b/src/video/SDL_video.c	Wed Aug 02 03:20:52 2006 +0000
     2.3 @@ -355,13 +355,21 @@
     2.4          SDL_UninitializedVideo();
     2.5          return (-1);
     2.6      }
     2.7 -    if (index >= 0) {
     2.8 -        if (index >= _this->num_displays) {
     2.9 -            SDL_SetError("index must be in the range 0 - %d",
    2.10 -                         _this->num_displays - 1);
    2.11 -            return -1;
    2.12 -        }
    2.13 -        _this->current_display = index;
    2.14 +    if (index < 0 || index >= _this->num_displays) {
    2.15 +        SDL_SetError("index must be in the range 0 - %d",
    2.16 +                     _this->num_displays - 1);
    2.17 +        return -1;
    2.18 +    }
    2.19 +    _this->current_display = index;
    2.20 +    return 0;
    2.21 +}
    2.22 +
    2.23 +int
    2.24 +SDL_GetCurrentVideoDisplay(void)
    2.25 +{
    2.26 +    if (!_this) {
    2.27 +        SDL_UninitializedVideo();
    2.28 +        return (-1);
    2.29      }
    2.30      return _this->current_display;
    2.31  }