XCB
Encyclopedia : X : XC : XCB : XCB
In computing, XCB (X C Binding) is a C language binding for the X Window System. It aims to replace Xlib. The project was started in 2001 by Bart Massey.
Xlib/XCB provides application binary interface compatibility with both Xlib and XCB, providing an incremental porting path.
Aims of XCB
The main aims of XCB are:
- reduction in library size and complexity;
- direct access to the X11 protocol.
The core and extension protocol descriptions are in XML, with the C bindings created via XSLT. A tertiary aim is to repurpose these protocol descriptions for the creation of protocol documentation, further language bindings, and server-side stubs.
Massey has worked to prove XCB formally correct, using Z notation. (Xlib has long been known to contain errors.)
Example
/* Simple XCB application drawing a box in a window */XCB has a comparable, but slightly lower-level API than Xlib, as can be seen with this example.#include
#include #include int main() ;
/* open connection with the server */ c = XCBConnect(NULL,NULL); if (c == NULL) /* get the first screen */ s = XCBSetupRootsIter( XCBGetSetup(c) ).data;
/* create black graphics context */ g = XCBGCONTEXTNew(c); w.window = s->root; mask = XCBGCForeground | XCBGCGraphicsExposures; values[0] = s->black_pixel; values[1] = 0; XCBCreateGC(c, g, w, mask, values);
/* create window */ w.window = XCBWINDOWNew(c); mask = XCBCWBackPixel | XCBCWEventMask; values[0] = s->white_pixel; values[1] = XCBEventMaskExposure | XCBEventMaskKeyPress; XCBCreateWindow(c, s->root_depth, w.window, s->root, 10, 10, 100, 100, 1, XCBWindowClassInputOutput, s->root_visual, mask, values);
/* map (show) the window */ XCBMapWindow(c, w.window);
XCBFlush(c);
/* event loop */ while (!done && (e = XCBWaitForEvent(c))) free(e); } /* close connection to server */ XCBDisconnect(c);
return 0; }
References
- [XCB: An X Protocol C Binding] (PDF) (Bart Massey and Jamey Sharp, 19 September 2001, presented at XFree86 Technical Conference 2001)
- [XCL: An Xlib Compatibility Layer For XCB] (Jamey Sharp and Bart Massey, 15 April 2002, presented at USENIX 2002)
- [X Meets Z: Verifying Correctness In The Presence Of POSIX Threads] (Bart Massey and Robert Bauer, 15 April 2002, presented at USENIX 2002)
External links
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
