[Xcb] some questions and remarks

Jamey Sharp jamey at minilop.net
Thu Sep 29 17:19:22 PDT 2005


On Thu, 2005-09-29 at 22:29 +0200, Vincent Torri wrote:
> Hey,

Hi Vincent!

> > > 1) For the QueryTree stuff, there is no Next() or End() functions. Is it
> > > normal ?
> >
> > I don't understand. There are XCBWINDOWNext and XCBWINDOWEnd functions,
> > which you should be able to use with the XCBWINDOWIter that you get from
> > XCBQueryTreeChildrenIter.
> 
> I thought that, when there is a *Iter function, an *Next function should
> exist. But, in fact, it's not the case. I need to iterate on the children.
> So, i've used:
> 
>   children = XCBQueryTreeChildren (rep);
>   children_end = children + XCBQueryTreeChildrenLength (rep);
>   for (; children != children_end; ++children)
>     {
>       ***
>       ***
>     }

That's a perfectly valid way to do it. If you want to use the iterator
interface instead, you can do that too, using XCBQueryTreeChildrenIter
together with XCBWINDOWNext.

> > What do you need it for? Remember that the cookie returned by every
> > request contains the sequence number of that request.
> 
> don't know. xcompmgr calls that function. I'll need to dig a bit to
> understand what it does.

Fair enough. Post to the list when you figure out why XNextRequest is
being used.

> > I don't entirely understand the question, but I'm pretty sure I've
> > written the code you want already. It's in
> > cairo/src/cairo-xcb-surface.c, in the functions format_from_visual and
> > _format_from_cairo (depending on how you want to select picture
> > formats).
> 
> I've see what you've done in cairo. It's exactly the same than what I did.
> 
> BUT (always a but) it returns ONLY the xid of the XCBRenderPICTFORMAT.

Ah, I see. You want to combine format_from_visual and
_format_from_cairo, sort of. The thing to understand is that
RenderQueryPictFormats returns multiple lists. You've looked at the
Screens list, but there's also the Formats list, and that one contains
all of the PICTFORMINFOs.

This code should do what you need, though I'm writing it off the top of
my head (using the Cairo code as a reference) and haven't tested it at
all.


/* Find the first PICTFORMAT that matches the given VISUALID. */
XCBRenderPICTFORMAT _format_from_visual(XCBRenderQueryPictFormatsRep *r,
	XCBVISUALID visual)
{
        static const XCBRenderPICTFORMAT nil;
        XCBRenderPICTSCREENIter si;
        XCBRenderPICTDEPTHIter di;
        XCBRenderPICTVISUALIter vi;
        
        for(si = XCBRenderQueryPictFormatsScreensIter(r); si.rem; XCBRenderPICTSCREENNext(&si))
                for(di = XCBRenderPICTSCREENDepthsIter(si.data); di.rem; XCBRenderPICTDEPTHNext(&di))
                        for(vi = XCBRenderPICTDEPTHVisualsIter(di.data); vi.rem; XCBRenderPICTVISUALNext(&vi))
                                if(vi.data->visual.id == visual.id)
                                        return vi.data->format;
        return nil;
}

/* Find the first PICTFORMINFO for the first PICTFORMAT that matches the
given VISUALID. */
XCBRenderPICTFORMINFO XCBAuxRenderFindVisualFormat(XCBConnection *c,
	XCBVISUALID visual)
{
        XCBRenderPICTFORMAT format;
        XCBRenderPICTFORMINFO forminfo = {{ 0 }};
        XCBRenderQueryPictFormatsRep *r;
        XCBRenderPICTFORMINFOIter fi;
        
        r = XCBRenderQueryPictFormatsReply(c, XCBRenderQueryPictFormats(c), 0);
        if(!r)
                return forminfo;
        
        format = _format_from_visual(r, visual);
        
        if(format.xid)
                for(fi = XCBRenderQueryPictFormatsFormatsIter(r); fi.rem; XCBRenderPICTFORMINFONext(&fi))
                        if(fi.data->id.xid == format.xid)
                        {
                                forminfo = *fi.data;
                                break;
                        }
        free(r);
        return forminfo;
}


Hope that helps.

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/xcb/attachments/20050929/c1260332/attachment.pgp


More information about the Xcb mailing list