A; you should wait until you receive an expose
event before you draw. Expose events are covered in the section
called Expose Events.
Like GdkWindow, a GdkPixmap is merely a client-side
handle for an object located on the X server. Because of
this, some things are entirely infeasible from a
performance point of view; notably, if you are doing
anything which requires significant manipulation of
individual pixels, drawables will be far too slow. On the
other hand, copying a pixmap to a window is not as slow as
you might think, because both objects are on the same
machine.
Creating a pixmap is much easier than creating a window,
because most of the window attributes are not relevant to
pixmaps. The function is
gdk_pixmap_new() (Figure 4). It accepts
an initial size, and a bit depth. If a depth of -1 is given, the depth is copied
from its GdkWindow
argument. You can't choose an arbitrary number for the
depth---the server will not support all depths, and the
pixmap's depth must match the depth of any windows you plan
to copy it to. To destroy a pixmap, call gdk_pixmap_unref().
The GdkWindow argument to
gdk_pixmap_new() may not seem
strictly necessary. However, the function wraps XCreatePixmap(), which takes an X window as
an argument. It uses this argument to determine which screen to create the window on; some
X servers have multiple displays. Screens are an Xlib
concept totally concealed by GDK; GDK supports only one
screen at a time. Thus the
window argument to
gdk_pixmap_new() seems mysterious from a GDK point of
view.
#include <gdk/gdk.h>
GdkPixmap* gdk_pixmap_new(GdkWindow* window, gint width, gint height, gint depth);
GdkPixmap* gdk_pixmap_new(GdkWindow* window, gint width, gint height, gint depth);
GdkPixmap* gdk_pixmap_new
void
gdk_pixmap_unref(GdkPixmap* pixmap);
void
gdk_pixmap_unref(GdkPixmap* pixmap);
void
gdk_pixmap_unref
Figure 4. GdkPixmap
Constructor