Чтобы получить разрешение экрана, вы можете использовать расширение XRandR, как в xrandr sources:
SizeID current_size;
XRRScreenSize *sizes;
dpy = XOpenDisplay (display_name);
// ...
root = RootWindow (dpy, screen);
sc = XRRGetScreenInfo (dpy, root);
current_size = XRRConfigCurrentConfiguration (sc, ¤t_rotation);
sizes = XRRConfigSizes(sc, &nsize);
for (i = 0; i < nsize; i++) {
printf ("%c%-2d %5d x %-5d (%4dmm x%4dmm )",
i == current_size ? '*' : ' ',
i, sizes[i].width, sizes[i].height,
sizes[i].mwidth, sizes[i].mheight);
// ...
}
Вы можете увидеть вывод команды «xrandr» в вашем xterm.
Или, лучше, используйте метод xdpyinfo :
Display *dpy;
// dpy = ...
int scr = /* ... */
printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));