2 * $ TOG: xdpyinfo.c /main/35 1998/02/09 13:57:05 kaleb $
4 * xdpyinfo - print information about X display connecton
7 Copyright 1988, 1998 The Open Group
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 * Author: Jim Fulton, MIT X Consortium
27 * GLX and Overlay support added by Jamie Zawinski <jwz@jwz.org>, 11-Nov-99
30 * cc -DHAVE_GLX xdpyinfo.c -o xdpyinfo -lGL -lX11 -lXext -lm
32 * Other defines to consider:
33 * -DHAVE_XIE -DHAVE_XTEST -DHAVE_SYNC -DHAVE_XRECORD
37 #include <X11/Xutil.h>
38 #include <X11/Xproto.h> /* for CARD32 */
39 #include <X11/extensions/multibuf.h>
41 #include <X11/extensions/XIElib.h>
44 #include <X11/extensions/XTest.h>
45 #endif /* HAVE_XTEST */
47 #include <X11/extensions/sync.h>
48 #endif /* HAVE_XSYNC */
49 #include <X11/extensions/Xdbe.h>
51 #include <X11/extensions/record.h>
52 #endif /* HAVE_XRECORD */
54 #include <X11/extensions/XShm.h>
64 #define HAVE_OVERLAY /* jwz: no compile-time deps, so do this all the time */
67 Bool queryExtensions = False;
69 static int StrCmp(a, b)
72 return strcmp(*a, *b);
76 #ifdef HAVE_GLX /* Added by jwz, 11-Nov-99 */
79 print_glx_versions (dpy)
82 /* Note: with Mesa 3.0, this lies: it prints the info from the
83 client's GL library, rather than the info from the GLX server.
85 Note also that we can't protect these calls by only doing
86 them when the GLX extension is present, because with Mesa,
87 the server doesn't have that extension (but the GL library
90 int scr = DefaultScreen (dpy);
91 const char *vend, *vers;
92 vend = glXQueryServerString (dpy, scr, GLX_VENDOR);
94 vers = glXQueryServerString (dpy, scr, GLX_VERSION);
95 printf ("GLX vendor: %s (%s)\n",
96 vend, (vers ? vers : "unknown version"));
100 print_glx_visual_info (dpy, vip)
104 int status, value = False;
106 status = glXGetConfig (dpy, vip, GLX_USE_GL, &value);
107 if (status == GLX_NO_EXTENSION)
108 /* dpy does not support the GLX extension. */
111 if (status == GLX_BAD_VISUAL || value == False)
113 printf (" GLX supported: no\n");
118 printf (" GLX supported: yes\n");
121 if (!glXGetConfig (dpy, vip, GLX_LEVEL, &value) &&
123 printf (" GLX level: %d\n", value);
125 if (!glXGetConfig (dpy, vip, GLX_RGBA, &value) && value)
127 int r=0, g=0, b=0, a=0;
128 glXGetConfig (dpy, vip, GLX_RED_SIZE, &r);
129 glXGetConfig (dpy, vip, GLX_GREEN_SIZE, &g);
130 glXGetConfig (dpy, vip, GLX_BLUE_SIZE, &b);
131 glXGetConfig (dpy, vip, GLX_ALPHA_SIZE, &a);
132 printf (" GLX type: RGBA (%2d, %2d, %2d, %2d)\n",
136 glXGetConfig (dpy, vip, GLX_ACCUM_RED_SIZE, &r);
137 glXGetConfig (dpy, vip, GLX_ACCUM_GREEN_SIZE, &g);
138 glXGetConfig (dpy, vip, GLX_ACCUM_BLUE_SIZE, &b);
139 glXGetConfig (dpy, vip, GLX_ACCUM_ALPHA_SIZE, &a);
140 printf (" GLX accum: RGBA (%2d, %2d, %2d, %2d)\n",
146 glXGetConfig (dpy, vip, GLX_BUFFER_SIZE, &value);
147 printf (" GLX type: indexed (%d)\n", value);
150 # if 0 /* redundant */
151 if (!glXGetConfig (dpy, vip, GLX_X_VISUAL_TYPE_EXT, &value))
152 printf (" GLX class: %s\n",
153 (value == GLX_TRUE_COLOR_EXT ? "TrueColor" :
154 value == GLX_DIRECT_COLOR_EXT ? "DirectColor" :
155 value == GLX_PSEUDO_COLOR_EXT ? "PseudoColor" :
156 value == GLX_STATIC_COLOR_EXT ? "StaticColor" :
157 value == GLX_GRAY_SCALE_EXT ? "Grayscale" :
158 value == GLX_STATIC_GRAY_EXT ? "StaticGray" : "???"));
161 # ifdef GLX_VISUAL_CAVEAT_EXT
162 if (!glXGetConfig (dpy, vip, GLX_VISUAL_CAVEAT_EXT, &value) &&
163 value != GLX_NONE_EXT)
164 printf (" GLX rating: %s\n",
165 (value == GLX_NONE_EXT ? "none" :
166 value == GLX_SLOW_VISUAL_EXT ? "slow" :
167 # ifdef GLX_NON_CONFORMANT_EXT
168 value == GLX_NON_CONFORMANT_EXT ? "non-conformant" :
173 if (!glXGetConfig (dpy, vip, GLX_DOUBLEBUFFER, &value))
174 printf (" GLX double-buffer: %s\n", (value ? "yes" : "no"));
176 if (!glXGetConfig (dpy, vip, GLX_STEREO, &value) &&
178 printf (" GLX stereo: %s\n", (value ? "yes" : "no"));
180 if (!glXGetConfig (dpy, vip, GLX_AUX_BUFFERS, &value) &&
182 printf (" GLX aux buffers: %d\n", value);
184 if (!glXGetConfig (dpy, vip, GLX_DEPTH_SIZE, &value))
185 printf (" GLX depth size: %d\n", value);
187 if (!glXGetConfig (dpy, vip, GLX_STENCIL_SIZE, &value) &&
189 printf (" GLX stencil size: %d\n", value);
191 # ifdef GLX_SAMPLE_BUFFERS_SGIS
192 if (!glXGetConfig (dpy, vip, GLX_SAMPLE_BUFFERS_SGIS, &value) &&
196 if (!glXGetConfig (dpy, vip, GLX_SAMPLES_SGIS, &value))
197 printf (" GLX multisamplers: %d (%d)\n", bufs, value);
201 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_TYPE_EXT, &value) &&
202 value != GLX_NONE_EXT)
204 if (value == GLX_NONE_EXT)
205 printf (" GLX transparency: none\n");
206 else if (value == GLX_TRANSPARENT_INDEX_EXT)
208 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_INDEX_VALUE_EXT,&value))
209 printf (" GLX transparency: indexed (%d)\n", value);
211 else if (value == GLX_TRANSPARENT_RGB_EXT)
213 int r=0, g=0, b=0, a=0;
214 glXGetConfig (dpy, vip, GLX_TRANSPARENT_RED_VALUE_EXT, &r);
215 glXGetConfig (dpy, vip, GLX_TRANSPARENT_GREEN_VALUE_EXT, &g);
216 glXGetConfig (dpy, vip, GLX_TRANSPARENT_BLUE_VALUE_EXT, &b);
217 glXGetConfig (dpy, vip, GLX_TRANSPARENT_ALPHA_VALUE_EXT, &a);
218 printf (" GLX transparency: RGBA (%2d, %2d, %2d, %2d)\n",
223 #endif /* HAVE_GLX */
226 #ifdef HAVE_OVERLAY /* Added by jwz, 11-Nov-99 */
228 /* If the server's root window contains a SERVER_OVERLAY_VISUALS property,
229 then that identifies the visuals which correspond to the video hardware's
230 overlay planes. Windows created in these kinds of visuals may have
231 transparent pixels that let other layers shine through.
233 This might not be an X Consortium standard, but it turns out that
234 SGI, HP, DEC, and IBM all use this same mechanism. So that's close
237 Documentation on the SERVER_OVERLAY_VISUALS property can be found at:
238 http://www.hp.com/xwindow/sharedInfo/Whitepapers/Visuals/server_overlay_visuals.html
244 CARD32 transparency; /* 0: none; 1: pixel; 2: mask */
245 CARD32 value; /* the transparent pixel */
246 CARD32 layer; /* -1: underlay; 0: normal; 1: popup; 2: overlay */
252 struct overlay *list;
255 static struct overlay_list *overlays = 0;
258 find_overlay_info (dpy)
262 Atom OVERLAY = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False);
264 overlays = (struct overlay_list *) calloc (sizeof (struct overlay_list),
267 for (screen = 0; screen < ScreenCount (dpy); screen++)
269 Window window = RootWindow (dpy, screen);
272 unsigned long nitems, bytes_after;
273 struct overlay *data = 0;
274 int result = XGetWindowProperty (dpy, window, OVERLAY,
275 0, (65536 / sizeof (long)), False,
276 OVERLAY, &actual_type, &actual_format,
277 &nitems, &bytes_after,
278 (unsigned char **) &data);
279 if (result == Success &&
280 actual_type == OVERLAY &&
281 actual_format == 32 &&
284 overlays[screen].count = (nitems /
285 (sizeof(struct overlay) / sizeof(CARD32)));
286 overlays[screen].list = data;
289 XFree((char *) data);
294 print_overlay_visual_info (vip)
298 int vis = vip->visualid;
299 int scr = vip->screen;
300 if (!overlays) return;
301 for (i = 0; i < overlays[scr].count; i++)
302 if (vis == overlays[scr].list[i].visual_id)
304 struct overlay *ov = &overlays[scr].list[i];
305 printf (" Overlay info: layer %ld (%s), ",
307 (ov->layer == -1 ? "underlay" :
308 ov->layer == 0 ? "normal" :
309 ov->layer == 1 ? "popup" :
310 ov->layer == 2 ? "overlay" : "???"));
311 if (ov->transparency == 1)
312 printf ("transparent pixel %lu\n", (unsigned long) ov->value);
313 else if (ov->transparency == 2)
314 printf ("transparent mask 0x%x\n", (unsigned long) ov->value);
319 #endif /* HAVE_OVERLAY */
323 print_extension_info (dpy)
327 char **extlist = XListExtensions (dpy, &n);
329 printf ("number of extensions: %d\n", n);
333 int opcode, event, error;
335 qsort(extlist, n, sizeof(char *), StrCmp);
336 for (i = 0; i < n; i++) {
337 if (!queryExtensions) {
338 printf (" %s\n", extlist[i]);
341 XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
342 printf (" %s (opcode: %d", extlist[i], opcode);
344 printf (", base event: %d", event);
346 printf (", base error: %d", error);
349 /* do not free, Xlib can depend on contents being unaltered */
350 /* XFreeExtensionList (extlist); */
355 print_display_info (dpy)
360 int minkeycode, maxkeycode;
363 XPixmapFormatValues *pmf;
367 printf ("name of display: %s\n", DisplayString (dpy));
368 printf ("version number: %d.%d\n",
369 ProtocolVersion (dpy), ProtocolRevision (dpy));
370 printf ("vendor string: %s\n", ServerVendor (dpy));
371 printf ("vendor release number: %d\n", VendorRelease (dpy));
374 print_glx_versions (dpy);
375 #endif /* HAVE_GLX */
377 req_size = XExtendedMaxRequestSize (dpy);
378 if (!req_size) req_size = XMaxRequestSize (dpy);
379 printf ("maximum request size: %ld bytes\n", req_size * 4);
380 printf ("motion buffer size: %d\n", XDisplayMotionBufferSize (dpy));
382 switch (BitmapBitOrder (dpy)) {
383 case LSBFirst: cp = "LSBFirst"; break;
384 case MSBFirst: cp = "MSBFirst"; break;
386 sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
390 printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
391 BitmapUnit (dpy), cp, BitmapPad (dpy));
393 switch (ImageByteOrder (dpy)) {
394 case LSBFirst: cp = "LSBFirst"; break;
395 case MSBFirst: cp = "MSBFirst"; break;
397 sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
401 printf ("image byte order: %s\n", cp);
403 pmf = XListPixmapFormats (dpy, &n);
404 printf ("number of supported pixmap formats: %d\n", n);
406 printf ("supported pixmap formats:\n");
407 for (i = 0; i < n; i++) {
408 printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
409 pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
411 XFree ((char *) pmf);
416 * when we get interfaces to the PixmapFormat stuff, insert code here
419 XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
420 printf ("keycode range: minimum %d, maximum %d\n",
421 minkeycode, maxkeycode);
423 XGetInputFocus (dpy, &focuswin, &focusrevert);
427 printf ("PointerRoot\n");
433 printf("window 0x%lx, revert to ", focuswin);
434 switch (focusrevert) {
441 case RevertToPointerRoot:
442 printf ("PointerRoot\n");
444 default: /* should not happen */
445 printf ("%d\n", focusrevert);
451 print_extension_info (dpy);
453 printf ("default screen number: %d\n", DefaultScreen (dpy));
454 printf ("number of screens: %d\n", ScreenCount (dpy));
458 print_visual_info (vip)
461 char errorbuf[40]; /* for sprintfing into */
462 char *class = NULL; /* for printing */
464 switch (vip->class) {
465 case StaticGray: class = "StaticGray"; break;
466 case GrayScale: class = "GrayScale"; break;
467 case StaticColor: class = "StaticColor"; break;
468 case PseudoColor: class = "PseudoColor"; break;
469 case TrueColor: class = "TrueColor"; break;
470 case DirectColor: class = "DirectColor"; break;
472 sprintf (errorbuf, "unknown class %d", vip->class);
477 printf (" visual:\n");
478 printf (" visual id: 0x%lx\n", vip->visualid);
479 printf (" class: %s\n", class);
480 printf (" depth: %d plane%s\n", vip->depth,
481 vip->depth == 1 ? "" : "s");
482 if (vip->class == TrueColor || vip->class == DirectColor)
483 printf (" available colormap entries: %d per subfield\n",
486 printf (" available colormap entries: %d\n",
488 printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
489 vip->red_mask, vip->green_mask, vip->blue_mask);
490 printf (" significant bits in color specification: %d bits\n",
495 print_screen_info (dpy, scr)
499 Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
500 XVisualInfo viproto; /* fill in for getting info */
501 XVisualInfo *vip; /* retured info */
502 int nvi; /* number of elements returned */
503 int i; /* temp variable: iterator */
504 char eventbuf[80]; /* want 79 chars per line + nul */
505 static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
507 int ndepths = 0, *depths = NULL;
508 unsigned int width, height;
512 * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
514 * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
515 * = N pixels / (M inch / 25.4)
516 * = N * 25.4 pixels / M inch
519 xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
520 ((double) DisplayWidthMM(dpy,scr)));
521 yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
522 ((double) DisplayHeightMM(dpy,scr)));
525 printf ("screen #%d:\n", scr);
526 printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
527 DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
528 DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));
529 printf (" resolution: %dx%d dots per inch\n",
530 (int) (xres + 0.5), (int) (yres + 0.5));
531 depths = XListDepths (dpy, scr, &ndepths);
532 if (!depths) ndepths = 0;
533 printf (" depths (%d): ", ndepths);
534 for (i = 0; i < ndepths; i++) {
535 printf ("%d", depths[i]);
536 if (i < ndepths - 1) {
542 if (depths) XFree ((char *) depths);
543 printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
544 printf (" depth of root window: %d plane%s\n",
545 DisplayPlanes (dpy, scr),
546 DisplayPlanes (dpy, scr) == 1 ? "" : "s");
547 printf (" number of colormaps: minimum %d, maximum %d\n",
548 MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
549 printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
550 printf (" default number of colormap cells: %d\n",
551 DisplayCells (dpy, scr));
552 printf (" preallocated pixels: black %d, white %d\n",
553 BlackPixel (dpy, scr), WhitePixel (dpy, scr));
554 printf (" options: backing-store %s, save-unders %s\n",
555 (DoesBackingStore (s) == NotUseful) ? no :
556 ((DoesBackingStore (s) == Always) ? yes : when),
557 DoesSaveUnders (s) ? yes : no);
558 XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
560 if (width == 65535 && height == 65535)
561 printf (" largest cursor: unlimited\n");
563 printf (" largest cursor: %dx%d\n", width, height);
564 printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
565 (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
569 viproto.screen = scr;
570 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
571 printf (" number of visuals: %d\n", nvi);
572 printf (" default visual id: 0x%lx\n",
573 XVisualIDFromVisual (DefaultVisual (dpy, scr)));
574 for (i = 0; i < nvi; i++) {
575 print_visual_info (vip+i);
577 print_overlay_visual_info (vip+i);
578 #endif /* HAVE_OVERLAY */
580 print_glx_visual_info (dpy, vip+i);
581 #endif /* HAVE_GLX */
583 if (vip) XFree ((char *) vip);
587 * The following routine prints out an event mask, wrapping events at nice
591 #define MASK_NAME_WIDTH 25
593 static struct _event_table {
597 { "KeyPressMask ", KeyPressMask },
598 { "KeyReleaseMask ", KeyReleaseMask },
599 { "ButtonPressMask ", ButtonPressMask },
600 { "ButtonReleaseMask ", ButtonReleaseMask },
601 { "EnterWindowMask ", EnterWindowMask },
602 { "LeaveWindowMask ", LeaveWindowMask },
603 { "PointerMotionMask ", PointerMotionMask },
604 { "PointerMotionHintMask ", PointerMotionHintMask },
605 { "Button1MotionMask ", Button1MotionMask },
606 { "Button2MotionMask ", Button2MotionMask },
607 { "Button3MotionMask ", Button3MotionMask },
608 { "Button4MotionMask ", Button4MotionMask },
609 { "Button5MotionMask ", Button5MotionMask },
610 { "ButtonMotionMask ", ButtonMotionMask },
611 { "KeymapStateMask ", KeymapStateMask },
612 { "ExposureMask ", ExposureMask },
613 { "VisibilityChangeMask ", VisibilityChangeMask },
614 { "StructureNotifyMask ", StructureNotifyMask },
615 { "ResizeRedirectMask ", ResizeRedirectMask },
616 { "SubstructureNotifyMask ", SubstructureNotifyMask },
617 { "SubstructureRedirectMask ", SubstructureRedirectMask },
618 { "FocusChangeMask ", FocusChangeMask },
619 { "PropertyChangeMask ", PropertyChangeMask },
620 { "ColormapChangeMask ", ColormapChangeMask },
621 { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
624 int print_event_mask (buf, lastcol, indent, mask)
625 char *buf; /* string to write into */
626 int lastcol; /* strlen(buf)+1 */
627 int indent; /* amount by which to indent */
628 long mask; /* event mask */
630 struct _event_table *etp;
634 buf[0] = buf[lastcol] = '\0'; /* just in case */
636 #define INDENT() { register int i; len = indent; \
637 for (i = 0; i < indent; i++) buf[i] = ' '; }
641 for (etp = event_table; etp->name; etp++) {
642 if (mask & etp->value) {
643 if (len + MASK_NAME_WIDTH > lastcol) {
647 strcpy (buf+len, etp->name);
648 len += MASK_NAME_WIDTH;
653 if (bitsfound) puts (buf);
661 print_standard_extension_info(dpy, extname, majorrev, minorrev)
664 int majorrev, minorrev;
666 int opcode, event, error;
668 printf("%s version %d.%d ", extname, majorrev, minorrev);
670 XQueryExtension(dpy, extname, &opcode, &event, &error);
671 printf ("opcode: %d", opcode);
673 printf (", base event: %d", event);
675 printf (", base error: %d", error);
680 print_multibuf_info(dpy, extname)
684 int i, j; /* temp variable: iterator */
685 int nmono, nstereo; /* count */
686 XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
688 " visual id, max buffers, depth: 0x%lx, %d, %d\n";
690 int majorrev, minorrev;
692 if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
695 print_standard_extension_info(dpy, extname, majorrev, minorrev);
697 for (i = 0; i < ScreenCount (dpy); i++)
699 if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
700 &nstereo, &stereo_info)) {
702 "%s: unable to get multibuffer info for screen %d\n",
705 printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
706 for (j = 0; j < nmono; j++) {
707 printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
710 printf (" number of stereo multibuffer types: %d\n", nstereo);
711 for (j = 0; j < nstereo; j++) {
712 printf (fmt, stereo_info[j].visualid,
713 stereo_info[j].max_buffers, stereo_info[j].depth);
715 if (mono_info) XFree ((char *) mono_info);
716 if (stereo_info) XFree ((char *) stereo_info);
720 } /* end print_multibuf_info */
727 char *subset_names[] = { NULL, "FULL", "DIS" };
728 char *align_names[] = { NULL, "Alignable", "Arbitrary" };
729 char *group_names[] = { /* 0 */ "Default",
730 /* 2 */ "ColorAlloc",
732 /* 6 */ "ConvertFromRGB",
733 /* 8 */ "ConvertToRGB",
740 /* 22 */ "Histogram",
741 /* 24 */ "WhiteAdjust"
745 print_xie_info(dpy, extname)
749 XieExtensionInfo *xieInfo;
753 XieTechniqueGroup prevGroup;
755 if (!XieInitialize(dpy, &xieInfo ))
758 print_standard_extension_info(dpy, extname,
759 xieInfo->server_major_rev, xieInfo->server_minor_rev);
761 printf(" service class: %s\n", subset_names[xieInfo->service_class]);
762 printf(" alignment: %s\n", align_names[xieInfo->alignment]);
763 printf(" uncnst_mantissa: %d\n", xieInfo->uncnst_mantissa);
764 printf(" uncnst_min_exp: %d\n", xieInfo->uncnst_min_exp);
765 printf(" uncnst_max_exp: %d\n", xieInfo->uncnst_max_exp);
766 printf(" cnst_levels:");
767 for (i = 0; i < xieInfo->n_cnst_levels; i++)
768 printf(" %d", xieInfo->cnst_levels[i]);
771 if (!XieQueryTechniques(dpy, xieValAll, &ntechs, &techs))
776 for (i = 0; i < ntechs; i++)
778 if (techs[i].group != prevGroup)
780 printf(" technique group: %s\n", group_names[techs[i].group >> 1]);
781 prevGroup = techs[i].group;
783 printf(" %s\tspeed: %d needs_param: %s number: %d\n",
785 techs[i].speed, (techs[i].needs_param ? "True " : "False"),
789 } /* end print_xie_info */
791 #endif /* HAVE_XIE */
796 print_xtest_info(dpy, extname)
800 int majorrev, minorrev, foo;
802 if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
804 print_standard_extension_info(dpy, extname, majorrev, minorrev);
807 #endif /* HAVE_XTEST */
811 print_sync_info(dpy, extname)
815 int majorrev, minorrev;
816 XSyncSystemCounter *syscounters;
819 if (!XSyncInitialize(dpy, &majorrev, &minorrev))
821 print_standard_extension_info(dpy, extname, majorrev, minorrev);
823 syscounters = XSyncListSystemCounters(dpy, &ncounters);
824 printf(" system counters: %d\n", ncounters);
825 for (i = 0; i < ncounters; i++)
827 printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
828 syscounters[i].name, syscounters[i].counter,
829 XSyncValueLow32(syscounters[i].resolution),
830 XSyncValueHigh32(syscounters[i].resolution));
832 XSyncFreeSystemCounterList(syscounters);
835 #endif /* HAVE_XSYNC */
838 print_shape_info(dpy, extname)
842 int majorrev, minorrev;
844 if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
846 print_standard_extension_info(dpy, extname, majorrev, minorrev);
852 print_mitshm_info(dpy, extname)
856 int majorrev, minorrev;
859 if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
861 print_standard_extension_info(dpy, extname, majorrev, minorrev);
862 printf(" shared pixmaps: ");
865 int format = XShmPixmapFormat(dpy);
866 printf("yes, format: %d\n", format);
877 print_dbe_info(dpy, extname)
881 int majorrev, minorrev;
882 XdbeScreenVisualInfo *svi;
886 if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
889 print_standard_extension_info(dpy, extname, majorrev, minorrev);
890 svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
891 for (iscrn = 0; iscrn < numscreens; iscrn++)
893 printf(" Double-buffered visuals on screen %d\n", iscrn);
894 for (ivis = 0; ivis < svi[iscrn].count; ivis++)
896 printf(" visual id 0x%lx depth %d perflevel %d\n",
897 svi[iscrn].visinfo[ivis].visual,
898 svi[iscrn].visinfo[ivis].depth,
899 svi[iscrn].visinfo[ivis].perflevel);
902 XdbeFreeVisualInfo(svi);
908 print_record_info(dpy, extname)
912 int majorrev, minorrev;
914 if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
916 print_standard_extension_info(dpy, extname, majorrev, minorrev);
919 #endif /* HAVE_XRECORD */
921 /* utilities to manage the list of recognized extensions */
924 typedef int (*ExtensionPrintFunc)(
925 #if NeedFunctionPrototypes
932 ExtensionPrintFunc printfunc;
934 } ExtensionPrintInfo;
936 ExtensionPrintInfo known_extensions[] =
939 {"MIT-SHM", print_mitshm_info, False},
941 {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
942 {"SHAPE", print_shape_info, False},
944 {SYNC_NAME, print_sync_info, False},
945 #endif /* HAVE_XSYNC */
947 {xieExtName, print_xie_info, False},
948 #endif /* HAVE_XIE */
950 {XTestExtensionName, print_xtest_info, False},
951 #endif /* HAVE_XTEST */
952 {"DOUBLE-BUFFER", print_dbe_info, False},
954 {"RECORD", print_record_info, False}
955 #endif /* HAVE_XRECORD */
956 /* add new extensions here */
957 /* wish list: PEX XKB LBX */
960 int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
963 print_known_extensions(f)
967 for (i = 0; i < num_known_extensions; i++)
969 fprintf(f, "%s ", known_extensions[i].extname);
974 mark_extension_for_printing(extname)
979 if (strcmp(extname, "all") == 0)
981 for (i = 0; i < num_known_extensions; i++)
982 known_extensions[i].printit = True;
986 for (i = 0; i < num_known_extensions; i++)
988 if (strcmp(extname, known_extensions[i].extname) == 0)
990 known_extensions[i].printit = True;
994 printf("%s extension not supported by %s\n", extname, ProgramName);
999 print_marked_extensions(dpy)
1003 for (i = 0; i < num_known_extensions; i++)
1005 if (known_extensions[i].printit)
1008 if (! (*known_extensions[i].printfunc)(dpy,
1009 known_extensions[i].extname))
1011 printf("%s extension not supported by server\n",
1012 known_extensions[i].extname);
1018 static void usage ()
1020 fprintf (stderr, "usage: %s [options]\n", ProgramName);
1021 fprintf (stderr, "-display displayname\tserver to query\n");
1022 fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
1023 fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
1024 fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
1025 print_known_extensions(stderr);
1026 fprintf (stderr, "\n");
1030 int main (argc, argv)
1034 Display *dpy; /* X connection */
1035 char *displayname = NULL; /* server to contact */
1036 int i; /* temp variable: iterator */
1037 Bool multibuf = False;
1038 int mbuf_event_base, mbuf_error_base;
1040 ProgramName = argv[0];
1042 for (i = 1; i < argc; i++) {
1043 char *arg = argv[i];
1044 int len = strlen(arg);
1046 if (!strncmp("-display", arg, len)) {
1047 if (++i >= argc) usage ();
1048 displayname = argv[i];
1049 } else if (!strncmp("-queryExtensions", arg, len)) {
1050 queryExtensions = True;
1051 } else if (!strncmp("-ext", arg, len)) {
1052 if (++i >= argc) usage ();
1053 mark_extension_for_printing(argv[i]);
1058 dpy = XOpenDisplay (displayname);
1060 fprintf (stderr, "%s: unable to open display \"%s\".\n",
1061 ProgramName, XDisplayName (displayname));
1066 find_overlay_info (dpy);
1067 #endif /* HAVE_OVERLAY */
1069 print_display_info (dpy);
1070 for (i = 0; i < ScreenCount (dpy); i++) {
1071 print_screen_info (dpy, i);
1074 print_marked_extensions(dpy);
1076 XCloseDisplay (dpy);