X Generic Event Extension

The X Generic Event extension (XGE) grew out of the problem that X only allows 64 event opcodes for all extensions together. Right now, there are only around 15 or so left, depending on how many extensions are enabled in your server. XGE simply defines one new event opcode (35, GenericEvent) in the core protocol, and then re-uses this opcode for multiple events.

Event Structure

typedef struct 
    BYTE    type; /* Always GenericEvent */
    CARD8   extension; 
    CARD16  sequenceNumber B16;
    CARD32  length B32;
    CARD16  evtype B16;
    CARD16  pad2 B16;
    CARD32  pad3 B32;
    CARD32  pad4 B32;
    CARD32  pad5 B32;
    CARD32  pad6 B32;
    CARD32  pad7 B32;
} xGenericEvent;

The actual type of an event is specified as the combination of extension and evtype. extension specifies the matching extension's major opcode. evtype is a static type as defined for this extension. evtype must be unique within the extension.

Long events

XGE allows events that are longer than the standard X protocol's 32 byte events. The length field of a GenericEvent defines the number of bytes after the initial 32 bytes in 4 byte units.

Sending long events requires an XGE-aware libX11/libxcb! The server must not send a long event unless it is sure that the client supports XGE, otherwise the protocol will be unaligned. libX11 without xcb support does not support GenericEvents.


XGE provides a single request: GEQueryVersion.

/* QueryVersion */
typedef struct {
    CARD8       reqType;       /* input extension major code   */
    CARD8       ReqType;       /* always X_GEQueryVersion */
    CARD16      length B16;
    CARD16      majorVersion B16;
    CARD16      minorVersion B16;
} xGEQueryVersionReq;

#define sz_xGEQueryVersionReq    8

typedef struct {
    CARD8       repType;        /* X_Reply                      */
    CARD8       RepType;        /* always X_GEQueryVersion */
    CARD16      sequenceNumber B16;
    CARD32      length B32;
    CARD16      majorVersion B16;
    CARD16      minorVersion B16;
    CARD32      pad00 B32;
    CARD32      pad01 B32;
    CARD32      pad02 B32;
    CARD32      pad03 B32;
    CARD32      pad04 B32;
} xGEQueryVersionReply;


As the event selection is specific to the extension, it is (currently) required that each extension provides its own event selection request. For example, in XI this is XiSelectEvent.

XGE is being used by XI (MPX) to send long events. Much of its current implementation supports device-specific events, but it is intended to be usable by other extensions as well.