[cairo] Xlib and XCopyArea

Daniel Amelang daniel.amelang at gmail.com
Fri Feb 9 12:40:12 PST 2007

On 2/9/07, Olivier Jolet <olivier.jolet at skynet.be> wrote:
> I'm a new user of Cairo. I can draw and display directly into the drawable
> created by XcreateSimpleWindow; but now, I'm trying to draw into a Pixmap
> with XcreatePixmap and then display it in the window...
> ...
>   drawable = XCreatePixmap (dpy, rootwin, SIZEX, SIZEY, DefaultDepth (dpy,
> screen));
>   surface = cairo_xlib_surface_create (dpy, drawable, DefaultVisual (dpy,
> screen), SIZEX, SIZEY);
>   cairo_xlib_surface_set_size (surface, SIZEX, SIZEY);
>   paint(surface);             /* just draw un circle *
>   XCopyArea(dpy, drawable, window, gc, 0, 0, SIZEX, SIZEY, 0, 0);

This is how I would do it:

1) after you create the X window, make a cairo xlib surface with it
2) call cairo_surface_create_similar with the new cairo xlib surface
to create your offscreen surface
3) use cairo to draw on the offscreen surface
4) when you're ready to draw on the actual window, call
cairo_set_source_surface with the offscreen surface then call

But I don't know exactly what you want to do with all this, so I may be wrong.

If you're still feeling lost, these might help:



More information about the cairo mailing list