# HG changeset patch # User Sam Lantinga # Date 1146974568 0 # Node ID 8d3ca155c396eee3f6b41500da8e6640e114e5d9 # Parent 1632155c67e5dc990d0675a14e86010587a84b6d Fixed bug #217 Sort the DirectX video modes largest to smallest diff -r 1632155c67e5 -r 8d3ca155c396 src/video/windib/SDL_dibvideo.c --- a/src/video/windib/SDL_dibvideo.c Sun May 07 03:44:58 2006 +0000 +++ b/src/video/windib/SDL_dibvideo.c Sun May 07 04:02:48 2006 +0000 @@ -348,7 +348,6 @@ #endif } /* Sort the mode lists */ - if( i > 1 ) for ( i=0; i 0 ) { SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); @@ -361,7 +360,7 @@ // because SDL surface conversion is much faster than the WinCE one. // Although it should be tested on devices with graphics accelerator. - DIB_AddMode(this, vformat->BitsPerPixel, + DIB_AddMode(this, vformat->BitsPerPixel, GetDeviceCaps(GetDC(NULL), HORZRES), GetDeviceCaps(GetDC(NULL), VERTRES)); diff -r 1632155c67e5 -r 8d3ca155c396 src/video/windx5/SDL_dx5video.c --- a/src/video/windx5/SDL_dx5video.c Sun May 07 03:44:58 2006 +0000 +++ b/src/video/windx5/SDL_dx5video.c Sun May 07 04:02:48 2006 +0000 @@ -636,6 +636,16 @@ DX5_Available, DX5_CreateDevice }; +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 b->h - a->h; + else + return b->w - a->w; +} + static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) { SDL_VideoDevice *this = (SDL_VideoDevice *)udata; @@ -955,6 +965,10 @@ SDL_modelist[i][j] = &rect->r; } SDL_modelist[i][j] = NULL; + + if ( SDL_nummodes[i] > 0 ) { + SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); + } } /* Fill in some window manager capabilities */ diff -r 1632155c67e5 -r 8d3ca155c396 src/video/x11/SDL_x11modes.c --- a/src/video/x11/SDL_x11modes.c Sun May 07 03:44:58 2006 +0000 +++ b/src/video/x11/SDL_x11modes.c Sun May 07 04:02:48 2006 +0000 @@ -617,7 +617,7 @@ } /* sort the mode list descending as SDL expects */ - qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist); + SDL_qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist); SDL_modelist[i] = NULL; /* terminator */ use_xrandr = xrandr_major * 100 + xrandr_minor;