6.3 Regions
An X region is an arbitrary set of pixels on
the screen. But usually a region is either a rectangular area, several
overlapping or adjacent rectangular areas, or a general polygon. Regions
are chiefly used to set the clip_mask member of the
GC. XSetRegion() sets the
clip_mask to a region so that output will occur only
within the region. Using XSetRegion() is a lot easier
than defining a single-plane pixmap with the desired size and shape and
then using that bitmap to set the clip_mask with
XSetClipMask(), and it is more flexible than the
clip_mask you can set with
XSetClipRectangles().
The most common use of setting the clip_mask to
a region is to combine the rectangle from each of multiple contiguous
Expose events on a single window into a single region
and clip the redrawing to that region. This provides a performance
improvement in some situations. See 3.2.13.1 Repainting the Window for more information and an
example.
A region has an x and y offset, which is used internally when
making calculations with regions (offsets for all regions have a common
origin). The offset has an effect if the region is used as a
clip_mask. When making a graphics request with the
clip_mask of the GC set with
XSetRegion(), the offset of the region is added to
clip_x_origin and clip_y_origin to
determine the placement of the region relative to the destination
drawable.
Regions can be created with XCreateRegion() or
XPolygonRegion(). XCreateRegion() creates an empty region to which rectangles ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access