0

我遇到了 XCB 的问题。我不明白*_reply_tvs*_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_outputswhich 期望第一个参数是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

4

1 回答 1

1

我认为您偶然发现的只是一个文档错误。声称具有*_request_t实际期望的所有功能*_reply_t。从您链接的源代码中,只需查看实际的函数定义(而不是手册页所说的),您就会发现

xcb_randr_output_t *
    xcb_randr_get_screen_resources_current_outputs (const xcb_randr_get_screen_resources_current_reply_t *R  );

您找到的结构实际上并未在文件中的任何地方使用,因此它可能是一些被遗忘的剩余部分,或者出于兼容性原因可能仍然保留。

于 2016-05-08T08:23:20.170 回答