Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11video.c @ 236:3f09f52ac2cc
Fixed X11 icon color allocation (thanks Mattias!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 07 Nov 2001 17:59:07 +0000 |
parents | 2a8d929f50e0 |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
235:dde0af58db4b | 236:3f09f52ac2cc |
---|---|
499 | 499 |
500 /* Free the colormap entries */ | 500 /* Free the colormap entries */ |
501 if ( SDL_XPixels ) { | 501 if ( SDL_XPixels ) { |
502 int numcolors; | 502 int numcolors; |
503 unsigned long pixel; | 503 unsigned long pixel; |
504 | |
505 numcolors = SDL_Visual->map_entries; | 504 numcolors = SDL_Visual->map_entries; |
506 for ( pixel=0; pixel<numcolors; ++pixel ) { | 505 for ( pixel=0; pixel<numcolors; ++pixel ) { |
507 while ( SDL_XPixels[pixel] > 0 ) { | 506 while ( SDL_XPixels[pixel] > 0 ) { |
508 XFreeColors(GFX_Display, | 507 XFreeColors(GFX_Display, |
509 SDL_DisplayColormap,&pixel,1,0); | 508 SDL_DisplayColormap,&pixel,1,0); |
1048 if(SDL_XPixels[best]) | 1047 if(SDL_XPixels[best]) |
1049 continue; /* already allocated, waste no more time */ | 1048 continue; /* already allocated, waste no more time */ |
1050 c = all + best; | 1049 c = all + best; |
1051 if(XAllocColor(GFX_Display, SDL_XColorMap, c)) { | 1050 if(XAllocColor(GFX_Display, SDL_XColorMap, c)) { |
1052 /* got it */ | 1051 /* got it */ |
1053 colors[best].r = c->red >> 8; | 1052 colors[c->pixel].r = c->red >> 8; |
1054 colors[best].g = c->green >> 8; | 1053 colors[c->pixel].g = c->green >> 8; |
1055 colors[best].b = c->blue >> 8; | 1054 colors[c->pixel].b = c->blue >> 8; |
1056 ++SDL_XPixels[best]; | 1055 ++SDL_XPixels[c->pixel]; |
1057 } else { | 1056 } else { |
1058 /* | 1057 /* |
1059 * The colour couldn't be allocated, probably being | 1058 * The colour couldn't be allocated, probably being |
1060 * owned as a r/w cell by another client. Flag it as | 1059 * owned as a r/w cell by another client. Flag it as |
1061 * unavailable and try again. The termination of the | 1060 * unavailable and try again. The termination of the |
1203 if ( SDL_XColorMap != SDL_DisplayColormap ) { | 1202 if ( SDL_XColorMap != SDL_DisplayColormap ) { |
1204 XFreeColormap(SDL_Display, SDL_XColorMap); | 1203 XFreeColormap(SDL_Display, SDL_XColorMap); |
1205 } | 1204 } |
1206 if ( SDL_iconcolors ) { | 1205 if ( SDL_iconcolors ) { |
1207 unsigned long pixel; | 1206 unsigned long pixel; |
1208 int numcolors = | 1207 Colormap dcmap = DefaultColormap(SDL_Display, |
1209 ((this->screen->format)->palette)->ncolors; | 1208 SDL_Screen); |
1210 for ( pixel=0; pixel<numcolors; ++pixel ) { | 1209 for(pixel = 0; pixel < 256; ++pixel) { |
1211 while ( SDL_iconcolors[pixel] > 0 ) { | 1210 while(SDL_iconcolors[pixel] > 0) { |
1212 XFreeColors(SDL_Display, | 1211 XFreeColors(GFX_Display, |
1213 SDL_DisplayColormap,&pixel,1,0); | 1212 dcmap, &pixel, 1, 0); |
1214 --SDL_iconcolors[pixel]; | 1213 --SDL_iconcolors[pixel]; |
1215 } | 1214 } |
1216 } | 1215 } |
1217 free(SDL_iconcolors); | 1216 free(SDL_iconcolors); |
1218 SDL_iconcolors = NULL; | 1217 SDL_iconcolors = NULL; |