16.7 Determining the Appropriate Visual Type

A single display can support multiple screens. Each screen can have several different visual types supported at different depths. You can use the functions described in this section to determine which visual to use for your application.

The functions in this section use the visual information masks and the XVisualInfo structure, which is defined in X11/Xutil.h and contains:


/* Visual information mask bits */

#define VisualNoMask		0x0
#define VisualIDMask		0x1
#define VisualScreenMask	0x2
#define VisualDepthMask		0x4
#define VisualClassMask		0x8
#define VisualRedMaskMask	0x10
#define VisualGreenMaskMask	0x20
#define VisualBlueMaskMask	0x40
#define VisualColormapSizeMask	0x80
#define VisualBitsPerRGBMask	0x100
#define VisualAllMask		0x1FF

/* Values */

typedef struct {
	Visual *visual;
	VisualID visualid;
	int screen;
	unsigned int depth;
	int class;
	unsigned long red_mask;
	unsigned long green_mask;
	unsigned long blue_mask;
	int colormap_size;
	int bits_per_rgb;
} XVisualInfo;

To obtain a list of visual information structures that match a specified template, use XGetVisualInfo().

To obtain the visual information that matches the specified depth and class of the screen, use XMatchVisualInfo().

Next: Manipulating Images

Christophe Tronche, ch@tronche.com