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
26 * GLX and Overlay support added by Jamie Zawinski <jwz@jwz.org>, 11-Nov-99
29 * cc -DHAVE_GLX glxdpyinfo.c -o glxdpyinfo -lGL -lX11 -lXext -lm
31 * Other defines to consider:
32 * -DHAVE_XIE -DHAVE_XTEST -DHAVE_SYNC -DHAVE_XRECORD
36 #include <X11/Xutil.h>
37 #include <X11/Xproto.h> /* for CARD32 */
38 #include <X11/extensions/multibuf.h>
40 #include <X11/extensions/XIElib.h>
43 #include <X11/extensions/XTest.h>
44 #endif /* HAVE_XTEST */
46 #include <X11/extensions/sync.h>
47 #endif /* HAVE_XSYNC */
48 #include <X11/extensions/Xdbe.h>
50 #include <X11/extensions/record.h>
51 #endif /* HAVE_XRECORD */
53 #include <X11/extensions/XShm.h>
63 #define HAVE_OVERLAY /* jwz: no compile-time deps, so do this all the time */
66 Bool queryExtensions = False;
68 static int StrCmp(a, b)
71 return strcmp(*a, *b);
75 #ifdef HAVE_GLX /* Added by jwz, 11-Nov-99 */
78 print_glx_versions (dpy)
81 /* Note: with Mesa 3.0, this lies: it prints the info from the
82 client's GL library, rather than the info from the GLX server.
84 Note also that we can't protect these calls by only doing
85 them when the GLX extension is present, because with Mesa,
86 the server doesn't have that extension (but the GL library
89 int scr = DefaultScreen (dpy);
90 const char *vend, *vers;
91 vend = glXQueryServerString (dpy, scr, GLX_VENDOR);
93 vers = glXQueryServerString (dpy, scr, GLX_VERSION);
94 printf ("GLX vendor: %s (%s)\n",
95 vend, (vers ? vers : "unknown version"));
99 print_glx_visual_info (dpy, vip)
103 int status, value = False;
105 status = glXGetConfig (dpy, vip, GLX_USE_GL, &value);
106 if (status == GLX_NO_EXTENSION)
107 /* dpy does not support the GLX extension. */
110 if (status == GLX_BAD_VISUAL || value == False)
112 printf (" GLX supported: no\n");
117 printf (" GLX supported: yes\n");
120 if (!glXGetConfig (dpy, vip, GLX_LEVEL, &value) &&
122 printf (" GLX level: %d\n", value);
124 if (!glXGetConfig (dpy, vip, GLX_RGBA, &value) && value)
126 int r=0, g=0, b=0, a=0;
127 glXGetConfig (dpy, vip, GLX_RED_SIZE, &r);
128 glXGetConfig (dpy, vip, GLX_GREEN_SIZE, &g);
129 glXGetConfig (dpy, vip, GLX_BLUE_SIZE, &b);
130 glXGetConfig (dpy, vip, GLX_ALPHA_SIZE, &a);
131 printf (" GLX type: RGBA (%2d, %2d, %2d, %2d)\n",
135 glXGetConfig (dpy, vip, GLX_ACCUM_RED_SIZE, &r);
136 glXGetConfig (dpy, vip, GLX_ACCUM_GREEN_SIZE, &g);
137 glXGetConfig (dpy, vip, GLX_ACCUM_BLUE_SIZE, &b);
138 glXGetConfig (dpy, vip, GLX_ACCUM_ALPHA_SIZE, &a);
139 printf (" GLX accum: RGBA (%2d, %2d, %2d, %2d)\n",
145 glXGetConfig (dpy, vip, GLX_BUFFER_SIZE, &value);
146 printf (" GLX type: indexed (%d)\n", value);
149 # if 0 /* redundant */
150 if (!glXGetConfig (dpy, vip, GLX_X_VISUAL_TYPE_EXT, &value))
151 printf (" GLX class: %s\n",
152 (value == GLX_TRUE_COLOR_EXT ? "TrueColor" :
153 value == GLX_DIRECT_COLOR_EXT ? "DirectColor" :
154 value == GLX_PSEUDO_COLOR_EXT ? "PseudoColor" :
155 value == GLX_STATIC_COLOR_EXT ? "StaticColor" :
156 value == GLX_GRAY_SCALE_EXT ? "Grayscale" :
157 value == GLX_STATIC_GRAY_EXT ? "StaticGray" : "???"));
160 # ifdef GLX_VISUAL_CAVEAT_EXT
161 if (!glXGetConfig (dpy, vip, GLX_VISUAL_CAVEAT_EXT, &value) &&
162 value != GLX_NONE_EXT)
163 printf (" GLX rating: %s\n",
164 (value == GLX_NONE_EXT ? "none" :
165 value == GLX_SLOW_VISUAL_EXT ? "slow" :
166 # ifdef GLX_NON_CONFORMANT_EXT
167 value == GLX_NON_CONFORMANT_EXT ? "non-conformant" :
172 if (!glXGetConfig (dpy, vip, GLX_DOUBLEBUFFER, &value))
173 printf (" GLX double-buffer: %s\n", (value ? "yes" : "no"));
175 if (!glXGetConfig (dpy, vip, GLX_STEREO, &value) &&
177 printf (" GLX stereo: %s\n", (value ? "yes" : "no"));
179 if (!glXGetConfig (dpy, vip, GLX_AUX_BUFFERS, &value) &&
181 printf (" GLX aux buffers: %d\n", value);
183 if (!glXGetConfig (dpy, vip, GLX_DEPTH_SIZE, &value))
184 printf (" GLX depth size: %d\n", value);
186 if (!glXGetConfig (dpy, vip, GLX_STENCIL_SIZE, &value) &&
188 printf (" GLX stencil size: %d\n", value);
190 # ifdef GLX_SAMPLE_BUFFERS_SGIS
191 if (!glXGetConfig (dpy, vip, GLX_SAMPLE_BUFFERS_SGIS, &value) &&
195 if (!glXGetConfig (dpy, vip, GLX_SAMPLES_SGIS, &value))
196 printf (" GLX multisamplers: %d (%d)\n", bufs, value);
200 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_TYPE_EXT, &value) &&
201 value != GLX_NONE_EXT)
203 if (value == GLX_NONE_EXT)
204 printf (" GLX transparency: none\n");
205 else if (value == GLX_TRANSPARENT_INDEX_EXT)
207 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_INDEX_VALUE_EXT,&value))
208 printf (" GLX transparency: indexed (%d)\n", value);
210 else if (value == GLX_TRANSPARENT_RGB_EXT)
212 int r=0, g=0, b=0, a=0;
213 glXGetConfig (dpy, vip, GLX_TRANSPARENT_RED_VALUE_EXT, &r);
214 glXGetConfig (dpy, vip, GLX_TRANSPARENT_GREEN_VALUE_EXT, &g);
215 glXGetConfig (dpy, vip, GLX_TRANSPARENT_BLUE_VALUE_EXT, &b);
216 glXGetConfig (dpy, vip, GLX_TRANSPARENT_ALPHA_VALUE_EXT, &a);
217 printf (" GLX transparency: RGBA (%2d, %2d, %2d, %2d)\n",
222 #endif /* HAVE_GLX */
225 #ifdef HAVE_OVERLAY /* Added by jwz, 11-Nov-99 */
227 /* If the server's root window contains a SERVER_OVERLAY_VISUALS property,
228 then that identifies the visuals which correspond to the video hardware's
229 overlay planes. Windows created in these kinds of visuals may have
230 transparent pixels that let other layers shine through.
232 This might not be an X Consortium standard, but it turns out that
233 SGI, HP, DEC, and IBM all use this same mechanism. So that's close
236 Documentation on the SERVER_OVERLAY_VISUALS property can be found at:
237 http://www.hp.com/xwindow/sharedInfo/Whitepapers/Visuals/server_overlay_visuals.html
243 CARD32 transparency; /* 0: none; 1: pixel; 2: mask */
244 CARD32 value; /* the transparent pixel */
245 CARD32 layer; /* -1: underlay; 0: normal; 1: popup; 2: overlay */
251 struct overlay *list;
254 static struct overlay_list *overlays = 0;
257 find_overlay_info (dpy)
261 Atom OVERLAY = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False);
263 overlays = (struct overlay_list *) calloc (sizeof (struct overlay_list),
266 for (screen = 0; screen < ScreenCount (dpy); screen++)
268 Window window = RootWindow (dpy, screen);
271 unsigned long nitems, bytes_after;
272 struct overlay *data = 0;
273 int result = XGetWindowProperty (dpy, window, OVERLAY,
274 0, (65536 / sizeof (long)), False,
275 OVERLAY, &actual_type, &actual_format,
276 &nitems, &bytes_after,
277 (unsigned char **) &data);
278 if (result == Success &&
279 actual_type == OVERLAY &&
280 actual_format == 32 &&
283 overlays[screen].count = (nitems /
284 (sizeof(struct overlay) / sizeof(CARD32)));
285 overlays[screen].list = data;
288 XFree((char *) data);
293 print_overlay_visual_info (vip)
297 int vis = vip->visualid;
298 int scr = vip->screen;
299 if (!overlays) return;
300 for (i = 0; i < overlays[scr].count; i++)
301 if (vis == overlays[scr].list[i].visual_id)
303 struct overlay *ov = &overlays[scr].list[i];
304 printf (" Overlay info: layer %ld (%s), ",
306 (ov->layer == -1 ? "underlay" :
307 ov->layer == 0 ? "normal" :
308 ov->layer == 1 ? "popup" :
309 ov->layer == 2 ? "overlay" : "???"));
310 if (ov->transparency == 1)
311 printf ("transparent pixel %lu\n", (unsigned long) ov->value);
312 else if (ov->transparency == 2)
313 printf ("transparent mask 0x%x\n", (unsigned long) ov->value);
318 #endif /* HAVE_OVERLAY */
322 print_extension_info (dpy)
326 char **extlist = XListExtensions (dpy, &n);
328 printf ("number of extensions: %d\n", n);
332 int opcode, event, error;
334 qsort(extlist, n, sizeof(char *), StrCmp);
335 for (i = 0; i < n; i++) {
336 if (!queryExtensions) {
337 printf (" %s\n", extlist[i]);
340 XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
341 printf (" %s (opcode: %d", extlist[i], opcode);
343 printf (", base event: %d", event);
345 printf (", base error: %d", error);
348 /* do not free, Xlib can depend on contents being unaltered */
349 /* XFreeExtensionList (extlist); */
354 print_display_info (dpy)
359 int minkeycode, maxkeycode;
362 XPixmapFormatValues *pmf;
366 printf ("name of display: %s\n", DisplayString (dpy));
367 printf ("version number: %d.%d\n",
368 ProtocolVersion (dpy), ProtocolRevision (dpy));
369 printf ("vendor string: %s\n", ServerVendor (dpy));
370 printf ("vendor release number: %d\n", VendorRelease (dpy));
373 print_glx_versions (dpy);
374 #endif /* HAVE_GLX */
376 req_size = XExtendedMaxRequestSize (dpy);
377 if (!req_size) req_size = XMaxRequestSize (dpy);
378 printf ("maximum request size: %ld bytes\n", req_size * 4);
379 printf ("motion buffer size: %d\n", XDisplayMotionBufferSize (dpy));
381 switch (BitmapBitOrder (dpy)) {
382 case LSBFirst: cp = "LSBFirst"; break;
383 case MSBFirst: cp = "MSBFirst"; break;
385 sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
389 printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
390 BitmapUnit (dpy), cp, BitmapPad (dpy));
392 switch (ImageByteOrder (dpy)) {
393 case LSBFirst: cp = "LSBFirst"; break;
394 case MSBFirst: cp = "MSBFirst"; break;
396 sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
400 printf ("image byte order: %s\n", cp);
402 pmf = XListPixmapFormats (dpy, &n);
403 printf ("number of supported pixmap formats: %d\n", n);
405 printf ("supported pixmap formats:\n");
406 for (i = 0; i < n; i++) {
407 printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
408 pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
410 XFree ((char *) pmf);
415 * when we get interfaces to the PixmapFormat stuff, insert code here
418 XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
419 printf ("keycode range: minimum %d, maximum %d\n",
420 minkeycode, maxkeycode);
422 XGetInputFocus (dpy, &focuswin, &focusrevert);
426 printf ("PointerRoot\n");
432 printf("window 0x%lx, revert to ", focuswin);
433 switch (focusrevert) {
440 case RevertToPointerRoot:
441 printf ("PointerRoot\n");
443 default: /* should not happen */
444 printf ("%d\n", focusrevert);
450 print_extension_info (dpy);
452 printf ("default screen number: %d\n", DefaultScreen (dpy));
453 printf ("number of screens: %d\n", ScreenCount (dpy));
457 print_visual_info (vip)
460 char errorbuf[40]; /* for sprintfing into */
461 char *class = NULL; /* for printing */
463 switch (vip->class) {
464 case StaticGray: class = "StaticGray"; break;
465 case GrayScale: class = "GrayScale"; break;
466 case StaticColor: class = "StaticColor"; break;
467 case PseudoColor: class = "PseudoColor"; break;
468 case TrueColor: class = "TrueColor"; break;
469 case DirectColor: class = "DirectColor"; break;
471 sprintf (errorbuf, "unknown class %d", vip->class);
476 printf (" visual:\n");
477 printf (" visual id: 0x%lx\n", vip->visualid);
478 printf (" class: %s\n", class);
479 printf (" depth: %d plane%s\n", vip->depth,
480 vip->depth == 1 ? "" : "s");
481 if (vip->class == TrueColor || vip->class == DirectColor)
482 printf (" available colormap entries: %d per subfield\n",
485 printf (" available colormap entries: %d\n",
487 printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
488 vip->red_mask, vip->green_mask, vip->blue_mask);
489 printf (" significant bits in color specification: %d bits\n",
494 print_screen_info (dpy, scr)
498 Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
499 XVisualInfo viproto; /* fill in for getting info */
500 XVisualInfo *vip; /* retured info */
501 int nvi; /* number of elements returned */
502 int i; /* temp variable: iterator */
503 char eventbuf[80]; /* want 79 chars per line + nul */
504 static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
506 int ndepths = 0, *depths = NULL;
507 unsigned int width, height;
511 * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
513 * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
514 * = N pixels / (M inch / 25.4)
515 * = N * 25.4 pixels / M inch
518 xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
519 ((double) DisplayWidthMM(dpy,scr)));
520 yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
521 ((double) DisplayHeightMM(dpy,scr)));
524 printf ("screen #%d:\n", scr);
525 printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
526 DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
527 DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));
528 printf (" resolution: %dx%d dots per inch\n",
529 (int) (xres + 0.5), (int) (yres + 0.5));
530 depths = XListDepths (dpy, scr, &ndepths);
531 if (!depths) ndepths = 0;
532 printf (" depths (%d): ", ndepths);
533 for (i = 0; i < ndepths; i++) {
534 printf ("%d", depths[i]);
535 if (i < ndepths - 1) {
541 if (depths) XFree ((char *) depths);
542 printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
543 printf (" depth of root window: %d plane%s\n",
544 DisplayPlanes (dpy, scr),
545 DisplayPlanes (dpy, scr) == 1 ? "" : "s");
546 printf (" number of colormaps: minimum %d, maximum %d\n",
547 MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
548 printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
549 printf (" default number of colormap cells: %d\n",
550 DisplayCells (dpy, scr));
551 printf (" preallocated pixels: black %d, white %d\n",
552 BlackPixel (dpy, scr), WhitePixel (dpy, scr));
553 printf (" options: backing-store %s, save-unders %s\n",
554 (DoesBackingStore (s) == NotUseful) ? no :
555 ((DoesBackingStore (s) == Always) ? yes : when),
556 DoesSaveUnders (s) ? yes : no);
557 XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
559 if (width == 65535 && height == 65535)
560 printf (" largest cursor: unlimited\n");
562 printf (" largest cursor: %dx%d\n", width, height);
563 printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
564 (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
568 viproto.screen = scr;
569 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
570 printf (" number of visuals: %d\n", nvi);
571 printf (" default visual id: 0x%lx\n",
572 XVisualIDFromVisual (DefaultVisual (dpy, scr)));
573 for (i = 0; i < nvi; i++) {
574 print_visual_info (vip+i);
576 print_overlay_visual_info (vip+i);
577 #endif /* HAVE_OVERLAY */
579 print_glx_visual_info (dpy, vip+i);
580 #endif /* HAVE_GLX */
582 if (vip) XFree ((char *) vip);
586 * The following routine prints out an event mask, wrapping events at nice
590 #define MASK_NAME_WIDTH 25
592 static struct _event_table {
596 { "KeyPressMask ", KeyPressMask },
597 { "KeyReleaseMask ", KeyReleaseMask },
598 { "ButtonPressMask ", ButtonPressMask },
599 { "ButtonReleaseMask ", ButtonReleaseMask },
600 { "EnterWindowMask ", EnterWindowMask },
601 { "LeaveWindowMask ", LeaveWindowMask },
602 { "PointerMotionMask ", PointerMotionMask },
603 { "PointerMotionHintMask ", PointerMotionHintMask },
604 { "Button1MotionMask ", Button1MotionMask },
605 { "Button2MotionMask ", Button2MotionMask },
606 { "Button3MotionMask ", Button3MotionMask },
607 { "Button4MotionMask ", Button4MotionMask },
608 { "Button5MotionMask ", Button5MotionMask },
609 { "ButtonMotionMask ", ButtonMotionMask },
610 { "KeymapStateMask ", KeymapStateMask },
611 { "ExposureMask ", ExposureMask },
612 { "VisibilityChangeMask ", VisibilityChangeMask },
613 { "StructureNotifyMask ", StructureNotifyMask },
614 { "ResizeRedirectMask ", ResizeRedirectMask },
615 { "SubstructureNotifyMask ", SubstructureNotifyMask },
616 { "SubstructureRedirectMask ", SubstructureRedirectMask },
617 { "FocusChangeMask ", FocusChangeMask },
618 { "PropertyChangeMask ", PropertyChangeMask },
619 { "ColormapChangeMask ", ColormapChangeMask },
620 { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
623 int print_event_mask (buf, lastcol, indent, mask)
624 char *buf; /* string to write into */
625 int lastcol; /* strlen(buf)+1 */
626 int indent; /* amount by which to indent */
627 long mask; /* event mask */
629 struct _event_table *etp;
633 buf[0] = buf[lastcol] = '\0'; /* just in case */
635 #define INDENT() { register int i; len = indent; \
636 for (i = 0; i < indent; i++) buf[i] = ' '; }
640 for (etp = event_table; etp->name; etp++) {
641 if (mask & etp->value) {
642 if (len + MASK_NAME_WIDTH > lastcol) {
646 strcpy (buf+len, etp->name);
647 len += MASK_NAME_WIDTH;
652 if (bitsfound) puts (buf);
660 print_standard_extension_info(dpy, extname, majorrev, minorrev)
663 int majorrev, minorrev;
665 int opcode, event, error;
667 printf("%s version %d.%d ", extname, majorrev, minorrev);
669 XQueryExtension(dpy, extname, &opcode, &event, &error);
670 printf ("opcode: %d", opcode);
672 printf (", base event: %d", event);
674 printf (", base error: %d", error);
679 print_multibuf_info(dpy, extname)
683 int i, j; /* temp variable: iterator */
684 int nmono, nstereo; /* count */
685 XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
687 " visual id, max buffers, depth: 0x%lx, %d, %d\n";
689 int majorrev, minorrev;
691 if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
694 print_standard_extension_info(dpy, extname, majorrev, minorrev);
696 for (i = 0; i < ScreenCount (dpy); i++)
698 if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
699 &nstereo, &stereo_info)) {
701 "%s: unable to get multibuffer info for screen %d\n",
704 printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
705 for (j = 0; j < nmono; j++) {
706 printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
709 printf (" number of stereo multibuffer types: %d\n", nstereo);
710 for (j = 0; j < nstereo; j++) {
711 printf (fmt, stereo_info[j].visualid,
712 stereo_info[j].max_buffers, stereo_info[j].depth);
714 if (mono_info) XFree ((char *) mono_info);
715 if (stereo_info) XFree ((char *) stereo_info);
719 } /* end print_multibuf_info */
726 char *subset_names[] = { NULL, "FULL", "DIS" };
727 char *align_names[] = { NULL, "Alignable", "Arbitrary" };
728 char *group_names[] = { /* 0 */ "Default",
729 /* 2 */ "ColorAlloc",
731 /* 6 */ "ConvertFromRGB",
732 /* 8 */ "ConvertToRGB",
739 /* 22 */ "Histogram",
740 /* 24 */ "WhiteAdjust"
744 print_xie_info(dpy, extname)
748 XieExtensionInfo *xieInfo;
752 XieTechniqueGroup prevGroup;
754 if (!XieInitialize(dpy, &xieInfo ))
757 print_standard_extension_info(dpy, extname,
758 xieInfo->server_major_rev, xieInfo->server_minor_rev);
760 printf(" service class: %s\n", subset_names[xieInfo->service_class]);
761 printf(" alignment: %s\n", align_names[xieInfo->alignment]);
762 printf(" uncnst_mantissa: %d\n", xieInfo->uncnst_mantissa);
763 printf(" uncnst_min_exp: %d\n", xieInfo->uncnst_min_exp);
764 printf(" uncnst_max_exp: %d\n", xieInfo->uncnst_max_exp);
765 printf(" cnst_levels:");
766 for (i = 0; i < xieInfo->n_cnst_levels; i++)
767 printf(" %d", xieInfo->cnst_levels[i]);
770 if (!XieQueryTechniques(dpy, xieValAll, &ntechs, &techs))
775 for (i = 0; i < ntechs; i++)
777 if (techs[i].group != prevGroup)
779 printf(" technique group: %s\n", group_names[techs[i].group >> 1]);
780 prevGroup = techs[i].group;
782 printf(" %s\tspeed: %d needs_param: %s number: %d\n",
784 techs[i].speed, (techs[i].needs_param ? "True " : "False"),
788 } /* end print_xie_info */
790 #endif /* HAVE_XIE */
795 print_xtest_info(dpy, extname)
799 int majorrev, minorrev, foo;
801 if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
803 print_standard_extension_info(dpy, extname, majorrev, minorrev);
806 #endif /* HAVE_XTEST */
810 print_sync_info(dpy, extname)
814 int majorrev, minorrev;
815 XSyncSystemCounter *syscounters;
818 if (!XSyncInitialize(dpy, &majorrev, &minorrev))
820 print_standard_extension_info(dpy, extname, majorrev, minorrev);
822 syscounters = XSyncListSystemCounters(dpy, &ncounters);
823 printf(" system counters: %d\n", ncounters);
824 for (i = 0; i < ncounters; i++)
826 printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
827 syscounters[i].name, syscounters[i].counter,
828 XSyncValueLow32(syscounters[i].resolution),
829 XSyncValueHigh32(syscounters[i].resolution));
831 XSyncFreeSystemCounterList(syscounters);
834 #endif /* HAVE_XSYNC */
837 print_shape_info(dpy, extname)
841 int majorrev, minorrev;
843 if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
845 print_standard_extension_info(dpy, extname, majorrev, minorrev);
851 print_mitshm_info(dpy, extname)
855 int majorrev, minorrev;
858 if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
860 print_standard_extension_info(dpy, extname, majorrev, minorrev);
861 printf(" shared pixmaps: ");
864 int format = XShmPixmapFormat(dpy);
865 printf("yes, format: %d\n", format);
876 print_dbe_info(dpy, extname)
880 int majorrev, minorrev;
881 XdbeScreenVisualInfo *svi;
885 if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
888 print_standard_extension_info(dpy, extname, majorrev, minorrev);
889 svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
890 for (iscrn = 0; iscrn < numscreens; iscrn++)
892 printf(" Double-buffered visuals on screen %d\n", iscrn);
893 for (ivis = 0; ivis < svi[iscrn].count; ivis++)
895 printf(" visual id 0x%lx depth %d perflevel %d\n",
896 svi[iscrn].visinfo[ivis].visual,
897 svi[iscrn].visinfo[ivis].depth,
898 svi[iscrn].visinfo[ivis].perflevel);
901 XdbeFreeVisualInfo(svi);
907 print_record_info(dpy, extname)
911 int majorrev, minorrev;
913 if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
915 print_standard_extension_info(dpy, extname, majorrev, minorrev);
918 #endif /* HAVE_XRECORD */
920 /* utilities to manage the list of recognized extensions */
923 typedef int (*ExtensionPrintFunc)(
924 #if NeedFunctionPrototypes
931 ExtensionPrintFunc printfunc;
933 } ExtensionPrintInfo;
935 ExtensionPrintInfo known_extensions[] =
938 {"MIT-SHM", print_mitshm_info, False},
940 {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
941 {"SHAPE", print_shape_info, False},
943 {SYNC_NAME, print_sync_info, False},
944 #endif /* HAVE_XSYNC */
946 {xieExtName, print_xie_info, False},
947 #endif /* HAVE_XIE */
949 {XTestExtensionName, print_xtest_info, False},
950 #endif /* HAVE_XTEST */
951 {"DOUBLE-BUFFER", print_dbe_info, False},
953 {"RECORD", print_record_info, False}
954 #endif /* HAVE_XRECORD */
955 /* add new extensions here */
956 /* wish list: PEX XKB LBX */
959 int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
962 print_known_extensions(f)
966 for (i = 0; i < num_known_extensions; i++)
968 fprintf(f, "%s ", known_extensions[i].extname);
973 mark_extension_for_printing(extname)
978 if (strcmp(extname, "all") == 0)
980 for (i = 0; i < num_known_extensions; i++)
981 known_extensions[i].printit = True;
985 for (i = 0; i < num_known_extensions; i++)
987 if (strcmp(extname, known_extensions[i].extname) == 0)
989 known_extensions[i].printit = True;
993 printf("%s extension not supported by %s\n", extname, ProgramName);
998 print_marked_extensions(dpy)
1002 for (i = 0; i < num_known_extensions; i++)
1004 if (known_extensions[i].printit)
1007 if (! (*known_extensions[i].printfunc)(dpy,
1008 known_extensions[i].extname))
1010 printf("%s extension not supported by server\n",
1011 known_extensions[i].extname);
1017 static void usage ()
1019 fprintf (stderr, "usage: %s [options]\n", ProgramName);
1020 fprintf (stderr, "-display displayname\tserver to query\n");
1021 fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
1022 fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
1023 fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
1024 print_known_extensions(stderr);
1025 fprintf (stderr, "\n");
1029 int main (argc, argv)
1033 Display *dpy; /* X connection */
1034 char *displayname = NULL; /* server to contact */
1035 int i; /* temp variable: iterator */
1036 Bool multibuf = False;
1037 int mbuf_event_base, mbuf_error_base;
1039 ProgramName = argv[0];
1041 for (i = 1; i < argc; i++) {
1042 char *arg = argv[i];
1043 int len = strlen(arg);
1045 if (!strncmp("-display", arg, len)) {
1046 if (++i >= argc) usage ();
1047 displayname = argv[i];
1048 } else if (!strncmp("-queryExtensions", arg, len)) {
1049 queryExtensions = True;
1050 } else if (!strncmp("-ext", arg, len)) {
1051 if (++i >= argc) usage ();
1052 mark_extension_for_printing(argv[i]);
1057 dpy = XOpenDisplay (displayname);
1059 fprintf (stderr, "%s: unable to open display \"%s\".\n",
1060 ProgramName, XDisplayName (displayname));
1065 find_overlay_info (dpy);
1066 #endif /* HAVE_OVERLAY */
1068 print_display_info (dpy);
1069 for (i = 0; i < ScreenCount (dpy); i++) {
1070 print_screen_info (dpy, i);
1073 print_marked_extensions(dpy);
1075 XCloseDisplay (dpy);