XCB

XCB

Infobox_Software
name = XCB
developer = Jamey Sharp, Josh Triplett, Bart Massey
latest_release_version = 1.1.90.1
latest_release_date = July 17, 2008 [cite mailing list |url=http://lists.freedesktop.org/archives/xcb/2008-July/003622.html |title= [Xcb] [ANNOUNCE] libxcb-1.1.91 - should be 1.1.90.1 |date=2008-07-17 |accessdate=2008-09-05 |mailinglist=xcb |last=Hutterer |first=Peter ]
operating_system = POSIX
license = MIT
genre = X Window core protocol development library
website = [http://xcb.freedesktop.org xcb.freedesktop.org]

In computing, XCB (X C Binding) is a C language binding for the X Window System. It is implemented as free software and 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. 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.

Aims

The main aims of XCB are:

* reduction in library size and complexity;
* direct access to the X11 protocol.

Secondary aims include making the C interface asynchronous, facilitating better multithreading and making extensions easier to implement (via XML protocol descriptions).

The core and extension protocol descriptions are in XML, with the C bindings created via a Python script. (Previous versions used XSLT and M4.) A tertiary aim is to repurpose these protocol descriptions for the creation of protocol documentation, further language bindings, and server-side stubs.

Massey and others have worked to prove key portions of XCB formally correct, using Z notation. (Xlib has long been known to contain errors). Fact|date=July 2008

Example

/* Simple XCB application drawing a box in a window */
#include
#include
#include

int main(){ 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 with the server */ c = xcb_connect(NULL,NULL); if (xcb_connection_has_error(c)) { printf("Cannot open display "); exit(1); } /* 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);

return 0;}

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

References

* [http://www.linuxshowcase.org/2001/full_papers/massey/massey.pdf XCB: An X Protocol C Binding] (PDF) (Bart Massey and Jamey Sharp, 19 September 2001, presented at XFree86 Technical Conference 2001)
* [http://www.usenix.org/events/usenix02/tech/freenix/full_papers/sharp/sharp_html/index.html XCL: An Xlib Compatibility Layer For XCB] (Jamey Sharp and Bart Massey, 15 April 2002, presented at USENIX 2002)
* [http://www.usenix.org/events/usenix02/tech/freenix/full_papers/massey/massey_html/index.html 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

* [http://xcb.freedesktop.org/ XCB wiki] (freedesktop.org)
* [http://xcb.freedesktop.org/XcbApi/ XCB API reference]
* [http://xcb.freedesktop.org/Publications Further publications]


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • XCB — Desarrollador Jamey Sharp, Josh Triplett, Bart Massey xcb.freedesktop.org …   Wikipedia Español

  • XCB — Développeur Jamey Sharp, Josh Triplett, Bart Massey Dernière version …   Wikipédia en Français

  • XCB — Тип Библиотека для работы с основным протоколом X Window System Разработчик Jamey Sharp, Josh Triple …   Википедия

  • XCB — Entwickler Jamey Sharp, Josh Triplett, Bart Massey Aktuelle Version 1.7 (August 2010) Betriebssystem …   Deutsch Wikipedia

  • xcb — ISO 639 3 Code of Language ISO 639 2/B Code : ISO 639 2/T Code : ISO 639 1 Code : Scope : Individual Language Type : Extinct Language Name : Cumbric …   Names of Languages ISO 639-3

  • XCB — Ares I X Control Board Contributor: MSFC …   NASA Acronyms

  • XCB — abbr. Extension Client Binding …   Dictionary of abbreviations

  • Clorpactin XCB — Clor·pac·tin XCB (klor pakґtin) trademark for a preparation of oxychlorosene …   Medical dictionary

  • Xlib Compatibility Layer — XCB XCB Développeur Jamey Sharp, Josh Triplett, Bart Massey Dernière version …   Wikipédia en Français

  • X.Org — Développeur Fondation X.Org Dernière version …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”