简体   繁体   中英

Get width and height from `xcb_get_geometry_reply()`

I'm attempting to retrieve the size of the root window via XCB, so as to create a window that size.

I can use xcb_get_geometry_reply() to get the geometry, but how can I convert that to uint16_t so that I can pass it to xcb_create_window() (as width and height)?

From 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;

Therefore, the width/height simply be accessed with geomtry->width and geomtry->height

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM