HOME

TheInfoList



OR:

XCB (''X protocol C-language Binding'') is a
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
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 provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
display server protocol. XCB is written in the
C programming language ''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
and distributed under the
MIT License The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license comp ...
. 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 written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the ...
.


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 the state of not being in synchronization. Asynchrony or asynchronous may refer to: Electronics and computing * Asynchrony (computer programming), the occurrence of events independent of the main program flow, and ways to deal with ...
, 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 arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
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 arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
, 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 (pro ...
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, which may subseque ...
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 Abrial ...
. (Xlib has long been known to contain errors.)


Xlib compatibility

''Xlib/XCB'' provides
application binary interface In computer software, an application binary interface (ABI) is an interface between two binary program modules. Often, one of these modules is a library or operating system facility, and the other is a program that is being run by a user. An ' ...
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 In computing, a windowing system (or window system) is software that manages separately different parts of display screens. It is a type of graphical user interface (GUI) which implements the WIMP (windows, icons, menus, pointer) paradigm for ...
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) XCB has a comparable, but slightly lower-level API than
Xlib Xlib (also known as libX11) is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the ...
, as can be seen with this example.


Protocol description

Creators of XCB have invented a specialized
interface description language 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 describe an inter ...
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 a website or mobile app. While many are published exclusively on the web, others are also published in magazines, newspapers, or comic books. Webcomics can be co ...
''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) 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 operating systems. It was founded by Hav ...
.
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) 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 operating systems. It was founded by Hav ...
)
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