Home »

Xcb

The meaning of «xcb»

XCB (X protocol C-language Binding) is a library implementing the client-side of the X11 display server protocol. XCB is written in the C programming language and distributed under the MIT License. The project was started in 2001 by Bart Massey and aims to replace Xlib.

XCB was designed as a smaller, modernized replacement for Xlib, previously the primary C library for communicating with the X window system, coinciding with a more complete overhaul of the X implementation that took place during the early 2000s.[1] The main goals of XCB are to:

The required size reduction is achieved primarily by restricting XCB's scope to handling the X protocol and omitting Xlib functionality such as its extensive utility library, much of which saw little use by applications. This results in a factor thirty reduction of the compiled library size (as of 2004).[2] Secondary goals include making the C interface asynchronous, facilitating better multithreading and making it easier to implement extensions (via XML protocol descriptions).

The core and extension protocol descriptions are in XML, with a program written in Python creating the C bindings. (Previous versions used XSLT and M4.)

A further goal is to be able to use these protocol descriptions to create protocol documentation, more language bindings, and server-side stubs.

Massey and others have worked to prove key portions of XCB formally correct using Z notation.[3] (Xlib has long been known to contain errors.[4])

Xlib/XCB provides application binary interface compatibility with both Xlib and XCB, providing an incremental porting path. Xlib/XCB uses the protocol layer of Xlib, but replaces the Xlib transport layer with XCB, and provides access to the underlying XCB connection for direct use of XCB. Xlib/XCB allows an application to open a single connection to the X display server and use both XCB and Xlib, possibly through a mixture of libraries designed for one or the other.[5][6]

// Simple XCB application for opening a window and drawing a box in it // To compile it using GNU, use: // gcc x.c -lxcb #include <stdio.h> #include <stdlib.h> #include <xcb/xcb.h> int main(void) { xcb_connection_t *c; xcb_screen_t *s; xcb_window_t w; xcb_gcontext_t g; xcb_generic_event_t *e; uint32_t mask; uint32_t values[2]; int done = 0; xcb_rectangle_t r = { 20, 20, 60, 60 }; // open connection to the server c = xcb_connect(NULL,NULL); if (xcb_connection_has_error(c)) { printf("Cannot open display\n"); exit(EXIT_FAILURE); } // get the first screen s = xcb_setup_roots_iterator( xcb_get_setup(c) ).data; // create black graphics context g = xcb_generate_id(c); w = s->root; mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES; values[0] = s->black_pixel; values[1] = 0; xcb_create_gc(c, g, w, mask, values); // create window w = xcb_generate_id(c); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = s->white_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS; xcb_create_window(c, s->root_depth, w, s->root, 10, 10, 100, 100, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, s->root_visual, mask, values); // map (show) the window xcb_map_window(c, w); xcb_flush(c); // event loop while (!done && (e = xcb_wait_for_event(c))) { switch (e->response_type & ~0x80) { case XCB_EXPOSE: // draw or redraw the window xcb_poly_fill_rectangle(c, w, g, 1, &r); xcb_flush(c); break; case XCB_KEY_PRESS: // exit on key press done = 1; break; } free(e); } // close connection to server xcb_disconnect(c); exit(EXIT_SUCCESS); }

XCB has a comparable, but slightly lower-level API than Xlib,[7] as can be seen with this example.

Related Searches

XcbusaXCBLCross-country cycling
The X (TV series)XCOMXcode
XCOM 2XCOR Lynx

Choice of words

x-cb_ _
xc-b_ _
xcb-_ _
xcb:_ _ _ _
xcb_ _ _ _
xcb_ - _ _ _
xcb-_ _ _ _
xcb _ _ _ _ _
xcb _ - _ _ _ _
© 2015-2021, Wikiwordbook.info
Copying information without reference to the source is prohibited!
contact us mobile version