7.6 Getting Complete Visual Information
As mentioned earlier, some systems define more than one visual.
The default visual might not be the most appropriate for your
application. Moreover, the visual found using the technique described in
7.4.2 Code to Allocate Read-only Colors using
XMatchVisualInfo()
is fine for applications with
routine color needs but is not necessarily the best. As you may recall,
XMatchVisualInfo()
returns a single visual
arbitrarily selected from the list that matches the passed visual class
and depth. The most thorough method is to get a complete list of visual
information for every available visual, using
XGetVisualInfo()
, and then choose from
these.
XGetVisualInfo()
returns a list of visual
structures that match the attributes specified by template and mask
arguments. The template is an XVisualInfo
structure
with members set to the required values, and the mask indicates which
members are matched with the list of available visuals. By passing an
empty template structure, you can get a complete list of
XVisualInfo
structures.
7.6.1 The XVisualInfo Structure
The XVisualInfo
structure returns information
about the available visuals. It is used both to select a visual type
from those available and as a source of information while using a
particular visual.
The XVisualInfo
structure is shown in Example 7-9.
Example 7-9. The XVisualInfo structure
typedef struct { Visual *visual; VisualID visualid; int screen_num; unsigned int depth; int class; unsigned long red_mask; ...
Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.