Mercurial > sdl-ios-xcode
diff src/video/x11/SDL_x11modes.c @ 641:df178851293b
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 28 Jun 2003 21:52:26 +0000 |
parents | 6862d4294870 |
children | 7c8deec1659c |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11modes.c Sat Jun 28 21:38:14 2003 +0000 +++ b/src/video/x11/SDL_x11modes.c Sat Jun 28 21:52:26 2003 +0000 @@ -85,9 +85,9 @@ { 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 @@ 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 @@ (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 @@ 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,