C.5 Writing Extension Stubs

All X requests always contain the length of the request, expressed as a 16-bit quantity of 32 bits. This means that a single request can be no more than 256K bytes in length. Some servers may not support single requests of such a length. The value of dpy->max_request_size contains the maximum length as defined by the server implementation. For further information, see “X Window System Protocol.”

C.5.1 Requests, Replies, and Xproto.h

The <Xproto.h> file contains three sets of definitions that are of interest to the stub implementor: request names, request structures, and reply structures.

You need to generate a file equivalent to <Xproto.h> for your extension and need to include it in your stub routine. Each stub routine also must include <Xlibint.h>.

The identifiers are deliberately chosen in such a way that, if the request is called X_DoSomething, then its request structure is xDoSomethingReq, and its reply is xDoSomethingReply. The GetReq family of macros, defined in <Xlibint.h>, takes advantage of this naming scheme.

For each X request, there is a definition in <Xproto.h> that looks similar to this:

#define X_DoSomething   42

In your extension header file this will be a minor opcode, rather than a major opcode.

C.5.2 Request Format

Every request contains an 8-bit major opcode and a 16-bit length field expressed in units of four bytes. Every request consists of four bytes of header (containing the major opcode, the length field, and a data byte) followed by zero ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.