1 /* test-xinerama.c --- playing with the Xinerama extension.
2 * xscreensaver, Copyright (c) 2003 Jamie Zawinski <jwz@jwz.org>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
27 #include <X11/Xatom.h>
28 #include <X11/Intrinsic.h>
30 #include <X11/Xproto.h>
31 #include <X11/extensions/Xinerama.h>
34 char *progclass = "XScreenSaver";
40 time_t now = time ((time_t *) 0);
41 char *ct = (char *) ctime (&now);
42 int n = strlen(progname);
44 strncpy(buf, progname, n);
47 strncpy(buf+n, ct+11, 8);
48 strcpy(buf+n+9, ": ");
54 main (int argc, char **argv)
56 int event_number, error_number;
59 XineramaScreenInfo *xsi;
63 Widget toplevel_shell = XtAppInitialize (&app, progclass, 0, 0,
64 &argc, argv, 0, 0, 0);
65 Display *dpy = XtDisplay (toplevel_shell);
66 XtGetApplicationNameAndClass (dpy, &progname, &progclass);
68 if (!XineramaQueryExtension(dpy, &event_number, &error_number))
70 fprintf(stderr, "%s: XineramaQueryExtension(dpy, ...) ==> False\n",
72 fprintf(stderr, "%s: server does not support the Xinerama extension.\n",
77 fprintf(stderr, "%s: XineramaQueryExtension(dpy, ...) ==> %d, %d\n",
78 blurb(), event_number, error_number);
80 if (!XineramaIsActive(dpy))
82 fprintf(stderr, "%s: XineramaIsActive(dpy) ==> False\n", blurb());
83 fprintf(stderr, "%s: server says Xinerama is turned off.\n", blurb());
87 fprintf(stderr, "%s: XineramaIsActive(dpy) ==> True\n", blurb());
89 if (!XineramaQueryVersion(dpy, &major, &minor))
91 fprintf(stderr, "%s: XineramaQueryVersion(dpy, ...) ==> False\n",
93 fprintf(stderr, "%s: server didn't report Xinerama version numbers?\n",
97 fprintf(stderr, "%s: XineramaQueryVersion(dpy, ...) ==> %d, %d\n", blurb(),
100 xsi = XineramaQueryScreens (dpy, &nscreens);
101 fprintf(stderr, "%s: %d Xinerama screens\n", blurb(), nscreens);
103 for (i = 0; i < nscreens; i++)
104 fprintf (stderr, "%s: screen %d: %dx%d+%d+%d\n",
106 xsi[i].screen_number,
107 xsi[i].width, xsi[i].height,
108 xsi[i].x_org, xsi[i].y_org);