C.2 Hooking into Xlib

These functions allow you to hook into the library. They are not normally used by application programmers but are used by people who need to extend the core X protocol and the X library interface. The functions, which generate protocol requests for X, are typically called stubs.

In extensions, stubs first should check to see if they have initialized themselves on a connection. If they have not, they then should call XInitExtension() to attempt to initialize themselves on the connection.

If the extension needs to be informed of GC/font allocation or deallocation or if the extension defines new event types, the functions described here allow the extension to be called when these events occur.

C.2.1 XInitExtension

The XExtCodes structure returns the information from XInitExtension() and is defined in <Xlib.h>:

typedef struct _XExtCodes {  /* public to extension, cannot be changed */
    int extension;           /* extension number */
    int major_opcode;        /* major op-code assigned by server */
    int first_event;         /* first event number for the extension */
    int first_error;         /* first error number for the extension */
} XExtCodes;
XExtCodes *XInitExtension(display, name)
      Display *display;
      char *name;
display

Specifies the connection to the X server.

name

Specifies the extension name.

XInitExtension() determines if the named extension exists. Then it allocates storage for maintaining the information about the extension on the connection, chains this onto the extension list for the connection, and ...

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.