将xcb_get_geometry_reply_t转换为uint16_t []

问题描述 投票:0回答:1

我正在尝试通过XCB检索根窗口的大小,以便创建该大小的窗口。

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

c xorg xcb
1个回答
0
投票

来自this page

就像我们可以设置窗口的各种属性一样,我们也可以要求X服务器提供这些属性的当前值。例如,我们可以检查窗口在屏幕上的位置,窗口的当前大小,是否被映射等。包含某些信息的结构是

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;

因此,宽度/高度可以通过geomtry->widthgeomtry->height简单访问

© www.soinside.com 2019 - 2024. All rights reserved.