[Xcb] about translation of Xlib functions

Vincent Torri Vincent.Torri at iecn.u-nancy.fr
Thu Dec 8 14:47:02 PST 2005


>
> > i've just begun the translation of some Xlib functions/macros, that I add
> > to the tutorial.
>
> Looks nice so far! Sometime I need to go read your whole tutorial again...

yes, it would be nice. I think that you'll find a lots of things to fix
and to add. Also, I xould like to add/modify a lots of things in it, now
that i'm more familiar with xcb.

> > I always put an complete code to obtain the same result than in Xlib, but
> > I fear that's a bit difficult to read. Another solution would be (for
> > example): take the default screen as documented in *** and grab its ***
> > member.
>
> If you look at how the macros are implemented in Xlib.h, their
> implementation looks much like your second solution. For example:
>
> #define DefaultRootWindow(dpy)  (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
> #define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
> #define DefaultGC(dpy, scr)     (ScreenOfDisplay(dpy,scr)->default_gc)

Yes, it's my doc :) As you can remark, the order is exactly the same as in
the tutorial :)

> I'd suggest documenting the equivalent of ScreenOfDisplay, and of all
> the Xlib macros that use _XPrivDisplay.

ok. I think that I don't forget anything if I try to document all the
functions/macro that are in Xlib.

 Then you can simply document how
> the remaining macros use the fundamental ones. Since ScreenOfDisplay has
> O(n) complexity on XCB, rather than O(1) complexity on Xlib, this
> approach should make it clear how to call ScreenOfDisplay only once and
> use the returned XCBSCREEN several times.

ok. So one thing to do is putting one and for all the ScreenOfDisplay at
the beginning.

> Can I suggest this implementation of ScreenOfDisplay?
>
> 	XCBSCREEN *ScreenOfDisplay(XCBConnection *c, int screen)
> 	{
> 		XCBSCREENIter iter = XCBConnSetupSuccessRepRootsIter(XCBGetSetup(c));
> 		for(; iter.rem; --screen, XCBSCREENNext(&iter))
> 			if(screen == 0)
> 				return iter.data;
> 		return 0;
> 	}
>

nice :) that's exactly the kind of thing that I want you (Jamey and other
people) to tell me.

> By the way, I notice QLength is the next thing on your list. Of course
> XCB doesn't support that operation, which should make that macro pretty
> easy to document. ;-)

indeed :)

> Hope that helps. Thanks for your work on this tutorial!

thank you :)

Vincent


More information about the Xcb mailing list