[cairo] freedesktop.org links in configure.in are wrong

Jamey Sharp jamey at minilop.net
Fri May 13 11:21:59 PDT 2005

On Thu, 2005-05-12 at 23:35 -0700, Carl Worth wrote:
> I thought this would be worth cleaning up before 0.5, (though I really
> need to stop finding little things to do and finish it already). There
> were some obvious little updates that I had missed in recent changes
> which I've now committed.

Thanks, Carl!

> After that, I want to fix cairo-xcb.h so it has functions to match
> what we've come up with for cairo-xlib.h. In mimicking the
> implementation there, I found the following loop in
> _cairo_xlib_surface_create_internal for finding the depth for a
> particular visual:
>         /* This is ugly, but we have to walk over all visuals
>          * for the display to find the depth.
>          */
>         for (i = 0; i < ScreenCount (dpy); i++) {
>             Screen *screen = ScreenOfDisplay (dpy, i);
>             for (j = 0; j < screen->ndepths; j++) {
>                 Depth *depth = &screen->depths[j];
>                 for (k = 0; k < depth->nvisuals; k++) {
>                     if (&depth->visuals[k] == visual)
>                         surface->depth = depth->depth;
>                     goto found;
>                 }
>             }
>         }
> Could you provide the XCB analogue for this function? I notice you
> have things like XCBSCREENIter and I see I could get one from an
> XCBConnSetupSuccessRep, but I'm not sure of the right way to get
> access to that.

There's a minor planned API change around that -- currently you get the
XCBConnSetupSuccessRep with XCBGetSetup, but Bart didn't like the name
and wanted XCBGetSetupData. (And for that matter I've never liked the
name XCBConnSetupSuccessRep, but haven't decided what to do about that.
I still haven't frozen the XCB API, so if anybody had constructive
complaints about it now would be the time to voice them.)

Here's the XCB equivalent code (taking into account Owen's fix):

        XCBSCREENIter roots = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(c));
        for(; roots.rem; XCBSCREENNext(&roots))
                XCBDEPTHIter depths = XCBSCREENAllowedDepthsIter(roots.data);
                for(; depths.rem; XCBDEPTHNext(&depths))
                        XCBVISUALTYPEIter visuals = XCBDEPTHVisualsIter(depths.data);
                        for(; visuals.rem; XCBVISUALTYPENext(&visuals))
                                if(visuals.data->visual_id.id == visual.id)
                                        surface->depth = depths.data->depth;
                                        goto found;

A couple of notes: First, isn't that symmetry pretty? ;-) The innermost
loop also could be written to loop over a C array returned by
XCBDEPTHVisuals, but I chose to use the iterator interface for
consistency; the other two loops only have iterators available. That's
because these functions return pointers directly into the blob of binary
data that the server returns at connection-setup time, unlike Xlib which
tries to transform the blob into C-friendly data structures. And just in
case there's any question: like Xlib, there's no dynamically allocated
memory to free here.

Oh, yes. The 'visual.id' and 'visual_id.id' thing might look weird. It's
a hack to C's type system; the goal is to make XIDs and other CARD32s
that have distinct types produce compile-time errors if used in the
wrong places. So types like XCBVISUALTYPE and XCBWINDOW are structures
that each contain only a CARD32. When you want to compare the values,
you have to dig the CARD32 out of the structure.

> Any guidance in XCB-xen for this task would be much appreciate.

Hope this helps. Thanks for playing with it!


More information about the cairo mailing list