comparison 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
comparison
equal deleted inserted replaced
640:3b31ef60ccbd 641:df178851293b
83 #ifdef XFREE86_VM 83 #ifdef XFREE86_VM
84 static int cmpmodes(const void *va, const void *vb) 84 static int cmpmodes(const void *va, const void *vb)
85 { 85 {
86 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va; 86 const SDL_NAME(XF86VidModeModeInfo) *a = *(const SDL_NAME(XF86VidModeModeInfo)**)va;
87 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb; 87 const SDL_NAME(XF86VidModeModeInfo) *b = *(const SDL_NAME(XF86VidModeModeInfo)**)vb;
88 if(a->hdisplay > b->hdisplay) 88 if( (a->vdisplay > b->vdisplay) && (a->hdisplay >= b->hdisplay) )
89 return -1; 89 return -1;
90 return b->vdisplay - a->vdisplay; 90 return b->hdisplay - a->hdisplay;
91 } 91 }
92 #endif 92 #endif
93 93
94 static void get_real_resolution(_THIS, int* w, int* h); 94 static void get_real_resolution(_THIS, int* w, int* h);
95 95
103 int best_width = 0, best_height = 0; 103 int best_width = 0, best_height = 0;
104 int nmodes; 104 int nmodes;
105 105
106 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) && 106 if ( SDL_NAME(XF86VidModeGetModeLine)(SDL_Display, SDL_Screen, &i, &mode) &&
107 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){ 107 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display,SDL_Screen,&nmodes,&modes)){
108 qsort(modes, nmodes, sizeof *modes, cmpmodes);
109 #ifdef XFREE86_DEBUG 108 #ifdef XFREE86_DEBUG
110 printf("Available modes (sdl):\n"); 109 printf("Available modes (unsorted):\n");
111 for ( i = 0; i < nmodes; ++i ) { 110 for ( i = 0; i < nmodes; ++i ) {
112 printf("Mode %d: %d x %d @ %d\n", i, 111 printf("Mode %d: %d x %d @ %d\n", i,
113 modes[i]->hdisplay, modes[i]->vdisplay, 112 modes[i]->hdisplay, modes[i]->vdisplay,
114 1000 * modes[i]->dotclock / (modes[i]->htotal * 113 1000 * modes[i]->dotclock / (modes[i]->htotal *
115 modes[i]->vtotal) ); 114 modes[i]->vtotal) );
118 for ( i = 0; i < nmodes ; i++ ) { 117 for ( i = 0; i < nmodes ; i++ ) {
119 if ( (modes[i]->hdisplay == width) && 118 if ( (modes[i]->hdisplay == width) &&
120 (modes[i]->vdisplay == height) ) 119 (modes[i]->vdisplay == height) )
121 goto match; 120 goto match;
122 } 121 }
122 qsort(modes, nmodes, sizeof *modes, cmpmodes);
123 for ( i = nmodes-1; i >= 0 ; i-- ) { 123 for ( i = nmodes-1; i >= 0 ; i-- ) {
124 if ( ! best_width ) { 124 if ( ! best_width ) {
125 if ( (modes[i]->hdisplay >= width) && 125 if ( (modes[i]->hdisplay >= width) &&
126 (modes[i]->vdisplay >= height) ) { 126 (modes[i]->vdisplay >= height) ) {
127 best_width = modes[i]->hdisplay; 127 best_width = modes[i]->hdisplay;
350 } 350 }
351 if ( ! buggy_X11 && 351 if ( ! buggy_X11 &&
352 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) { 352 SDL_NAME(XF86VidModeGetAllModeLines)(SDL_Display, SDL_Screen,&nmodes,&modes) ) {
353 353
354 #ifdef XFREE86_DEBUG 354 #ifdef XFREE86_DEBUG
355 printf("Available modes (x11):\n"); 355 printf("Available modes: (sorted)\n");
356 for ( i = 0; i < nmodes; ++i ) { 356 for ( i = 0; i < nmodes; ++i ) {
357 printf("Mode %d: %d x %d @ %d\n", i, 357 printf("Mode %d: %d x %d @ %d\n", i,
358 modes[i]->hdisplay, modes[i]->vdisplay, 358 modes[i]->hdisplay, modes[i]->vdisplay,
359 1000 * modes[i]->dotclock / (modes[i]->htotal * 359 1000 * modes[i]->dotclock / (modes[i]->htotal *
360 modes[i]->vtotal) ); 360 modes[i]->vtotal) );