从 `xcb_get_geometry_reply()` 获取宽度和高度

Get width and height from `xcb_get_geometry_reply()`

我正在尝试通过 XCB 检索根 window 的大小,以便创建一个 window 那个大小。

我可以使用 xcb_get_geometry_reply() 获取几何图形,但我如何将其转换为 uint16_t 以便我可以将其传递给 xcb_create_window()(作为宽度和高度)?

来自this page

Just like we can set various attributes of our windows, we can also ask the X server supply the current values of these attributes. For example, we can check where a window is located on the screen, what is its current size, whether it is mapped or not, etc. The structure that contains some of this information is

typedef struct {
    uint8_t      response_type;
    uint8_t      depth;         /* depth of the window */
    uint16_t     sequence;
    uint32_t     length;
    xcb_window_t root;          /* Id of the root window *>
    int16_t      x;             /* X coordinate of the window's location */
    int16_t      y;             /* Y coordinate of the window's location */
    uint16_t     width;         /* Width of the window */
    uint16_t     height;        /* Height of the window */
    uint16_t     border_width;  /* Width of the window's border */
 } xcb_get_geometry_reply_t;

因此,width/height 只需使用 geomtry->widthgeomtry->height

即可访问