Video modes are sorted width first, then height
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Nov 2004 21:25:42 +0000
changeset 966 f72cc0c7305f
parent 965 b68e551205e9
child 967 cda407d627a3
Video modes are sorted width first, then height
src/video/dga/SDL_dgavideo.c
src/video/photon/SDL_ph_modes.c
src/video/riscos/SDL_riscosFullScreenVideo.c
src/video/windib/SDL_dibvideo.c
src/video/x11/SDL_x11modes.c
--- a/src/video/dga/SDL_dgavideo.c	Fri Nov 12 21:24:46 2004 +0000
+++ b/src/video/dga/SDL_dgavideo.c	Fri Nov 12 21:25:42 2004 +0000
@@ -284,15 +284,15 @@
     /* Prefer DirectColor visuals for otherwise equal modes */
     if ( (a->viewportWidth == b->viewportWidth) &&
          (b->viewportHeight == a->viewportHeight) ) {
-         if ( a->visualClass == DirectColor )
-             return -1;
-         if ( b->visualClass == DirectColor )
-             return 1;
-         return 0;
+        if ( a->visualClass == DirectColor )
+            return -1;
+        if ( b->visualClass == DirectColor )
+            return 1;
+        return 0;
+    } else if ( a->viewportWidth == b->viewportWidth ) {
+        return b->viewportHeight - a->viewportHeight;
     } else {
-        if(a->viewportWidth > b->viewportWidth)
-            return -1;
-        return b->viewportHeight - a->viewportHeight;
+        return b->viewportWidth - a->viewportWidth;
     }
 }
 static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode)
--- a/src/video/photon/SDL_ph_modes.c	Fri Nov 12 21:24:46 2004 +0000
+++ b/src/video/photon/SDL_ph_modes.c	Fri Nov 12 21:25:42 2004 +0000
@@ -38,34 +38,26 @@
 
 static int compare_modes_by_res(const void* mode1, const void* mode2)
 {
-    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
-    {
-        return 0;
-    }
+    PgVideoModeInfo_t mode1_info;
+    PgVideoModeInfo_t mode2_info;
 
-    key1 = mode_info.width * mode_info.height;
-
-    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
+    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode1_info) < 0)
     {
         return 0;
     }
 
-    key2 = mode_info.width * mode_info.height;
+    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0)
+    {
+        return 0;
+    }
 
-    if (key1 > key2)
+    if (mode1_info.width == mode2_info.width)
     {
-        return 1;
+        return mode2_info.height - mode1_info.height;
     }
     else
     {
-        if (key1 == key2)
-        {
-           return 0;
-        }
-        else
-        {
-            return -1;
-        }
+        return mode2_info.width - mode1_info.width;
     }
 }
 
--- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Fri Nov 12 21:24:46 2004 +0000
+++ b/src/video/riscos/SDL_riscosFullScreenVideo.c	Fri Nov 12 21:25:42 2004 +0000
@@ -381,9 +381,10 @@
 {
     SDL_Rect *a = *(SDL_Rect **)va;
     SDL_Rect *b = *(SDL_Rect **)vb;
-    if(a->w > b->w)
-        return -1;
-    return b->h - a->h;
+    if(a->w == b->w)
+        return b->h - a->h;
+    else
+        return b->w - a->w;
 }
 
 static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)
--- a/src/video/windib/SDL_dibvideo.c	Fri Nov 12 21:24:46 2004 +0000
+++ b/src/video/windib/SDL_dibvideo.c	Fri Nov 12 21:25:42 2004 +0000
@@ -201,9 +201,10 @@
 {
     SDL_Rect *a = *(SDL_Rect **)va;
     SDL_Rect *b = *(SDL_Rect **)vb;
-    if(a->w > b->w)
-        return -1;
-    return b->h - a->h;
+    if ( a->w == b->w )
+        return b->h - a->h;
+    else
+        return b->w - a->w;
 }
 
 static int DIB_AddMode(_THIS, int bpp, int w, int h)
--- a/src/video/x11/SDL_x11modes.c	Fri Nov 12 21:24:46 2004 +0000
+++ b/src/video/x11/SDL_x11modes.c	Fri Nov 12 21:25:42 2004 +0000
@@ -85,9 +85,10 @@
 {
     const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va;
     const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb;
-    if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) )
-        return -1;
-    return b->hdisplay - a->hdisplay;
+    if ( a->hdisplay == b->hdisplay )
+        return b->vdisplay - a->vdisplay;
+    else
+        return b->hdisplay - a->hdisplay;
 }
 #endif