[Xcb] [ANN] X Go Binding (and xgbutil)

Andrew Gallant jamslam at gmail.com
Sat May 26 15:52:53 PDT 2012

Hello all,

For the past couple of months, I've been working on the X Go Binding
(XGB) [1] and an analog to xcb-util called xgbutil [2]. There was a
previous XGB library [3], but I've forked it and rewritten most of the
code. I've also replaced the Python code generator with xgbgen [4],
and if there's any interest, it could be adapted to work for other
languages without any major redesign (I think).

XGB's API is nearly identical to XCB's API. It supports synchronous
and asynchronous errors and is thread safe. (Go's goroutines made this
job relatively simple. I'm using only a single mutex for a small piece
of XGB.)

XGB also has compilable Go source code for every extension described
in xproto except for XKB. (*shiver*) I am unsure of whether or not
they all work, but so far, RandR and Xinerama are certainly working.

Both XGB and xgbutil are heavily documented [5,6] and contain several examples.

xgbutil contains a lot of supporting code, particularly for: EWMH,
ICCCM, event callbacks, mouse/key bindings, some support for the X
keyboard encoding (to get something like XLookupString working), a
window abstraction and an image abstraction that can be used to paint
any Go image.Image to a window... And a lot more. xgbutil has several
documented examples. [7]

If you have Go installed and would like to try a quick example of a
stupid MS style paint program, you could try:

GOPATH=$HOME/gotmp go get

And use your mouse (left and right click) to paint some some squares
and gophers. You can use this method of installation with any of the
other examples in the xgbutil/examples directory. (And more generally,
most Go programs.)

Finally, I've written a very simple image viewer [8] as a small
demonstration of what xgbutil can do. To install (assuming Go is
installed and your GOPATH environment variable is set properly):

go get github.com/BurntSushi/imgv
go/path/bin/imgv some-image.png

I welcome any comments or criticisms!

- Andrew

P.S. A window manager [9] is also in the pipeline :-)

[1] - https://github.com/BurntSushi/xgb
[2] - https://github.com/BurntSushi/xgbutil
[3] - http://code.google.com/p/x-go-binding/
[4] - http://godoc.burntsushi.net/pkg/github.com/BurntSushi/xgb/xgbgen/
[5] - http://godoc.burntsushi.net/pkg/github.com/BurntSushi/xgb/
[6] - http://godoc.burntsushi.net/pkg/github.com/BurntSushi/xgbutil/
[7] - http://godoc.burntsushi.net/pkg/github.com/BurntSushi/xgbutil/examples/
[8] - https://github.com/BurntSushi/imgv
[9] - https://github.com/BurntSushi/wingo

More information about the Xcb mailing list