Doxygen Source Code Documentation
xxx.c File Reference
Go to the source code of this file.
Functions | |
| void | xxx_get_colormap (Display *display, Window w, XColor **xcar, int *ncar) |
Function Documentation
|
||||||||||||||||||||
|
Definition at line 7 of file xxx.c. References display, and malloc.
00008 {
00009 Status sss ;
00010 XWindowAttributes xwat ;
00011 XColor * xcol ;
00012 VisualID vid ;
00013 XVisualInfo vinfo , * vin ;
00014 int count , ii ;
00015
00016 sss = XGetWindowAttributes( display , w , &xwat ) ;
00017 if( sss == 0 ){ *xcar = NULL ; *ncar = 0 ; return ; }
00018
00019 vinfo.visualid = vid = XVisualIDFromVisual(xwat.visual) ;
00020 vin = XGetVisualInfo( display , VisualIDMask , &vinfo , &count ) ;
00021 if( count == 0 || vin == NULL ){ *xcar = NULL ; *ncar = 0 ; return ; }
00022
00023 #if defined(__cplusplus) || defined(c_plusplus)
00024 if( vin->c_class != PseudoColor ){ XFree(vin) ; *xcar = NULL ; *ncar = 0 ; return ; }
00025 #else
00026 if( vin->class != PseudoColor ){ XFree(vin) ; *xcar = NULL ; *ncar = 0 ; return ; }
00027 #endif
00028
00029 count = vin->colormap_size ;
00030 xcol = (XColor *) malloc( sizefo(XColor) * count ) ;
00031 for( ii=0 ; ii < count ; ii++ ) xcol[ii].pixel = (Pixel) ii ;
00032
00033 XQueryColors( display , xwat.colormap , xcol , count ) ;
00034
00035 fprintf(stderr,"xxx_get_colormap: found %d colors:\n",count) ;
00036 for( ii=0 ; ii < count ; ii++ )
00037 fprintf(stderr," %3d: r = %x g = %x b = %x\n" ,
00038 ii , (int)xcol[ii].red , (int)xcol[ii].green , (int)xcol[ii].blue ) ;
00039
00040 *xcar = xcol ; *ncar = count ; XFree(vin) ; return ;
00041 }
|