XErrorEvent结构字段含义

XErrorEvent structure field meaning

我目前在使用 Xlib 和 CEF 时遇到了一些问题,我需要调查发送到 XSetErrorHandler 注册函数的 XErrorEvent

typedef struct {
    int type;
    Display *display;   /* Display the event was read from */
    XID resourceid;     /* resource id */
    unsigned long serial;   /* serial number of failed request */
    unsigned char error_code;   /* error code of failed request */
    unsigned char request_code; /* Major op-code of failed request */
    unsigned char minor_code;   /* Minor op-code of failed request */
} XErrorEvent;

我想知道 typerequest_codeminor_code 字段的含义。 There is a book on C language interface for the X window system 但我找不到有关此字段的任何信息。

type 将无类型内存指针标识为指向 XErrorEvent 的指针 - 它的值始终为 X_Error.

request_codea protocol request of the procedure that failed, as defined in X11/Xproto.h,基本上是哪种请求产生了错误(第 2020 行及以后):

/* Request codes */

#define X_CreateWindow                  1  
#define X_ChangeWindowAttributes        2   
#define X_GetWindowAttributes           3   
#define X_DestroyWindow                 4
#define X_DestroySubwindows             5   
#define X_ChangeSaveSet                 6
#define X_ReparentWindow                7
#define X_MapWindow                     8
...

minor_code 类似于 request_code 除了被扩展使用。每个分机在 128-255 范围内都有自己的 request_codeminor_code 标识由该扩展定义的特定请求。所以,X11最多支持127个扩展,每个扩展最多可以定义255个请求。 The exact paragraph:

Each extension is assigned a single opcode from that range, also known as it's “major opcode.” For each operation provided by that extension, typically a second byte is used as a “minor opcode.” Minor opcodes for each extension are defined by the extension.