[Xcb] xpyb and pycairo
Barton C Massey
bart at cs.pdx.edu
Wed Jul 22 14:34:41 PDT 2009
Glad to see you getting started! I'm not a Python guy and
thus can't answer most of your questions. The Xlib/XCB
thing, though, I think I can.
In principle, Cairo has an XCB backend for rendering. In
practice, last I heard it didn't actually work. So Cairo
drawing is normally done using Xlib under the hood to
generate X protocol.
You are correct that the xids (e.g. pixmap ids) used by XCB
and Xlib are essentially the server's business, and can
intermigrate. Further, we have arranged things with Xlib
and XCB such that you can freely mix XCB calls from your
application with the Xlib calls made by Cairo to render your
stuff. The only real trick is getting an XCB connection
object from the Xlib display object; there's a routine in
XCB for this, but you have to get your hands on the display
first.
xft is a font rendering thing, and pango is a text rendering
thing atop xft. imlib2 is a raster image processing
library. cairo is a drawing library. So they all do
different things, really.
Hope this helps.
Bart
In message <20090723074149.GB5127 at cs.uiowa.edu> you wrote:
> 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.
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
More information about the Xcb
mailing list