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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* Copyright (C) 2008, Kristian Lyngstol <kristian@bohemians.org>
*
* GNU GPLv2 goes here.
*
* Tiny utility app to fetch xinerama info.
*
* Coding style per compiz... Please don't hurt me.
*/
#include <stdio.h>
#include <X11/extensions/Xinerama.h>
#include <X11/Xlib.h>
#include <stdlib.h>
int xineramaEvent, xineramaError;
int majorVersion, minorVersion;
Display *dpy;
XineramaScreenInfo *screenInfo;
int nScreenInfo;
void bail(char *str)
{
perror ("The flux capacitor is broken! Bailing!");
perror (str);
exit (1);
}
void verbose (char *str)
{
printf (str);
}
void printVersion ()
{
Status ret;
ret = XineramaQueryVersion (dpy, &majorVersion, &minorVersion);
printf ("Xinerama version: %d.%d\n", majorVersion,minorVersion);
if (!ret)
bail ("Incompatible xinerama version. XineramaQueryVersion failed!");
}
int main (int argc, char **argv)
{
Bool ret;
dpy = XOpenDisplay (0);
if (!dpy)
bail ("Couldn't open display. OH WOE IS ME.");
ret = XineramaQueryExtension (dpy, &xineramaEvent, &xineramaError);
if (!ret)
bail ("No xinerama extension");
printVersion ();
verbose ("Attempting to get screen info.\n");
screenInfo = XineramaQueryScreens (dpy, &nScreenInfo);
int i;
if (nScreenInfo == 0)
verbose ("Only 0 heads? HELP THIS DOES NOT MAKE SENSE. I think. right.\n");
printf ("Screen\tx_org\ty_org\twidth\theight\n");
for (i = 0; i < nScreenInfo; i++)
printf ("%d\t%d\t%d\t%d\t%d\n",
screenInfo[i].screen_number,
screenInfo[i].x_org,
screenInfo[i].y_org,
screenInfo[i].width,
screenInfo[i].height);
verbose ("Gee, that's all. Thanks for tuning in.\n");
return 0;
}
|