Video modes are sorted width first, then height
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Nov 2004 21:25:42 +0000
changeset 966f72cc0c7305f
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
     1.1 --- a/src/video/dga/SDL_dgavideo.c	Fri Nov 12 21:24:46 2004 +0000
     1.2 +++ b/src/video/dga/SDL_dgavideo.c	Fri Nov 12 21:25:42 2004 +0000
     1.3 @@ -284,15 +284,15 @@
     1.4      /* Prefer DirectColor visuals for otherwise equal modes */
     1.5      if ( (a->viewportWidth == b->viewportWidth) &&
     1.6           (b->viewportHeight == a->viewportHeight) ) {
     1.7 -         if ( a->visualClass == DirectColor )
     1.8 -             return -1;
     1.9 -         if ( b->visualClass == DirectColor )
    1.10 -             return 1;
    1.11 -         return 0;
    1.12 +        if ( a->visualClass == DirectColor )
    1.13 +            return -1;
    1.14 +        if ( b->visualClass == DirectColor )
    1.15 +            return 1;
    1.16 +        return 0;
    1.17 +    } else if ( a->viewportWidth == b->viewportWidth ) {
    1.18 +        return b->viewportHeight - a->viewportHeight;
    1.19      } else {
    1.20 -        if(a->viewportWidth > b->viewportWidth)
    1.21 -            return -1;
    1.22 -        return b->viewportHeight - a->viewportHeight;
    1.23 +        return b->viewportWidth - a->viewportWidth;
    1.24      }
    1.25  }
    1.26  static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode)
     2.1 --- a/src/video/photon/SDL_ph_modes.c	Fri Nov 12 21:24:46 2004 +0000
     2.2 +++ b/src/video/photon/SDL_ph_modes.c	Fri Nov 12 21:25:42 2004 +0000
     2.3 @@ -38,34 +38,26 @@
     2.4  
     2.5  static int compare_modes_by_res(const void* mode1, const void* mode2)
     2.6  {
     2.7 -    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
     2.8 +    PgVideoModeInfo_t mode1_info;
     2.9 +    PgVideoModeInfo_t mode2_info;
    2.10 +
    2.11 +    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode1_info) < 0)
    2.12      {
    2.13          return 0;
    2.14      }
    2.15  
    2.16 -    key1 = mode_info.width * mode_info.height;
    2.17 -
    2.18 -    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
    2.19 +    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0)
    2.20      {
    2.21          return 0;
    2.22      }
    2.23  
    2.24 -    key2 = mode_info.width * mode_info.height;
    2.25 -
    2.26 -    if (key1 > key2)
    2.27 +    if (mode1_info.width == mode2_info.width)
    2.28      {
    2.29 -        return 1;
    2.30 +        return mode2_info.height - mode1_info.height;
    2.31      }
    2.32      else
    2.33      {
    2.34 -        if (key1 == key2)
    2.35 -        {
    2.36 -           return 0;
    2.37 -        }
    2.38 -        else
    2.39 -        {
    2.40 -            return -1;
    2.41 -        }
    2.42 +        return mode2_info.width - mode1_info.width;
    2.43      }
    2.44  }
    2.45  
     3.1 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Fri Nov 12 21:24:46 2004 +0000
     3.2 +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c	Fri Nov 12 21:25:42 2004 +0000
     3.3 @@ -381,9 +381,10 @@
     3.4  {
     3.5      SDL_Rect *a = *(SDL_Rect **)va;
     3.6      SDL_Rect *b = *(SDL_Rect **)vb;
     3.7 -    if(a->w > b->w)
     3.8 -        return -1;
     3.9 -    return b->h - a->h;
    3.10 +    if(a->w == b->w)
    3.11 +        return b->h - a->h;
    3.12 +    else
    3.13 +        return b->w - a->w;
    3.14  }
    3.15  
    3.16  static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)
     4.1 --- a/src/video/windib/SDL_dibvideo.c	Fri Nov 12 21:24:46 2004 +0000
     4.2 +++ b/src/video/windib/SDL_dibvideo.c	Fri Nov 12 21:25:42 2004 +0000
     4.3 @@ -201,9 +201,10 @@
     4.4  {
     4.5      SDL_Rect *a = *(SDL_Rect **)va;
     4.6      SDL_Rect *b = *(SDL_Rect **)vb;
     4.7 -    if(a->w > b->w)
     4.8 -        return -1;
     4.9 -    return b->h - a->h;
    4.10 +    if ( a->w == b->w )
    4.11 +        return b->h - a->h;
    4.12 +    else
    4.13 +        return b->w - a->w;
    4.14  }
    4.15  
    4.16  static int DIB_AddMode(_THIS, int bpp, int w, int h)
     5.1 --- a/src/video/x11/SDL_x11modes.c	Fri Nov 12 21:24:46 2004 +0000
     5.2 +++ b/src/video/x11/SDL_x11modes.c	Fri Nov 12 21:25:42 2004 +0000
     5.3 @@ -85,9 +85,10 @@
     5.4  {
     5.5      const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va;
     5.6      const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb;
     5.7 -    if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) )
     5.8 -        return -1;
     5.9 -    return b->hdisplay - a->hdisplay;
    5.10 +    if ( a->hdisplay == b->hdisplay )
    5.11 +        return b->vdisplay - a->vdisplay;
    5.12 +    else
    5.13 +        return b->hdisplay - a->hdisplay;
    5.14  }
    5.15  #endif
    5.16