Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Jun 28, 2003
1 parent 055c8dd commit 14d9c12
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/video/x11/SDL_x11modes.c
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -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) &&
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 14d9c12

Please sign in to comment.