server-side xcb

Tomas Carnecky tom at dbservice.com
Thu Jun 17 17:56:45 PDT 2010


I started looking into how to generate everything that has to do with 
the wire protocol using xcb. I'm starting small, with the easier 
extensions first (dpms), and I'll be gradually adding support for the 
more complicated extensions as the time goes.

This mail serves as an overview of what I've been playing with in the 
past few days. The code is nowhere near functional, but should give you 
an idea into which direction I'm heading. Comments are very much 
appreciated.

I took c_client.py as an inspiration how to generate the C source files. 
However, instead of doing that straight from python, I've chosen to use 
a templating engine. I couldn't find any for python that would be 
suitable to generate C, all engines focus mostly on html. So the 
template itself looks strange and emacs has troubles using the right 
syntax highlighting because it can't decide whether it's C, python or 
html. But overall I think a template is better than plain python.

The code generates request/reply structures, corresponding swap 
functions and a function prefixed with wire_. That function is what's 
called by the dispatch code. The function validates the request size, 
swaps the request if necessary and then calls the function prefixed with 
impl_, that's where the actual implementation would be. If the request 
requires a reply, the impl_ function also fills the reply structure. The 
reply is optionally swapped and then sent to the client. So there is 
only one set of protocol handlers because they handle both swapped and 
non-swapped clients.

You can look at the code for DPMS QueryVersion here:
http://github.com/wereHamster/xorg-server/blob/server-side-xcb/proto/dpms.c#L9

The current code only works with requests/replies which use simple 
fields. Lists etc are not supported yet. One issue is how to represent 
(and swap) dynamically sized fields in the request/reply structures, 
another is how to give the client the ability to write additional data 
after the reply (as in GetImage for example). I'll take a look at how 
xcb solved these problems.

tom




More information about the xorg-devel mailing list