gpt4 book ai didi

c - 如何在C中获取屏幕的高度和宽度

转载 作者:行者123 更新时间:2023-12-04 11:47:26 24 4
gpt4 key购买 nike

我得到以下代码。

typedef struct _display {
int fd; /* Network socket. */
Window root; /* Root window id. */
int vnumber; /* X protocol version number. */
int dtype; /* X server display device type. */
int dplanes; /* Number of display bit planes. */
int dcells; /* Number of display color map cells. */
_QEvent *head, *tail; /* Input event queue. */
int qlen; /* Length of input event queue */
int request; /* Id of last request. */
char * lastdraw; /* Last draw request. */
char *buffer; /* Output buffer starting address. */
char *bufptr; /* Output buffer index pointer. */
char *bufmax; /* Output buffer maximum+1 address. */
int squish; /* Squish MouseMoved events? */
Pixmap black, white; /* Constant tile pixmaps */
char *displayname; /* "host:display" string used on this connect*/
int width, height; /* width and height of display */
} Display;

但我不明白的是 X 获取显示器宽度和高度的位置。有没有人碰巧知道答案,或者能够为我指明正确的方向?

谢谢阿奇

最佳答案

为什么不获取根窗口的属性?

XWindowAttributes ra;
XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra);
w = ra.width;
h = ra.height;

关于c - 如何在C中获取屏幕的高度和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14526522/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com