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 [-lXtst] -lm
32 * Other defines to consider:
33 * -DMITSHM -DHAVE_XDBE -DHAVE_XIE -DHAVE_XTEST -DHAVE_SYNC
38 #include <X11/Xutil.h>
39 #include <X11/Xproto.h> /* for CARD32 */
40 #include <X11/extensions/multibuf.h>
42 #include <X11/extensions/XIElib.h>
45 #include <X11/extensions/XTest.h>
46 #endif /* HAVE_XTEST */
48 #include <X11/extensions/sync.h>
49 #endif /* HAVE_XSYNC */
51 #include <X11/extensions/Xdbe.h>
52 #endif /* HAVE_XDBE */
54 #include <X11/extensions/record.h>
55 #endif /* HAVE_XRECORD */
57 #include <X11/extensions/XShm.h>
67 #define HAVE_OVERLAY /* jwz: no compile-time deps, so do this all the time */
70 Bool queryExtensions = False;
72 static int StrCmp(a, b)
75 return strcmp(*a, *b);
79 #ifdef HAVE_GLX /* Added by jwz, 11-Nov-99 */
82 print_glx_versions (dpy)
85 /* Note: with Mesa 3.0, this lies: it prints the info from the
86 client's GL library, rather than the info from the GLX server.
88 Note also that we can't protect these calls by only doing
89 them when the GLX extension is present, because with Mesa,
90 the server doesn't have that extension (but the GL library
93 int scr = DefaultScreen (dpy);
94 const char *vend, *vers;
95 vend = glXQueryServerString (dpy, scr, GLX_VENDOR);
97 vers = glXQueryServerString (dpy, scr, GLX_VERSION);
98 printf ("GLX vendor: %s (%s)\n",
99 vend, (vers ? vers : "unknown version"));
103 print_glx_visual_info (dpy, vip)
107 int status, value = False;
109 status = glXGetConfig (dpy, vip, GLX_USE_GL, &value);
110 if (status == GLX_NO_EXTENSION)
111 /* dpy does not support the GLX extension. */
114 if (status == GLX_BAD_VISUAL || value == False)
116 printf (" GLX supported: no\n");
121 printf (" GLX supported: yes\n");
124 if (!glXGetConfig (dpy, vip, GLX_LEVEL, &value) &&
126 printf (" GLX level: %d\n", value);
128 if (!glXGetConfig (dpy, vip, GLX_RGBA, &value) && value)
130 int r=0, g=0, b=0, a=0;
131 glXGetConfig (dpy, vip, GLX_RED_SIZE, &r);
132 glXGetConfig (dpy, vip, GLX_GREEN_SIZE, &g);
133 glXGetConfig (dpy, vip, GLX_BLUE_SIZE, &b);
134 glXGetConfig (dpy, vip, GLX_ALPHA_SIZE, &a);
135 printf (" GLX type: RGBA (%2d, %2d, %2d, %2d)\n",
139 glXGetConfig (dpy, vip, GLX_ACCUM_RED_SIZE, &r);
140 glXGetConfig (dpy, vip, GLX_ACCUM_GREEN_SIZE, &g);
141 glXGetConfig (dpy, vip, GLX_ACCUM_BLUE_SIZE, &b);
142 glXGetConfig (dpy, vip, GLX_ACCUM_ALPHA_SIZE, &a);
143 printf (" GLX accum: RGBA (%2d, %2d, %2d, %2d)\n",
149 glXGetConfig (dpy, vip, GLX_BUFFER_SIZE, &value);
150 printf (" GLX type: indexed (%d)\n", value);
153 # if 0 /* redundant */
154 if (!glXGetConfig (dpy, vip, GLX_X_VISUAL_TYPE_EXT, &value))
155 printf (" GLX class: %s\n",
156 (value == GLX_TRUE_COLOR_EXT ? "TrueColor" :
157 value == GLX_DIRECT_COLOR_EXT ? "DirectColor" :
158 value == GLX_PSEUDO_COLOR_EXT ? "PseudoColor" :
159 value == GLX_STATIC_COLOR_EXT ? "StaticColor" :
160 value == GLX_GRAY_SCALE_EXT ? "Grayscale" :
161 value == GLX_STATIC_GRAY_EXT ? "StaticGray" : "???"));
164 # ifdef GLX_VISUAL_CAVEAT_EXT
165 if (!glXGetConfig (dpy, vip, GLX_VISUAL_CAVEAT_EXT, &value) &&
166 value != GLX_NONE_EXT)
167 printf (" GLX rating: %s\n",
168 (value == GLX_NONE_EXT ? "none" :
169 value == GLX_SLOW_VISUAL_EXT ? "slow" :
170 # ifdef GLX_NON_CONFORMANT_EXT
171 value == GLX_NON_CONFORMANT_EXT ? "non-conformant" :
176 if (!glXGetConfig (dpy, vip, GLX_DOUBLEBUFFER, &value))
177 printf (" GLX double-buffer: %s\n", (value ? "yes" : "no"));
179 if (!glXGetConfig (dpy, vip, GLX_STEREO, &value) &&
181 printf (" GLX stereo: %s\n", (value ? "yes" : "no"));
183 if (!glXGetConfig (dpy, vip, GLX_AUX_BUFFERS, &value) &&
185 printf (" GLX aux buffers: %d\n", value);
187 if (!glXGetConfig (dpy, vip, GLX_DEPTH_SIZE, &value))
188 printf (" GLX depth size: %d\n", value);
190 if (!glXGetConfig (dpy, vip, GLX_STENCIL_SIZE, &value) &&
192 printf (" GLX stencil size: %d\n", value);
194 # ifdef GLX_SAMPLE_BUFFERS_SGIS
195 if (!glXGetConfig (dpy, vip, GLX_SAMPLE_BUFFERS_SGIS, &value) &&
199 if (!glXGetConfig (dpy, vip, GLX_SAMPLES_SGIS, &value))
200 printf (" GLX multisamplers: %d (%d)\n", bufs, value);
204 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_TYPE_EXT, &value) &&
205 value != GLX_NONE_EXT)
207 if (value == GLX_NONE_EXT)
208 printf (" GLX transparency: none\n");
209 else if (value == GLX_TRANSPARENT_INDEX_EXT)
211 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_INDEX_VALUE_EXT,&value))
212 printf (" GLX transparency: indexed (%d)\n", value);
214 else if (value == GLX_TRANSPARENT_RGB_EXT)
216 int r=0, g=0, b=0, a=0;
217 glXGetConfig (dpy, vip, GLX_TRANSPARENT_RED_VALUE_EXT, &r);
218 glXGetConfig (dpy, vip, GLX_TRANSPARENT_GREEN_VALUE_EXT, &g);
219 glXGetConfig (dpy, vip, GLX_TRANSPARENT_BLUE_VALUE_EXT, &b);
220 glXGetConfig (dpy, vip, GLX_TRANSPARENT_ALPHA_VALUE_EXT, &a);
221 printf (" GLX transparency: RGBA (%2d, %2d, %2d, %2d)\n",
226 #endif /* HAVE_GLX */
229 #ifdef HAVE_OVERLAY /* Added by jwz, 11-Nov-99 */
231 /* If the server's root window contains a SERVER_OVERLAY_VISUALS property,
232 then that identifies the visuals which correspond to the video hardware's
233 overlay planes. Windows created in these kinds of visuals may have
234 transparent pixels that let other layers shine through.
236 This might not be an X Consortium standard, but it turns out that
237 SGI, HP, DEC, and IBM all use this same mechanism. So that's close
240 Documentation on the SERVER_OVERLAY_VISUALS property can be found at:
241 http://www.hp.com/xwindow/sharedInfo/Whitepapers/Visuals/server_overlay_visuals.html
247 CARD32 transparency; /* 0: none; 1: pixel; 2: mask */
248 CARD32 value; /* the transparent pixel */
249 CARD32 layer; /* -1: underlay; 0: normal; 1: popup; 2: overlay */
255 struct overlay *list;
258 static struct overlay_list *overlays = 0;
261 find_overlay_info (dpy)
265 Atom OVERLAY = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False);
267 overlays = (struct overlay_list *) calloc (sizeof (struct overlay_list),
270 for (screen = 0; screen < ScreenCount (dpy); screen++)
272 Window window = RootWindow (dpy, screen);
275 unsigned long nitems, bytes_after;
276 struct overlay *data = 0;
277 int result = XGetWindowProperty (dpy, window, OVERLAY,
278 0, (65536 / sizeof (long)), False,
279 OVERLAY, &actual_type, &actual_format,
280 &nitems, &bytes_after,
281 (unsigned char **) &data);
282 if (result == Success &&
283 actual_type == OVERLAY &&
284 actual_format == 32 &&
287 overlays[screen].count = (nitems /
288 (sizeof(struct overlay) / sizeof(CARD32)));
289 overlays[screen].list = data;
292 XFree((char *) data);
297 print_overlay_visual_info (vip)
301 int vis = vip->visualid;
302 int scr = vip->screen;
303 if (!overlays) return;
304 for (i = 0; i < overlays[scr].count; i++)
305 if (vis == overlays[scr].list[i].visual_id)
307 struct overlay *ov = &overlays[scr].list[i];
308 printf (" Overlay info: layer %ld (%s), ",
310 (ov->layer == -1 ? "underlay" :
311 ov->layer == 0 ? "normal" :
312 ov->layer == 1 ? "popup" :
313 ov->layer == 2 ? "overlay" : "???"));
314 if (ov->transparency == 1)
315 printf ("transparent pixel %lu\n", (unsigned long) ov->value);
316 else if (ov->transparency == 2)
317 printf ("transparent mask 0x%x\n", (unsigned long) ov->value);
322 #endif /* HAVE_OVERLAY */
326 print_extension_info (dpy)
330 char **extlist = XListExtensions (dpy, &n);
332 printf ("number of extensions: %d\n", n);
336 int opcode, event, error;
338 qsort(extlist, n, sizeof(char *), StrCmp);
339 for (i = 0; i < n; i++) {
340 if (!queryExtensions) {
341 printf (" %s\n", extlist[i]);
344 XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
345 printf (" %s (opcode: %d", extlist[i], opcode);
347 printf (", base event: %d", event);
349 printf (", base error: %d", error);
352 /* do not free, Xlib can depend on contents being unaltered */
353 /* XFreeExtensionList (extlist); */
358 print_display_info (dpy)
363 int minkeycode, maxkeycode;
366 XPixmapFormatValues *pmf;
370 printf ("name of display: %s\n", DisplayString (dpy));
371 printf ("version number: %d.%d\n",
372 ProtocolVersion (dpy), ProtocolRevision (dpy));
373 printf ("vendor string: %s\n", ServerVendor (dpy));
374 printf ("vendor release number: %d\n", VendorRelease (dpy));
377 print_glx_versions (dpy);
378 #endif /* HAVE_GLX */
380 req_size = XExtendedMaxRequestSize (dpy);
381 if (!req_size) req_size = XMaxRequestSize (dpy);
382 printf ("maximum request size: %ld bytes\n", req_size * 4);
383 printf ("motion buffer size: %d\n", XDisplayMotionBufferSize (dpy));
385 switch (BitmapBitOrder (dpy)) {
386 case LSBFirst: cp = "LSBFirst"; break;
387 case MSBFirst: cp = "MSBFirst"; break;
389 sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
393 printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
394 BitmapUnit (dpy), cp, BitmapPad (dpy));
396 switch (ImageByteOrder (dpy)) {
397 case LSBFirst: cp = "LSBFirst"; break;
398 case MSBFirst: cp = "MSBFirst"; break;
400 sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
404 printf ("image byte order: %s\n", cp);
406 pmf = XListPixmapFormats (dpy, &n);
407 printf ("number of supported pixmap formats: %d\n", n);
409 printf ("supported pixmap formats:\n");
410 for (i = 0; i < n; i++) {
411 printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
412 pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
414 XFree ((char *) pmf);
419 * when we get interfaces to the PixmapFormat stuff, insert code here
422 XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
423 printf ("keycode range: minimum %d, maximum %d\n",
424 minkeycode, maxkeycode);
426 XGetInputFocus (dpy, &focuswin, &focusrevert);
430 printf ("PointerRoot\n");
436 printf("window 0x%lx, revert to ", focuswin);
437 switch (focusrevert) {
444 case RevertToPointerRoot:
445 printf ("PointerRoot\n");
447 default: /* should not happen */
448 printf ("%d\n", focusrevert);
454 print_extension_info (dpy);
456 printf ("default screen number: %d\n", DefaultScreen (dpy));
457 printf ("number of screens: %d\n", ScreenCount (dpy));
461 print_visual_info (vip)
464 char errorbuf[40]; /* for sprintfing into */
465 char *class = NULL; /* for printing */
467 switch (vip->class) {
468 case StaticGray: class = "StaticGray"; break;
469 case GrayScale: class = "GrayScale"; break;
470 case StaticColor: class = "StaticColor"; break;
471 case PseudoColor: class = "PseudoColor"; break;
472 case TrueColor: class = "TrueColor"; break;
473 case DirectColor: class = "DirectColor"; break;
475 sprintf (errorbuf, "unknown class %d", vip->class);
480 printf (" visual:\n");
481 printf (" visual id: 0x%lx\n", vip->visualid);
482 printf (" class: %s\n", class);
483 printf (" depth: %d plane%s\n", vip->depth,
484 vip->depth == 1 ? "" : "s");
485 if (vip->class == TrueColor || vip->class == DirectColor)
486 printf (" available colormap entries: %d per subfield\n",
489 printf (" available colormap entries: %d\n",
491 printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
492 vip->red_mask, vip->green_mask, vip->blue_mask);
493 printf (" significant bits in color specification: %d bits\n",
498 print_screen_info (dpy, scr)
502 Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
503 XVisualInfo viproto; /* fill in for getting info */
504 XVisualInfo *vip; /* retured info */
505 int nvi; /* number of elements returned */
506 int i; /* temp variable: iterator */
507 char eventbuf[80]; /* want 79 chars per line + nul */
508 static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
510 int ndepths = 0, *depths = NULL;
511 unsigned int width, height;
515 * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
517 * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
518 * = N pixels / (M inch / 25.4)
519 * = N * 25.4 pixels / M inch
522 xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
523 ((double) DisplayWidthMM(dpy,scr)));
524 yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
525 ((double) DisplayHeightMM(dpy,scr)));
528 printf ("screen #%d:\n", scr);
529 printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
530 DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
531 DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));
532 printf (" resolution: %dx%d dots per inch\n",
533 (int) (xres + 0.5), (int) (yres + 0.5));
534 depths = XListDepths (dpy, scr, &ndepths);
535 if (!depths) ndepths = 0;
536 printf (" depths (%d): ", ndepths);
537 for (i = 0; i < ndepths; i++) {
538 printf ("%d", depths[i]);
539 if (i < ndepths - 1) {
545 if (depths) XFree ((char *) depths);
546 printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
547 printf (" depth of root window: %d plane%s\n",
548 DisplayPlanes (dpy, scr),
549 DisplayPlanes (dpy, scr) == 1 ? "" : "s");
550 printf (" number of colormaps: minimum %d, maximum %d\n",
551 MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
552 printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
553 printf (" default number of colormap cells: %d\n",
554 DisplayCells (dpy, scr));
555 printf (" preallocated pixels: black %d, white %d\n",
556 BlackPixel (dpy, scr), WhitePixel (dpy, scr));
557 printf (" options: backing-store %s, save-unders %s\n",
558 (DoesBackingStore (s) == NotUseful) ? no :
559 ((DoesBackingStore (s) == Always) ? yes : when),
560 DoesSaveUnders (s) ? yes : no);
561 XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
563 if (width == 65535 && height == 65535)
564 printf (" largest cursor: unlimited\n");
566 printf (" largest cursor: %dx%d\n", width, height);
567 printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
568 (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
572 viproto.screen = scr;
573 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
574 printf (" number of visuals: %d\n", nvi);
575 printf (" default visual id: 0x%lx\n",
576 XVisualIDFromVisual (DefaultVisual (dpy, scr)));
577 for (i = 0; i < nvi; i++) {
578 print_visual_info (vip+i);
580 print_overlay_visual_info (vip+i);
581 #endif /* HAVE_OVERLAY */
583 print_glx_visual_info (dpy, vip+i);
584 #endif /* HAVE_GLX */
586 if (vip) XFree ((char *) vip);
590 * The following routine prints out an event mask, wrapping events at nice
594 #define MASK_NAME_WIDTH 25
596 static struct _event_table {
600 { "KeyPressMask ", KeyPressMask },
601 { "KeyReleaseMask ", KeyReleaseMask },
602 { "ButtonPressMask ", ButtonPressMask },
603 { "ButtonReleaseMask ", ButtonReleaseMask },
604 { "EnterWindowMask ", EnterWindowMask },
605 { "LeaveWindowMask ", LeaveWindowMask },
606 { "PointerMotionMask ", PointerMotionMask },
607 { "PointerMotionHintMask ", PointerMotionHintMask },
608 { "Button1MotionMask ", Button1MotionMask },
609 { "Button2MotionMask ", Button2MotionMask },
610 { "Button3MotionMask ", Button3MotionMask },
611 { "Button4MotionMask ", Button4MotionMask },
612 { "Button5MotionMask ", Button5MotionMask },
613 { "ButtonMotionMask ", ButtonMotionMask },
614 { "KeymapStateMask ", KeymapStateMask },
615 { "ExposureMask ", ExposureMask },
616 { "VisibilityChangeMask ", VisibilityChangeMask },
617 { "StructureNotifyMask ", StructureNotifyMask },
618 { "ResizeRedirectMask ", ResizeRedirectMask },
619 { "SubstructureNotifyMask ", SubstructureNotifyMask },
620 { "SubstructureRedirectMask ", SubstructureRedirectMask },
621 { "FocusChangeMask ", FocusChangeMask },
622 { "PropertyChangeMask ", PropertyChangeMask },
623 { "ColormapChangeMask ", ColormapChangeMask },
624 { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
627 int print_event_mask (buf, lastcol, indent, mask)
628 char *buf; /* string to write into */
629 int lastcol; /* strlen(buf)+1 */
630 int indent; /* amount by which to indent */
631 long mask; /* event mask */
633 struct _event_table *etp;
637 buf[0] = buf[lastcol] = '\0'; /* just in case */
639 #define INDENT() { register int i; len = indent; \
640 for (i = 0; i < indent; i++) buf[i] = ' '; }
644 for (etp = event_table; etp->name; etp++) {
645 if (mask & etp->value) {
646 if (len + MASK_NAME_WIDTH > lastcol) {
650 strcpy (buf+len, etp->name);
651 len += MASK_NAME_WIDTH;
656 if (bitsfound) puts (buf);
664 print_standard_extension_info(dpy, extname, majorrev, minorrev)
667 int majorrev, minorrev;
669 int opcode, event, error;
671 printf("%s version %d.%d ", extname, majorrev, minorrev);
673 XQueryExtension(dpy, extname, &opcode, &event, &error);
674 printf ("opcode: %d", opcode);
676 printf (", base event: %d", event);
678 printf (", base error: %d", error);
683 print_multibuf_info(dpy, extname)
687 int i, j; /* temp variable: iterator */
688 int nmono, nstereo; /* count */
689 XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
691 " visual id, max buffers, depth: 0x%lx, %d, %d\n";
693 int majorrev, minorrev;
695 if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
698 print_standard_extension_info(dpy, extname, majorrev, minorrev);
700 for (i = 0; i < ScreenCount (dpy); i++)
702 if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
703 &nstereo, &stereo_info)) {
705 "%s: unable to get multibuffer info for screen %d\n",
708 printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
709 for (j = 0; j < nmono; j++) {
710 printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
713 printf (" number of stereo multibuffer types: %d\n", nstereo);
714 for (j = 0; j < nstereo; j++) {
715 printf (fmt, stereo_info[j].visualid,
716 stereo_info[j].max_buffers, stereo_info[j].depth);
718 if (mono_info) XFree ((char *) mono_info);
719 if (stereo_info) XFree ((char *) stereo_info);
723 } /* end print_multibuf_info */
730 char *subset_names[] = { NULL, "FULL", "DIS" };
731 char *align_names[] = { NULL, "Alignable", "Arbitrary" };
732 char *group_names[] = { /* 0 */ "Default",
733 /* 2 */ "ColorAlloc",
735 /* 6 */ "ConvertFromRGB",
736 /* 8 */ "ConvertToRGB",
743 /* 22 */ "Histogram",
744 /* 24 */ "WhiteAdjust"
748 print_xie_info(dpy, extname)
752 XieExtensionInfo *xieInfo;
756 XieTechniqueGroup prevGroup;
758 if (!XieInitialize(dpy, &xieInfo ))
761 print_standard_extension_info(dpy, extname,
762 xieInfo->server_major_rev, xieInfo->server_minor_rev);
764 printf(" service class: %s\n", subset_names[xieInfo->service_class]);
765 printf(" alignment: %s\n", align_names[xieInfo->alignment]);
766 printf(" uncnst_mantissa: %d\n", xieInfo->uncnst_mantissa);
767 printf(" uncnst_min_exp: %d\n", xieInfo->uncnst_min_exp);
768 printf(" uncnst_max_exp: %d\n", xieInfo->uncnst_max_exp);
769 printf(" cnst_levels:");
770 for (i = 0; i < xieInfo->n_cnst_levels; i++)
771 printf(" %d", xieInfo->cnst_levels[i]);
774 if (!XieQueryTechniques(dpy, xieValAll, &ntechs, &techs))
779 for (i = 0; i < ntechs; i++)
781 if (techs[i].group != prevGroup)
783 printf(" technique group: %s\n", group_names[techs[i].group >> 1]);
784 prevGroup = techs[i].group;
786 printf(" %s\tspeed: %d needs_param: %s number: %d\n",
788 techs[i].speed, (techs[i].needs_param ? "True " : "False"),
792 } /* end print_xie_info */
794 #endif /* HAVE_XIE */
799 print_xtest_info(dpy, extname)
803 int majorrev, minorrev, foo;
805 if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
807 print_standard_extension_info(dpy, extname, majorrev, minorrev);
810 #endif /* HAVE_XTEST */
814 print_sync_info(dpy, extname)
818 int majorrev, minorrev;
819 XSyncSystemCounter *syscounters;
822 if (!XSyncInitialize(dpy, &majorrev, &minorrev))
824 print_standard_extension_info(dpy, extname, majorrev, minorrev);
826 syscounters = XSyncListSystemCounters(dpy, &ncounters);
827 printf(" system counters: %d\n", ncounters);
828 for (i = 0; i < ncounters; i++)
830 printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
831 syscounters[i].name, syscounters[i].counter,
832 XSyncValueLow32(syscounters[i].resolution),
833 XSyncValueHigh32(syscounters[i].resolution));
835 XSyncFreeSystemCounterList(syscounters);
838 #endif /* HAVE_XSYNC */
841 print_shape_info(dpy, extname)
845 int majorrev, minorrev;
847 if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
849 print_standard_extension_info(dpy, extname, majorrev, minorrev);
855 print_mitshm_info(dpy, extname)
859 int majorrev, minorrev;
862 if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
864 print_standard_extension_info(dpy, extname, majorrev, minorrev);
865 printf(" shared pixmaps: ");
868 int format = XShmPixmapFormat(dpy);
869 printf("yes, format: %d\n", format);
881 print_dbe_info(dpy, extname)
885 int majorrev, minorrev;
886 XdbeScreenVisualInfo *svi;
890 if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
893 print_standard_extension_info(dpy, extname, majorrev, minorrev);
894 svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
895 for (iscrn = 0; iscrn < numscreens; iscrn++)
897 printf(" Double-buffered visuals on screen %d\n", iscrn);
898 for (ivis = 0; ivis < svi[iscrn].count; ivis++)
900 printf(" visual id 0x%lx depth %d perflevel %d\n",
901 svi[iscrn].visinfo[ivis].visual,
902 svi[iscrn].visinfo[ivis].depth,
903 svi[iscrn].visinfo[ivis].perflevel);
906 XdbeFreeVisualInfo(svi);
909 #endif /* HAVE_XDBE */
913 print_record_info(dpy, extname)
917 int majorrev, minorrev;
919 if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
921 print_standard_extension_info(dpy, extname, majorrev, minorrev);
924 #endif /* HAVE_XRECORD */
926 /* utilities to manage the list of recognized extensions */
929 typedef int (*ExtensionPrintFunc)(
930 #if NeedFunctionPrototypes
937 ExtensionPrintFunc printfunc;
939 } ExtensionPrintInfo;
941 ExtensionPrintInfo known_extensions[] =
944 {"MIT-SHM", print_mitshm_info, False},
946 {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
947 {"SHAPE", print_shape_info, False},
949 {SYNC_NAME, print_sync_info, False},
950 #endif /* HAVE_XSYNC */
952 {xieExtName, print_xie_info, False},
953 #endif /* HAVE_XIE */
955 {XTestExtensionName, print_xtest_info, False},
956 #endif /* HAVE_XTEST */
958 {"DOUBLE-BUFFER", print_dbe_info, False},
959 #endif /* HAVE_XDBE */
961 {"RECORD", print_record_info, False}
962 #endif /* HAVE_XRECORD */
963 /* add new extensions here */
964 /* wish list: PEX XKB LBX */
967 int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
970 print_known_extensions(f)
974 for (i = 0; i < num_known_extensions; i++)
976 fprintf(f, "%s ", known_extensions[i].extname);
981 mark_extension_for_printing(extname)
986 if (strcmp(extname, "all") == 0)
988 for (i = 0; i < num_known_extensions; i++)
989 known_extensions[i].printit = True;
993 for (i = 0; i < num_known_extensions; i++)
995 if (strcmp(extname, known_extensions[i].extname) == 0)
997 known_extensions[i].printit = True;
1001 printf("%s extension not supported by %s\n", extname, ProgramName);
1006 print_marked_extensions(dpy)
1010 for (i = 0; i < num_known_extensions; i++)
1012 if (known_extensions[i].printit)
1015 if (! (*known_extensions[i].printfunc)(dpy,
1016 known_extensions[i].extname))
1018 printf("%s extension not supported by server\n",
1019 known_extensions[i].extname);
1025 static void usage ()
1027 fprintf (stderr, "usage: %s [options]\n", ProgramName);
1028 fprintf (stderr, "-display displayname\tserver to query\n");
1029 fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
1030 fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
1031 fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
1032 print_known_extensions(stderr);
1033 fprintf (stderr, "\n");
1037 int main (argc, argv)
1041 Display *dpy; /* X connection */
1042 char *displayname = NULL; /* server to contact */
1043 int i; /* temp variable: iterator */
1044 Bool multibuf = False;
1045 int mbuf_event_base, mbuf_error_base;
1047 ProgramName = argv[0];
1049 for (i = 1; i < argc; i++) {
1050 char *arg = argv[i];
1051 int len = strlen(arg);
1053 if (!strncmp("-display", arg, len)) {
1054 if (++i >= argc) usage ();
1055 displayname = argv[i];
1056 } else if (!strncmp("-queryExtensions", arg, len)) {
1057 queryExtensions = True;
1058 } else if (!strncmp("-ext", arg, len)) {
1059 if (++i >= argc) usage ();
1060 mark_extension_for_printing(argv[i]);
1065 dpy = XOpenDisplay (displayname);
1067 fprintf (stderr, "%s: unable to open display \"%s\".\n",
1068 ProgramName, XDisplayName (displayname));
1073 find_overlay_info (dpy);
1074 #endif /* HAVE_OVERLAY */
1076 print_display_info (dpy);
1077 for (i = 0; i < ScreenCount (dpy); i++) {
1078 print_screen_info (dpy, i);
1081 print_marked_extensions(dpy);
1083 XCloseDisplay (dpy);