[Xcb] about translation of Xlib functions

Jamey Sharp jamey at minilop.net
Thu Dec 8 14:02:34 PST 2005

On Thu, Dec 08, 2005 at 09:43:57PM +0100, Vincent Torri wrote:
> Hello,

Hi Vincent!

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

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

I'd suggest documenting the equivalent of ScreenOfDisplay, and of all
the Xlib macros that use _XPrivDisplay. 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.

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;

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

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20051208/f7b4b58b/attachment.pgp

More information about the Xcb mailing list