16

If one needs low level access to X11 events, windowing and input without using GTK, QT et al., should one use Xlib or XCB? What are the pros and cons of each?

x-x
  • 7,287
  • 9
  • 51
  • 78
  • 2
    qt5.5.0 use XCB rather than xlib. So I assume xcb is ready for production use. – Jichao Oct 03 '15 at 16:51
  • 2
    Use XCB if you want high performance... and a reasonable dose of pain due to lack of documentation (I _love_ XCB, btw!). Also, a good source for information on XCB seems to be the X protocol itself, since XCB is a fairly thin layer, as far as I can tell – étale-cohomology Aug 20 '17 at 20:41

2 Answers2

17

You can use both of them. XCB is simpler to use, has a better response to a multithread environment but lacks documentation, while Xlib is a more dated/complex tool, better documented and fully implemented.

I'm currently studying the XCB API and the hardest thing to do is to find docs and good API references..

In the end: if you aim to faster development, you should use Xlib, otherwise XCB is meant to be the future (but it's still far from being such).

moongoal
  • 2,847
  • 22
  • 23
  • 11
    _...the hardest thing to do is to find docs and good API references..._ Very true. Some of the official tutorials are riddled with errors and won't even compile. [Example](http://xcb.freedesktop.org/tutorial/events/) – x-x Jan 27 '12 at 23:18
5

What helps when learning XCB is to look at X11 specification, for example here https://www.x.org/releases/current/doc/xproto/x11protocol.pdf

Most XCB calls map directly to X11 requests. The same is true for extensions.

Arzet Ro
  • 487
  • 1
  • 5
  • 12
gatis paeglis
  • 541
  • 5
  • 7