Commit 9dd9471d authored by Sam Lantinga's avatar Sam Lantinga

Video modes are sorted width first, then height

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40967
parent 4cf94e33
...@@ -284,15 +284,15 @@ static int cmpmodes(const void *va, const void *vb) ...@@ -284,15 +284,15 @@ static int cmpmodes(const void *va, const void *vb)
/* Prefer DirectColor visuals for otherwise equal modes */ /* Prefer DirectColor visuals for otherwise equal modes */
if ( (a->viewportWidth == b->viewportWidth) && if ( (a->viewportWidth == b->viewportWidth) &&
(b->viewportHeight == a->viewportHeight) ) { (b->viewportHeight == a->viewportHeight) ) {
if ( a->visualClass == DirectColor ) if ( a->visualClass == DirectColor )
return -1;
if ( b->visualClass == DirectColor )
return 1;
return 0;
} else {
if(a->viewportWidth > b->viewportWidth)
return -1; return -1;
if ( b->visualClass == DirectColor )
return 1;
return 0;
} else if ( a->viewportWidth == b->viewportWidth ) {
return b->viewportHeight - a->viewportHeight; return b->viewportHeight - a->viewportHeight;
} else {
return b->viewportWidth - a->viewportWidth;
} }
} }
static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode) static void UpdateHWInfo(_THIS, SDL_NAME(XDGAMode) *mode)
......
...@@ -38,34 +38,26 @@ SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; ...@@ -38,34 +38,26 @@ SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
static int compare_modes_by_res(const void* mode1, const void* mode2) 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; return 0;
} }
key1 = mode_info.width * mode_info.height; if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0)
if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
{ {
return 0; return 0;
} }
key2 = mode_info.width * mode_info.height; if (mode1_info.width == mode2_info.width)
if (key1 > key2)
{ {
return 1; return mode2_info.height - mode1_info.height;
} }
else else
{ {
if (key1 == key2) return mode2_info.width - mode1_info.width;
{
return 0;
}
else
{
return -1;
}
} }
} }
......
...@@ -381,9 +381,10 @@ static int cmpmodes(const void *va, const void *vb) ...@@ -381,9 +381,10 @@ static int cmpmodes(const void *va, const void *vb)
{ {
SDL_Rect *a = *(SDL_Rect **)va; SDL_Rect *a = *(SDL_Rect **)va;
SDL_Rect *b = *(SDL_Rect **)vb; SDL_Rect *b = *(SDL_Rect **)vb;
if(a->w > b->w) if(a->w == b->w)
return -1; return b->h - a->h;
return b->h - a->h; else
return b->w - a->w;
} }
static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)
......
...@@ -201,9 +201,10 @@ static int cmpmodes(const void *va, const void *vb) ...@@ -201,9 +201,10 @@ static int cmpmodes(const void *va, const void *vb)
{ {
SDL_Rect *a = *(SDL_Rect **)va; SDL_Rect *a = *(SDL_Rect **)va;
SDL_Rect *b = *(SDL_Rect **)vb; SDL_Rect *b = *(SDL_Rect **)vb;
if(a->w > b->w) if ( a->w == b->w )
return -1; return b->h - a->h;
return b->h - a->h; else
return b->w - a->w;
} }
static int DIB_AddMode(_THIS, int bpp, int w, int h) static int DIB_AddMode(_THIS, int bpp, int w, int h)
......
...@@ -85,9 +85,10 @@ static int cmpmodes(const void *va, const void *vb) ...@@ -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) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va;
const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb;
if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) ) if ( a->hdisplay == b->hdisplay )
return -1; return b->vdisplay - a->vdisplay;
return b->hdisplay - a->hdisplay; else
return b->hdisplay - a->hdisplay;
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment