[Xcb] some questions and remarks

Vincent Torri Vincent.Torri at iecn.u-nancy.fr
Thu Sep 29 22:39:42 PDT 2005



On Thu, 29 Sep 2005, Jamey Sharp wrote:

> 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.

ok

> > > 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;
> }

ok, i've missed that

> Hope that helps.

it does :) Thank you

Vincent


More information about the Xcb mailing list