XCB
   HOME

TheInfoList



OR:

XCB (''X protocol C-language Binding'') is a
library A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
implementing the client side of the
X11 The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X originated as part of Project Athena at Massachusetts Institute of Technology (MIT) in 1984. The X protocol has been at ...
display server protocol. XCB is written in the
C programming language C (''pronounced'' '' – like the letter c'') is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of ...
and distributed under the
MIT License The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility. Unl ...
. The project was started in 2001 by Bart Massey and aims to replace
Xlib Xlib (also known as libX11) is an X Window System protocol client library (computer science), library written in the C (programming language), C programming language. It contains subroutine, functions for interacting with an X Server (computi ...
.


Overview

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. The main goals of XCB are to: * reduce library size and complexity * provide direct access to the X11 protocol 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). Secondary goals include making the C interface
asynchronous Asynchrony is any dynamic far from synchronization. If and as parts of an asynchronous system become more synchronized, those parts or even the whole system can be said to be in sync. Asynchrony or asynchronous may refer to: Electronics and com ...
, facilitating better multithreading and making it easier to implement extensions (via
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
protocol descriptions). The core and extension protocol descriptions are in
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
, with a program written in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
creating the C bindings. (Previous versions used
XSLT XSLT (Extensible Stylesheet Language Transformations) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text, or XSL Formatting Objects. These formats c ...
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 The Z notation is a formal specification language used for describing and modelling computing systems. It is targeted at the clear specification of computer programs and computer-based systems in general. History In 1974, Jean-Raymond Abria ...
. (Xlib has long been known to contain errors.)


Xlib compatibility

''Xlib/XCB'' provides
application binary interface An application binary interface (ABI) is an interface exposed by software that is defined for in-process machine code access. Often, the exposing software is a library, and the consumer is a program. An ABI is at a relatively low-level of a ...
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.


Example

// Simple XCB application for opening a window and drawing a box in it // To compile it using GNU, use: // gcc x.c -lxcb #include #include #include int main(void) The
bitwise and In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral (considered as a bit string) at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operat ...
operation a->response_type & ~0x80 removes a bit that indicates where the event came from. XCB has a comparable, but slightly lower-level API than
Xlib Xlib (also known as libX11) is an X Window System protocol client library (computer science), library written in the C (programming language), C programming language. It contains subroutine, functions for interacting with an X Server (computi ...
, as can be seen with this example.


Protocol description

Creators of XCB have invented a specialized
interface description language An interface description language or interface definition language (IDL) is a generic term for a language that lets a program or object written in one language communicate with another program written in an unknown language. IDLs are usually use ...
to model X11 protocol in language-neutral way and facilitate generation of bindings to other programming languages. libxcb itself is implemented as a code generator and a tiny C stub of utility functions. An example:


Logo

The XCB logo was produced by Gearóid Molloy, author of the
web comic Webcomics (also known as online comics or Internet comics) are comics published on the internet, such as on a website or a mobile app. While many webcomics are published exclusively online, others are also published in magazines, newspapers, or ...
''Neko the Kitty'', and donated to the project.KittyLogo
(xcb.freedesktop.org)


Other language bindings


XCB.pm
- Perl module implementing bindings to XCB.
xpyb
- The Python binding to the X Window System using XCB. As of June 2013, it does not support Python 3. Provided by
freedesktop.org freedesktop.org (fd.o), formerly X Desktop Group (XDG), is a project to work on interoperability and shared base technology for free-software desktop environments for the X Window System (X11) and Wayland on Linux and other Unix-like operatin ...
.
xcffib
- Another Python binding which supports Python 2 & 3 as well as several more X extensions than xpyb.


Notes


References

* * *


External links


XCB wiki
(
freedesktop.org freedesktop.org (fd.o), formerly X Desktop Group (XDG), is a project to work on interoperability and shared base technology for free-software desktop environments for the X Window System (X11) and Wayland on Linux and other Unix-like operatin ...
)
XCB API referencetutorial



Further publications

The X New Developer’s Guide: Xlib and XCB
{{DEFAULTSORT:Xcb C (programming language) libraries Freedesktop.org Freedesktop.org libraries Software using the MIT license X Window System