changeset 1963:2590b68531ef

Added SDL_GetCurrentVideoDisplay()
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Aug 2006 03:20:52 +0000
parents c92e5f3e68d9
children 071b6598d48f
files include/SDL_video.h src/video/SDL_video.c
diffstat 2 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_video.h	Sun Jul 30 08:09:20 2006 +0000
+++ b/include/SDL_video.h	Wed Aug 02 03:20:52 2006 +0000
@@ -403,13 +403,24 @@
  *
  * \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);
+
+/**
+ * \fn int SDL_GetCurrentVideoDisplay(void)
+ *
+ * \brief Get the index of the currently selected display.
+ *
  * \return The index of the currently selected display.
  *
- * \note You can query the currently selected display by passing an index of -1.
- *
  * \sa SDL_GetNumVideoDisplays()
+ * \sa SDL_SelectVideoDisplay()
  */
-extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index);
+extern DECLSPEC int SDLCALL SDL_GetCurrentVideoDisplay(void);
 
 /**
  * \fn int SDL_GetNumDisplayModes(void)
--- a/src/video/SDL_video.c	Sun Jul 30 08:09:20 2006 +0000
+++ b/src/video/SDL_video.c	Wed Aug 02 03:20:52 2006 +0000
@@ -355,13 +355,21 @@
         SDL_UninitializedVideo();
         return (-1);
     }
-    if (index >= 0) {
-        if (index >= _this->num_displays) {
-            SDL_SetError("index must be in the range 0 - %d",
-                         _this->num_displays - 1);
-            return -1;
-        }
-        _this->current_display = index;
+    if (index < 0 || index >= _this->num_displays) {
+        SDL_SetError("index must be in the range 0 - %d",
+                     _this->num_displays - 1);
+        return -1;
+    }
+    _this->current_display = index;
+    return 0;
+}
+
+int
+SDL_GetCurrentVideoDisplay(void)
+{
+    if (!_this) {
+        SDL_UninitializedVideo();
+        return (-1);
     }
     return _this->current_display;
 }