[Xcb] XCB tutorial comments

Jamey Sharp jamey at minilop.net
Sat Dec 10 15:39:57 PST 2005

On Thu, Dec 08, 2005 at 11:47:02PM +0100, Vincent Torri wrote:
> > 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.
> > Can I suggest this implementation of ScreenOfDisplay?
> nice :) that's exactly the kind of thing that I want you (Jamey and other
> people) to tell me.

OK. :-)

I've now done a pretty thorough reading through section 8, and skimmed
the rest. It's a fine tutorial, so I'm *still* really pleased that
you're writing it. :-) I do have some suggestions:

Section 4.2: Note that graphic contexts have no client-side structure in
XCB, they're just XIDs. Xlib has a client-side structure because it
caches the GC contents so it can avoid making redundant requests, but of
course XCB doesn't do that.

Section 4.3: The event types that XCB supports are exactly those
specified by the X protocol. So XCB's core protocol support will always
have 33 events, unless there's a new version of the X protocol.

Section 5.2: Might add -Wall to the compile flags, just to encourage
good practices. :-)

Section 7: Your demo program might illustrate capturing the screen
number and displaying information about that screen instead of just the
first one. The pattern that I introduced a couple of years ago --
	XCBConnSetupSuccessRepRootsIter (XCBGetSetup (c)).data
-- is awful because it doesn't let the user pick an appropriate screen.
Any time you use that pattern or pass NULL as the second argument to
XCBConnect, maybe check whether it should be fixed?

Section 8: It's kind of important to note that XCBWINDOWNew does *not*
ask the server for a new XID: it just does a quick computation on the
client. (If the client runs out of IDs, which should be rare, then it
does do a single round-trip to the server to get another batch of IDs.)

Section 8: In the demo program, the line
	while (1) {}
is just evil. ;-) The pause(2) function should do what you want.

That's all the detailed comments I've got so far. Here are some more
general ones.

Please don't list any definitions from xcbint.h. That header file won't
be installed by the time XCB 1.0 is released, and I reserve the right to
change its contents at any time. So far I've only noticed this in
section 6, where you've listed the definition of XCBConnection.

You might consider introducing event handling before window creation and
drawing. You could, for example, produce a simple application that
reports mouse movement and click events on the root window. Then when
you introduce window creation you can present an appropriate event loop
for expose events.

When you want to give an example program *fragment*, rather than a
complete example program, can I suggest writing it as a function? Then
it's clear that some of the variables are parameters and the others are
local to the example.

Some examples of issuing a bunch of requests and then forcing all the
cookies at once would be a nice addition.

That's all. :-) Again, nice work so far! Thanks for your effort!

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

Yeah, that seems clearest.

-------------- 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/20051210/465ecbe9/attachment.pgp

More information about the Xcb mailing list