[英]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.我正在尝试通过 XCB 检索根 window 的大小,以便创建该大小的 window。
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)?我可以使用xcb_get_geometry_reply()
来获取几何图形,但是如何将其转换为uint16_t
以便将其传递给xcb_create_window()
(作为宽度和高度)?
Just like we can set various attributes of our windows, we can also ask the X server supply the current values of these attributes.就像我们可以设置 windows 的各种属性一样,我们也可以要求 X 服务器提供这些属性的当前值。 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例如,我们可以检查 window 在屏幕上的位置,它的当前大小是多少,是否已映射等。包含这些信息的结构是
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
因此,只需使用geomtry->width
和geomtry->height
访问宽度/高度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.