Date: 28 Jun 2003 22:42:52 +0100

From: Alan Swanson
Subject: Re: [SDL] New XFree 4.3 Video Mode Patch

I have a wee amendment that moves the qsort in set_best_resolution
to only occur after failing to find an exact match only. This would
make absolutely sure we get a user set mode.

While I've never had any problems for my normal resolutions (1280x1024,
1024x768, 800x600 & 640,480) while closely examining the output from
qsort I've noticed it doesn't seem to sort the modes fully. These is
one definite wrong at 1152x768 and a few that just look wrong to me.

From a program (attached) I made to examine this more easily. X has
sorted its mode list using the same method as ours (plus frequency),
and our user modes get inserted without any other movement.

On the patch I've made I've also changed cmpmodes to sort on vertical
resolution and then horizontal. Ie vertical is now most significant
bit.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40642
This commit is contained in:
Sam Lantinga 2003-06-28 21:52:26 +00:00
parent 01983c1d04
commit 3f73ea75d2

View file

@ -85,9 +85,9 @@ 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->hdisplay > b->hdisplay)
if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) )
return -1;
return b->vdisplay - a->vdisplay;
return b->hdisplay - a->hdisplay;
}
#endif
@ -105,9 +105,8 @@ static void set_best_resolution(_THIS, int width, int height)
if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) &&
SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){
qsort(modes, nmodes, sizeof *modes, cmpmodes);
#ifdef XFREE86_DEBUG
printf("Available modes (sdl):\n");
printf("Available modes (unsorted):\n");
for ( i = 0; i < nmodes; ++i ) {
printf("Mode %d: %d x %d @ %d\n", i,
modes[i]->hdisplay, modes[i]->vdisplay,
@ -120,6 +119,7 @@ static void set_best_resolution(_THIS, int width, int height)
(modes[i]->vdisplay == height) )
goto match;
}
qsort(modes, nmodes, sizeof *modes, cmpmodes);
for ( i = nmodes-1; i >= 0 ; i-- ) {
if ( ! best_width ) {
if ( (modes[i]->hdisplay >= width) &&
@ -352,7 +352,7 @@ int X11_GetVideoModes(_THIS)
SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) {
#ifdef XFREE86_DEBUG
printf("Available modes (x11):\n");
printf("Available modes: (sorted)\n");
for ( i = 0; i < nmodes; ++i ) {
printf("Mode %d: %d x %d @ %d\n", i,
modes[i]->hdisplay, modes[i]->vdisplay,