Skip to content

Commit 78a64e2

Browse files
committed
Add src/xcbproto/README.md
1 parent 416a851 commit 78a64e2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/xcbproto/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# xcbproto Directory
2+
3+
This directory contains the tooling and protocol definitions used to generate Python bindings for XCB (X C Binding).
4+
5+
## Overview
6+
7+
- **`gen_xcb_to_py.py`**: Code generator that produces Python/ctypes bindings from XCB protocol XML files.
8+
- **`*.xml`**: Protocol definition files vendored from the upstream [xcbproto](https://gitlab.freedesktop.org/xorg/proto/xcbproto) repository. These describe the X11 core protocol and extensions (RandR, Render, XFixes, etc.).
9+
10+
## Workflow
11+
12+
The generator is a **maintainer tool**, not part of the normal build process:
13+
14+
1. When the project needs new XCB requests or types, a maintainer edits the configuration in `gen_xcb_to_py.py` (see `TYPES` and `REQUESTS` dictionaries near the top).
15+
2. The maintainer runs the generator:
16+
17+
```bash
18+
python src/xcbproto/gen_xcb_to_py.py
19+
```
20+
21+
3. The generator reads the XML protocol definitions and emits `xcbgen.py`.
22+
4. The maintainer ensures that this worked correctly, and moves the file to `src/mss/linux/xcbgen.py`.
23+
4. The generated `xcbgen.py` is committed to version control and distributed with the package, so end users never need to run the generator.
24+
25+
## Protocol XML Files
26+
27+
The `*.xml` files are **unmodified copies** from the upstream xcbproto project. They define the wire protocol and data structures used by libxcb. Do not edit these files.
28+
29+
## Why Generate Code?
30+
31+
The XCB C library exposes thousands of protocol elements. Rather than hand-write ctypes bindings for every structure and request, we auto-generate only the subset we actually use. This keeps the codebase lean while ensuring the bindings exactly match the upstream protocol definitions.
32+
33+
## Dependencies
34+
35+
- **lxml**: Required to parse the XML protocol definitions.
36+
- **Python 3.12+**: The generator uses modern Python features.
37+
38+
Note that end users do **not** need lxml; it's only required if you're regenerating the bindings.

0 commit comments

Comments
 (0)