Date: 28 Jun 2003 22:42:52 +0100
authorSam Lantinga <slouken@libsdl.org>
Sat, 28 Jun 2003 21:52:26 +0000
changeset 641df178851293b
parent 640 3b31ef60ccbd
child 642 de622b7108bf
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.
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Sat Jun 28 21:38:14 2003 +0000
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Sat Jun 28 21:52:26 2003 +0000
     1.3 @@ -85,9 +85,9 @@
     1.4  {
     1.5      const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va;
     1.6      const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb;
     1.7 -    if(a->hdisplay > b->hdisplay)
     1.8 +    if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) )
     1.9          return -1;
    1.10 -    return b->vdisplay - a->vdisplay;
    1.11 +    return b->hdisplay - a->hdisplay;
    1.12  }
    1.13  #endif
    1.14  
    1.15 @@ -105,9 +105,8 @@
    1.16  
    1.17          if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) &&
    1.18               SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){
    1.19 -            qsort(modes, nmodes, sizeof *modes, cmpmodes);
    1.20  #ifdef XFREE86_DEBUG
    1.21 -            printf("Available modes (sdl):\n");
    1.22 +            printf("Available modes (unsorted):\n");
    1.23              for ( i = 0; i < nmodes; ++i ) {
    1.24                  printf("Mode %d: %d x %d @ %d\n", i,
    1.25                          modes[i]->hdisplay, modes[i]->vdisplay,
    1.26 @@ -120,6 +119,7 @@
    1.27                       (modes[i]->vdisplay == height) )
    1.28                      goto match;
    1.29              }
    1.30 +            qsort(modes, nmodes, sizeof *modes, cmpmodes);
    1.31              for ( i = nmodes-1; i >= 0 ; i-- ) {
    1.32  		if ( ! best_width ) {
    1.33                      if ( (modes[i]->hdisplay >= width) &&
    1.34 @@ -352,7 +352,7 @@
    1.35           SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) {
    1.36  
    1.37  #ifdef XFREE86_DEBUG
    1.38 -        printf("Available modes (x11):\n");
    1.39 +        printf("Available modes: (sorted)\n");
    1.40          for ( i = 0; i < nmodes; ++i ) {
    1.41              printf("Mode %d: %d x %d @ %d\n", i,
    1.42                      modes[i]->hdisplay, modes[i]->vdisplay,