blob: adbd38a43075d317239619ea38248f71bb3e6fb4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
int main(int argc, char **argv)
{
Display *dpy;
XineramaScreenInfo *xsi;
int i, nscreens;
dpy = XOpenDisplay(NULL);
if (dpy == NULL) {
fputs("ERROR: Could not open display!\n", stderr);
return EXIT_FAILURE;
}
/* Is xinerama extension available? */
if (!XineramaIsActive(dpy)) {
fputs("ERROR: Xinerama extension unavailable on current screen!\n", stderr);
return EXIT_FAILURE;
}
else {
xsi = XineramaQueryScreens(dpy, &nscreens);
if (argc <= 1) {
for (i = 0; i < nscreens; i++) {
printf("screen %d: %dx%d\n", i, xsi[i].width, xsi[i].height);
}
}
else {
i = atoi(argv[1]);
if (i <= 0 || i > nscreens) {
fprintf(stderr, "ERROR: Screen %d not available!\n", i);
return EXIT_FAILURE;
}
else
printf("%dx%d\n", xsi[i-1].width, xsi[i-1].height);
}
}
return EXIT_SUCCESS;
}
|