From d582fadc97d043656dde92362c3437de21f08b11 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 12 Nov 2004 21:25:42 +0000 Subject: [PATCH] Video modes are sorted width first, then height --- src/video/dga/SDL_dgavideo.c | 14 ++++++------ src/video/photon/SDL_ph_modes.c | 24 +++++++------------- src/video/riscos/SDL_riscosFullScreenVideo.c | 7 +++--- src/video/windib/SDL_dibvideo.c | 7 +++--- src/video/x11/SDL_x11modes.c | 7 +++--- 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/video/dga/SDL_dgavideo.c b/src/video/dga/SDL_dgavideo.c index 5f28aca6a..ac1b5723b 100644 --- a/src/video/dga/SDL_dgavideo.c +++ b/src/video/dga/SDL_dgavideo.c @@ -284,15 +284,15 @@ static int cmpmodes(const void *va, const void *vb) /* 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; - } else { - if(a->viewportWidth > b->viewportWidth) + 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 { + return b->viewportWidth - a->viewportWidth; } } static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode) diff --git a/src/video/photon/SDL_ph_modes.c b/src/video/photon/SDL_ph_modes.c index 2d3c444ef..e46648a8b 100644 --- a/src/video/photon/SDL_ph_modes.c +++ b/src/video/photon/SDL_ph_modes.c @@ -38,34 +38,26 @@ SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; static int compare_modes_by_res(const void* mode1, const void* mode2) { - if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) + PgVideoModeInfo_t mode1_info; + PgVideoModeInfo_t mode2_info; + + if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode1_info) < 0) { return 0; } - key1 = mode_info.width * mode_info.height; - - if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) + if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0) { return 0; } - key2 = mode_info.width * mode_info.height; - - 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; } } diff --git a/src/video/riscos/SDL_riscosFullScreenVideo.c b/src/video/riscos/SDL_riscosFullScreenVideo.c index f7fe594f8..3ad8ca6d4 100644 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c @@ -381,9 +381,10 @@ static int cmpmodes(const void *va, const void *vb) { 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) diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 13db2a2cb..22cf293a0 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -201,9 +201,10 @@ static int cmpmodes(const void *va, const void *vb) { 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) diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index f3720fec3..cf0bb2033 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -85,9 +85,10 @@ static int cmpmodes(const void *va, const void *vb) { 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