xcffib is intended to be a (mostly) drop-in replacement for xpyb. xpyb
has an inactive upstream, several memory leaks, is python2 only and doesn't
have pypy support. xcffib is a binding which uses
cffi, which mitigates some of the issues
described above. xcffib also builds bindings for 27 of the 29 (xprint and xkb
are missing) X extensions in 1.10.
Currently xcb-types (any tagged version, not just the old one on Hackage)
doesn't run against xcb-proto 1.10; there is a hacked branch available at
tych0/xcb-types that allows you to parse
xcb-proto 1.10 mostly correctly. Other than that, you should be able to install
all the deps from hackage or pip. The
.travis.yaml has an
example of how to install the dependencies on Ubuntu flavors.
There are lots of differences right now between xpyb and xcffib, mostly
because xcffib isn't done yet :-)
- In general, you should
s/xcb/xcffib/g xcb.Exceptionis spelledxcffib.XcffibExceptionand is also a parent of all exceptions generated by xcffib.xcb.ConnectExceptionis gone, it was unusedxcffib.ConnectionExceptionis raised on connection errorsxcb.Iteratoris gone; similar functionality is implemented byxcffib.pack_list.xcb.Requestis gone. It was an entirely internal and unnecessary interface.xcffib.Connection.send_requesttakes slightly different (but more sensible) arguments.- Everywhere
xcb-protosayschar,xcffibuses a char. That means on input for a<list type="char"/>, you can use a python string literal.xcffibalso gives you a string of length 1 out for each element in such a list, instead of anint. Finally, there is a helper method calledto_stringonxcffib.List, to convert these string-like things into native strings. In both python2 and python3 you get a nativestr. This means that for things likexproto.STR, you can just dothe_str.name.to_string()instead of''.join(map(chr, the_str.name)). - As above,
voidis also packed/unpacked aschars, since the convention is to use it as string data, e.g. inxproto.ChangeProperty. - The submodule
xcbis gone. The top module re-exported all these constants anyway, so they live there now. i.e.xcb.xcb.CurrentTimeis now justxcffib.CurrentTime.
- When sending requests with nested structs you no longer have to pack the
contents yourself. For example, when calling
xproto.FillPoly, you used to have to convert thePOINTs you were passing in to some sort of buffer which had themstruct.pack'd. Now, you can just pass an iterable (orxcffib.List) ofPOINTs and it will be automatically packed for you. - Most of the lower level XCB connection primitives that were previously not
exposed are now available via
xcffib.{ffi,C}, assuming you want to go out of band of the binding. - Checked vs. Unchecked requests are still supported (via Checked and Unchecked
function calls). However, there is also an additional optional parameter
is_checkedto each request function, to allow you to set the checked status that way. Additionally, requests that are (un)checked by default, e.g.QueryTree(CreateWindow), have aQueryTreeChecked(CreateWindowUnchecked) version which just has the same default behavior. - The
FooErrorBadFooduality is gone; it was difficult to understand what to actually catch if you wanted to handle an error. Instead,FooErrorandBadFooare aliases, and both implement the X error object description and python Exception (via inheriting fromXcffibException).
Why is the binding generator written in haskell? Because haskell is awesome.
- XGE support? (xpyb doesn't implement this either)
- xprint and xkb support. These will require some non-trivial work in xcb-types, since it won't parse them correctly.