If a window has been obscured then we will have to redraw the window when it gets reexposed.
This means that we may have to go through all the drawing function calls that have previously been used to render our drawing. This will be cumbersome and may involve some complicated storage methods.
Fortunately, X provides a mechanism that overcomes this (and other) problem.
A Pixmap is an off-screen Drawable area.
We can draw to Pixmap in the same way as we draw to a Window.
However no immediate display effect will occur in our window. To do this we must copy the Pixmap to a Window.
The program draw2.c draws to pixmaps instead of the window. NOTE: the effect of an exposure on draw.c and draw2.c.
To create a Pixmap use the XCreatePixmap() function. This function takes 5 arguments and returns a Pixmap structure:
When you have finished using a Pixmap it is a good idea to free the memory in which it has been stored by calling:
If you want to clear a Pixmap (not done automatically) use XFillRectangle().
To copy a Pixmap onto another Pixmap or a Window use:
XCopyArea(Display *display, Drawable source, Drawable destination, GC gc, int src_x, src_y, int width, int height, int dest_x, int dest_y)
where (src_x, src_y) specify the coordinates in the source pixmap where copy starts, width and height specify dimensions of copied area and (dest_x, dest_y) are the start coordinates in the destination where pixels are placed.