[Xcb] xpyb and pycairo

Donald Ephraim Curtis dcurtis at cs.uiowa.edu
Thu Jul 23 00:41:49 PDT 2009


I am relatively new to xcb and xorg programming so I apologize if I
don't use the right terminology here.

I went through and to get a feel for xcb I wrote a program in Python
that uses libxcb through ctypes.  I had many reasons for this and we can
skip the discussion of whether this was smart or not.

But now I feeling at least comfortable enough to use a xpyb but I want
to continue to use cairo.  As I see it pycairo doesn't currently have a
way to take a xpyb connection object and create a surface.

As a side note this makes me think that it's more of a Cairo issue
(specifically pycairo) and not a xpyb issue.

Regardless, has anyone else here tried this?

My biggest concern is to be able to use nicer fonts (DejaVu Sans 8) and
also to be able to draw translucent images (shading of the drawing).  If
there is a different library that would work better i'd be happy to use
it.


Another part of this is that I'm curious if someone can explain what the
main differences between imlib2, xft, cairo, pango.  From what I
understand, cairo is the only library which currently supports XCB
drawables.  What I don't quite understand is that isn't the Xorg server
where everything lives?  So shouldn't a pixmap id be the same whether
I'm using xcb or xlib?  If this is true, then if imlib can create
pixmaps and read pixmaps, shouldn't it not matter what what library you
use, be it xlib or xcb?  I guess maybe I don't understand where these
pixmaps exist.

to better explain my understanding this is the imlib example code i'm
looking at where rpm is holding the root pixel map id.

imlib_context_set_drawable(rpm);
bg = imlib_create_image_from_drawable(0, x, y, w, h, 1);

if (!bg) {
    printf("Failed to create background image in ppshade!\n");
        return Py_BuildValue("i", 0);
}

imlib_context_set_image(bg);
sprintf(filter,"tint(x=0,y=0,w=%d,h=%d,red=%d,green=%d,blue=%d,alpha=%d);", w,h,r,g,b,a);
imlib_apply_filter(filter);
imlib_render_pixmaps_for_whole_image(&bgpm, &mask);
XSetWindowBackgroundPixmap(dsp, panel, bgpm);
imlib_free_pixmap_and_mask(bgpm);
imlib_free_image();

what i see is that imlib copies an image from the drawable (being the
root pixmap) and then shades it and sets the panel (client window) to
this new pixmap.  Thus, couldn't I just swap out the call to
XSetWindowBackgroundPixmap with a call to xcb_change_window_attributes
where I set XCB_CW_BACK_PIXMAP?

Summary: how is a window/pixmap id in xcb different from one given by
xlib?

Am I way off here?  I appreciate any information.



More information about the Xcb mailing list