我遇到了 XCB 的问题。我不明白*_reply_t
vs*_request_t
类型之间的区别。
似乎*_reply_t
是 代替 传递的*_response_t
,但是结构非常不同。
例如:
xcb_randr_get_screen_resources_current_reply_t *reply = xcb_randr_get_screen_resources_current_reply(
connection, xcb_randr_get_screen_resources_current(connection, root), NULL);
所以现在reply
是*_reply_t
. 但现在我需要使用xcb_randr_get_screen_resources_current_outputs
which 期望第一个参数是xcb_randr_get_screen_resources_current_request_t
这里的文档的类型:
http://www.linuxhowtos.org/manpages/3/xcb_randr_get_screen_resources_current_outputs.htm
xcb_randr_output_t *xcb_randr_get_screen_resources_current_outputs(
const xcb_randr_get_screen_resources_current_request_t *reply
);
但是,第一次调用的响应是xcb_randr_get_screen_resources_current_reply_t
( *_reply_t
) 类型的。如何在不强制转换的情况下将其传递给输出调用?每个文档的结构完全不同:
typedef struct xcb_randr_get_screen_resources_current_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_timestamp_t timestamp;
xcb_timestamp_t config_timestamp;
uint16_t num_crtcs;
uint16_t num_outputs;
uint16_t num_modes;
uint16_t names_len;
uint8_t pad1[8];
} xcb_randr_get_screen_resources_current_reply_t;
并且 的结构*_request_t
不在我从这里的源代码中获得的文档中:
https://xcb.freedesktop.org/manual/randr_8h_source.html#l00896
typedef struct xcb_randr_get_screen_resources_current_request_t {
uint8_t major_opcode;
uint8_t minor_opcode;
uint16_t length;
xcb_window_t window;
} xcb_randr_get_screen_resources_current_request_t;
我做 ctypes 所以我必须事先声明我要传入的类型作为方法的签名。所以我很困惑一个完全不同的结构(reply
)是如何进入第二个结构的调用的request
。