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 # if defined(GL_SAMPLE_BUFFERS)
195 # define SB GL_SAMPLE_BUFFERS
196 # define SM GL_SAMPLES
197 # elif defined(GLX_SAMPLE_BUFFERS)
198 # define SB GLX_SAMPLE_BUFFERS
199 # define SM GLX_SAMPLES
200 # elif defined(GLX_SAMPLE_BUFFERS_ARB)
201 # define SB GLX_SAMPLE_BUFFERS_ARB
202 # define SM GLX_SAMPLES_ARB
203 # elif defined(GLX_SAMPLE_BUFFERS_SGIS)
204 # define SB GLX_SAMPLE_BUFFERS_SGIS
205 # define SM GLX_SAMPLES_SGIS
209 if (!glXGetConfig (dpy, vip, SB, &value) && value != 0)
212 if (!glXGetConfig (dpy, vip, SM, &value))
213 printf (" GLX multisample: %d, %d\n", bufs, value);
217 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_TYPE_EXT, &value) &&
218 value != GLX_NONE_EXT)
220 if (value == GLX_NONE_EXT)
221 printf (" GLX transparency: none\n");
222 else if (value == GLX_TRANSPARENT_INDEX_EXT)
224 if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_INDEX_VALUE_EXT,&value))
225 printf (" GLX transparency: indexed (%d)\n", value);
227 else if (value == GLX_TRANSPARENT_RGB_EXT)
229 int r=0, g=0, b=0, a=0;
230 glXGetConfig (dpy, vip, GLX_TRANSPARENT_RED_VALUE_EXT, &r);
231 glXGetConfig (dpy, vip, GLX_TRANSPARENT_GREEN_VALUE_EXT, &g);
232 glXGetConfig (dpy, vip, GLX_TRANSPARENT_BLUE_VALUE_EXT, &b);
233 glXGetConfig (dpy, vip, GLX_TRANSPARENT_ALPHA_VALUE_EXT, &a);
234 printf (" GLX transparency: RGBA (%2d, %2d, %2d, %2d)\n",
239 #endif /* HAVE_GLX */
242 #ifdef HAVE_OVERLAY /* Added by jwz, 11-Nov-99 */
244 /* If the server's root window contains a SERVER_OVERLAY_VISUALS property,
245 then that identifies the visuals which correspond to the video hardware's
246 overlay planes. Windows created in these kinds of visuals may have
247 transparent pixels that let other layers shine through.
249 This might not be an X Consortium standard, but it turns out that
250 SGI, HP, DEC, and IBM all use this same mechanism. So that's close
253 Documentation on the SERVER_OVERLAY_VISUALS property can be found at:
254 http://www.hp.com/xwindow/sharedInfo/Whitepapers/Visuals/server_overlay_visuals.html
260 CARD32 transparency; /* 0: none; 1: pixel; 2: mask */
261 CARD32 value; /* the transparent pixel */
262 CARD32 layer; /* -1: underlay; 0: normal; 1: popup; 2: overlay */
268 struct overlay *list;
271 static struct overlay_list *overlays = 0;
274 find_overlay_info (dpy)
278 Atom OVERLAY = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False);
280 overlays = (struct overlay_list *) calloc (sizeof (struct overlay_list),
283 for (screen = 0; screen < ScreenCount (dpy); screen++)
285 Window window = RootWindow (dpy, screen);
288 unsigned long nitems, bytes_after;
289 struct overlay *data = 0;
290 int result = XGetWindowProperty (dpy, window, OVERLAY,
291 0, (65536 / sizeof (long)), False,
292 OVERLAY, &actual_type, &actual_format,
293 &nitems, &bytes_after,
294 (unsigned char **) &data);
295 if (result == Success &&
296 actual_type == OVERLAY &&
297 actual_format == 32 &&
300 overlays[screen].count = (nitems /
301 (sizeof(struct overlay) / sizeof(CARD32)));
302 overlays[screen].list = data;
305 XFree((char *) data);
310 print_overlay_visual_info (vip)
314 int vis = vip->visualid;
315 int scr = vip->screen;
316 if (!overlays) return;
317 for (i = 0; i < overlays[scr].count; i++)
318 if (vis == overlays[scr].list[i].visual_id)
320 struct overlay *ov = &overlays[scr].list[i];
321 printf (" Overlay info: layer %ld (%s), ",
323 (ov->layer == -1 ? "underlay" :
324 ov->layer == 0 ? "normal" :
325 ov->layer == 1 ? "popup" :
326 ov->layer == 2 ? "overlay" : "???"));
327 if (ov->transparency == 1)
328 printf ("transparent pixel %lu\n", (unsigned long) ov->value);
329 else if (ov->transparency == 2)
330 printf ("transparent mask 0x%x\n", (unsigned long) ov->value);
335 #endif /* HAVE_OVERLAY */
339 print_extension_info (dpy)
343 char **extlist = XListExtensions (dpy, &n);
345 printf ("number of extensions: %d\n", n);
349 int opcode, event, error;
351 qsort(extlist, n, sizeof(char *), StrCmp);
352 for (i = 0; i < n; i++) {
353 if (!queryExtensions) {
354 printf (" %s\n", extlist[i]);
357 XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
358 printf (" %s (opcode: %d", extlist[i], opcode);
360 printf (", base event: %d", event);
362 printf (", base error: %d", error);
365 /* do not free, Xlib can depend on contents being unaltered */
366 /* XFreeExtensionList (extlist); */
371 print_display_info (dpy)
376 int minkeycode, maxkeycode;
379 XPixmapFormatValues *pmf;
383 printf ("name of display: %s\n", DisplayString (dpy));
384 printf ("version number: %d.%d\n",
385 ProtocolVersion (dpy), ProtocolRevision (dpy));
386 printf ("vendor string: %s\n", ServerVendor (dpy));
387 printf ("vendor release number: %d\n", VendorRelease (dpy));
390 print_glx_versions (dpy);
391 #endif /* HAVE_GLX */
393 req_size = XExtendedMaxRequestSize (dpy);
394 if (!req_size) req_size = XMaxRequestSize (dpy);
395 printf ("maximum request size: %ld bytes\n", req_size * 4);
396 printf ("motion buffer size: %d\n", XDisplayMotionBufferSize (dpy));
398 switch (BitmapBitOrder (dpy)) {
399 case LSBFirst: cp = "LSBFirst"; break;
400 case MSBFirst: cp = "MSBFirst"; break;
402 sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
406 printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
407 BitmapUnit (dpy), cp, BitmapPad (dpy));
409 switch (ImageByteOrder (dpy)) {
410 case LSBFirst: cp = "LSBFirst"; break;
411 case MSBFirst: cp = "MSBFirst"; break;
413 sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
417 printf ("image byte order: %s\n", cp);
419 pmf = XListPixmapFormats (dpy, &n);
420 printf ("number of supported pixmap formats: %d\n", n);
422 printf ("supported pixmap formats:\n");
423 for (i = 0; i < n; i++) {
424 printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
425 pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
427 XFree ((char *) pmf);
432 * when we get interfaces to the PixmapFormat stuff, insert code here
435 XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
436 printf ("keycode range: minimum %d, maximum %d\n",
437 minkeycode, maxkeycode);
439 XGetInputFocus (dpy, &focuswin, &focusrevert);
443 printf ("PointerRoot\n");
449 printf("window 0x%lx, revert to ", focuswin);
450 switch (focusrevert) {
457 case RevertToPointerRoot:
458 printf ("PointerRoot\n");
460 default: /* should not happen */
461 printf ("%d\n", focusrevert);
467 print_extension_info (dpy);
469 printf ("default screen number: %d\n", DefaultScreen (dpy));
470 printf ("number of screens: %d\n", ScreenCount (dpy));
474 print_visual_info (vip)
477 char errorbuf[40]; /* for sprintfing into */
478 char *class = NULL; /* for printing */
480 switch (vip->class) {
481 case StaticGray: class = "StaticGray"; break;
482 case GrayScale: class = "GrayScale"; break;
483 case StaticColor: class = "StaticColor"; break;
484 case PseudoColor: class = "PseudoColor"; break;
485 case TrueColor: class = "TrueColor"; break;
486 case DirectColor: class = "DirectColor"; break;
488 sprintf (errorbuf, "unknown class %d", vip->class);
493 printf (" visual:\n");
494 printf (" visual id: 0x%lx\n", vip->visualid);
495 printf (" class: %s\n", class);
496 printf (" depth: %d plane%s\n", vip->depth,
497 vip->depth == 1 ? "" : "s");
498 if (vip->class == TrueColor || vip->class == DirectColor)
499 printf (" available colormap entries: %d per subfield\n",
502 printf (" available colormap entries: %d\n",
504 printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
505 vip->red_mask, vip->green_mask, vip->blue_mask);
506 printf (" significant bits in color specification: %d bits\n",
511 print_screen_info (dpy, scr)
515 Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
516 XVisualInfo viproto; /* fill in for getting info */
517 XVisualInfo *vip; /* retured info */
518 int nvi; /* number of elements returned */
519 int i; /* temp variable: iterator */
520 char eventbuf[80]; /* want 79 chars per line + nul */
521 static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
523 int ndepths = 0, *depths = NULL;
524 unsigned int width, height;
528 * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
530 * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
531 * = N pixels / (M inch / 25.4)
532 * = N * 25.4 pixels / M inch
535 xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
536 ((double) DisplayWidthMM(dpy,scr)));
537 yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
538 ((double) DisplayHeightMM(dpy,scr)));
541 printf ("screen #%d:\n", scr);
542 printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
543 DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
544 DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));
545 printf (" resolution: %dx%d dots per inch\n",
546 (int) (xres + 0.5), (int) (yres + 0.5));
547 depths = XListDepths (dpy, scr, &ndepths);
548 if (!depths) ndepths = 0;
549 printf (" depths (%d): ", ndepths);
550 for (i = 0; i < ndepths; i++) {
551 printf ("%d", depths[i]);
552 if (i < ndepths - 1) {
558 if (depths) XFree ((char *) depths);
559 printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
560 printf (" depth of root window: %d plane%s\n",
561 DisplayPlanes (dpy, scr),
562 DisplayPlanes (dpy, scr) == 1 ? "" : "s");
563 printf (" number of colormaps: minimum %d, maximum %d\n",
564 MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
565 printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
566 printf (" default number of colormap cells: %d\n",
567 DisplayCells (dpy, scr));
568 printf (" preallocated pixels: black %d, white %d\n",
569 BlackPixel (dpy, scr), WhitePixel (dpy, scr));
570 printf (" options: backing-store %s, save-unders %s\n",
571 (DoesBackingStore (s) == NotUseful) ? no :
572 ((DoesBackingStore (s) == Always) ? yes : when),
573 DoesSaveUnders (s) ? yes : no);
574 XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
576 if (width == 65535 && height == 65535)
577 printf (" largest cursor: unlimited\n");
579 printf (" largest cursor: %dx%d\n", width, height);
580 printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
581 (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
585 viproto.screen = scr;
586 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
587 printf (" number of visuals: %d\n", nvi);
588 printf (" default visual id: 0x%lx\n",
589 XVisualIDFromVisual (DefaultVisual (dpy, scr)));
590 for (i = 0; i < nvi; i++) {
591 print_visual_info (vip+i);
593 print_overlay_visual_info (vip+i);
594 #endif /* HAVE_OVERLAY */
596 print_glx_visual_info (dpy, vip+i);
597 #endif /* HAVE_GLX */
599 if (vip) XFree ((char *) vip);
603 * The following routine prints out an event mask, wrapping events at nice
607 #define MASK_NAME_WIDTH 25
609 static struct _event_table {
613 { "KeyPressMask ", KeyPressMask },
614 { "KeyReleaseMask ", KeyReleaseMask },
615 { "ButtonPressMask ", ButtonPressMask },
616 { "ButtonReleaseMask ", ButtonReleaseMask },
617 { "EnterWindowMask ", EnterWindowMask },
618 { "LeaveWindowMask ", LeaveWindowMask },
619 { "PointerMotionMask ", PointerMotionMask },
620 { "PointerMotionHintMask ", PointerMotionHintMask },
621 { "Button1MotionMask ", Button1MotionMask },
622 { "Button2MotionMask ", Button2MotionMask },
623 { "Button3MotionMask ", Button3MotionMask },
624 { "Button4MotionMask ", Button4MotionMask },
625 { "Button5MotionMask ", Button5MotionMask },
626 { "ButtonMotionMask ", ButtonMotionMask },
627 { "KeymapStateMask ", KeymapStateMask },
628 { "ExposureMask ", ExposureMask },
629 { "VisibilityChangeMask ", VisibilityChangeMask },
630 { "StructureNotifyMask ", StructureNotifyMask },
631 { "ResizeRedirectMask ", ResizeRedirectMask },
632 { "SubstructureNotifyMask ", SubstructureNotifyMask },
633 { "SubstructureRedirectMask ", SubstructureRedirectMask },
634 { "FocusChangeMask ", FocusChangeMask },
635 { "PropertyChangeMask ", PropertyChangeMask },
636 { "ColormapChangeMask ", ColormapChangeMask },
637 { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
640 int print_event_mask (buf, lastcol, indent, mask)
641 char *buf; /* string to write into */
642 int lastcol; /* strlen(buf)+1 */
643 int indent; /* amount by which to indent */
644 long mask; /* event mask */
646 struct _event_table *etp;
650 buf[0] = buf[lastcol] = '\0'; /* just in case */
652 #define INDENT() { register int i; len = indent; \
653 for (i = 0; i < indent; i++) buf[i] = ' '; }
657 for (etp = event_table; etp->name; etp++) {
658 if (mask & etp->value) {
659 if (len + MASK_NAME_WIDTH > lastcol) {
663 strcpy (buf+len, etp->name);
664 len += MASK_NAME_WIDTH;
669 if (bitsfound) puts (buf);
677 print_standard_extension_info(dpy, extname, majorrev, minorrev)
680 int majorrev, minorrev;
682 int opcode, event, error;
684 printf("%s version %d.%d ", extname, majorrev, minorrev);
686 XQueryExtension(dpy, extname, &opcode, &event, &error);
687 printf ("opcode: %d", opcode);
689 printf (", base event: %d", event);
691 printf (", base error: %d", error);
696 print_multibuf_info(dpy, extname)
700 int i, j; /* temp variable: iterator */
701 int nmono, nstereo; /* count */
702 XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
704 " visual id, max buffers, depth: 0x%lx, %d, %d\n";
706 int majorrev, minorrev;
708 if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
711 print_standard_extension_info(dpy, extname, majorrev, minorrev);
713 for (i = 0; i < ScreenCount (dpy); i++)
715 if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
716 &nstereo, &stereo_info)) {
718 "%s: unable to get multibuffer info for screen %d\n",
721 printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
722 for (j = 0; j < nmono; j++) {
723 printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
726 printf (" number of stereo multibuffer types: %d\n", nstereo);
727 for (j = 0; j < nstereo; j++) {
728 printf (fmt, stereo_info[j].visualid,
729 stereo_info[j].max_buffers, stereo_info[j].depth);
731 if (mono_info) XFree ((char *) mono_info);
732 if (stereo_info) XFree ((char *) stereo_info);
736 } /* end print_multibuf_info */
743 char *subset_names[] = { NULL, "FULL", "DIS" };
744 char *align_names[] = { NULL, "Alignable", "Arbitrary" };
745 char *group_names[] = { /* 0 */ "Default",
746 /* 2 */ "ColorAlloc",
748 /* 6 */ "ConvertFromRGB",
749 /* 8 */ "ConvertToRGB",
756 /* 22 */ "Histogram",
757 /* 24 */ "WhiteAdjust"
761 print_xie_info(dpy, extname)
765 XieExtensionInfo *xieInfo;
769 XieTechniqueGroup prevGroup;
771 if (!XieInitialize(dpy, &xieInfo ))
774 print_standard_extension_info(dpy, extname,
775 xieInfo->server_major_rev, xieInfo->server_minor_rev);
777 printf(" service class: %s\n", subset_names[xieInfo->service_class]);
778 printf(" alignment: %s\n", align_names[xieInfo->alignment]);
779 printf(" uncnst_mantissa: %d\n", xieInfo->uncnst_mantissa);
780 printf(" uncnst_min_exp: %d\n", xieInfo->uncnst_min_exp);
781 printf(" uncnst_max_exp: %d\n", xieInfo->uncnst_max_exp);
782 printf(" cnst_levels:");
783 for (i = 0; i < xieInfo->n_cnst_levels; i++)
784 printf(" %d", xieInfo->cnst_levels[i]);
787 if (!XieQueryTechniques(dpy, xieValAll, &ntechs, &techs))
792 for (i = 0; i < ntechs; i++)
794 if (techs[i].group != prevGroup)
796 printf(" technique group: %s\n", group_names[techs[i].group >> 1]);
797 prevGroup = techs[i].group;
799 printf(" %s\tspeed: %d needs_param: %s number: %d\n",
801 techs[i].speed, (techs[i].needs_param ? "True " : "False"),
805 } /* end print_xie_info */
807 #endif /* HAVE_XIE */
812 print_xtest_info(dpy, extname)
816 int majorrev, minorrev, foo;
818 if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
820 print_standard_extension_info(dpy, extname, majorrev, minorrev);
823 #endif /* HAVE_XTEST */
827 print_sync_info(dpy, extname)
831 int majorrev, minorrev;
832 XSyncSystemCounter *syscounters;
835 if (!XSyncInitialize(dpy, &majorrev, &minorrev))
837 print_standard_extension_info(dpy, extname, majorrev, minorrev);
839 syscounters = XSyncListSystemCounters(dpy, &ncounters);
840 printf(" system counters: %d\n", ncounters);
841 for (i = 0; i < ncounters; i++)
843 printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
844 syscounters[i].name, syscounters[i].counter,
845 XSyncValueLow32(syscounters[i].resolution),
846 XSyncValueHigh32(syscounters[i].resolution));
848 XSyncFreeSystemCounterList(syscounters);
851 #endif /* HAVE_XSYNC */
854 print_shape_info(dpy, extname)
858 int majorrev, minorrev;
860 if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
862 print_standard_extension_info(dpy, extname, majorrev, minorrev);
868 print_mitshm_info(dpy, extname)
872 int majorrev, minorrev;
875 if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
877 print_standard_extension_info(dpy, extname, majorrev, minorrev);
878 printf(" shared pixmaps: ");
881 int format = XShmPixmapFormat(dpy);
882 printf("yes, format: %d\n", format);
894 print_dbe_info(dpy, extname)
898 int majorrev, minorrev;
899 XdbeScreenVisualInfo *svi;
903 if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
906 print_standard_extension_info(dpy, extname, majorrev, minorrev);
907 svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
908 for (iscrn = 0; iscrn < numscreens; iscrn++)
910 printf(" Double-buffered visuals on screen %d\n", iscrn);
911 for (ivis = 0; ivis < svi[iscrn].count; ivis++)
913 printf(" visual id 0x%lx depth %d perflevel %d\n",
914 svi[iscrn].visinfo[ivis].visual,
915 svi[iscrn].visinfo[ivis].depth,
916 svi[iscrn].visinfo[ivis].perflevel);
919 XdbeFreeVisualInfo(svi);
922 #endif /* HAVE_XDBE */
926 print_record_info(dpy, extname)
930 int majorrev, minorrev;
932 if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
934 print_standard_extension_info(dpy, extname, majorrev, minorrev);
937 #endif /* HAVE_XRECORD */
939 /* utilities to manage the list of recognized extensions */
942 typedef int (*ExtensionPrintFunc)(
943 #if NeedFunctionPrototypes
950 ExtensionPrintFunc printfunc;
952 } ExtensionPrintInfo;
954 ExtensionPrintInfo known_extensions[] =
957 {"MIT-SHM", print_mitshm_info, False},
959 {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
960 {"SHAPE", print_shape_info, False},
962 {SYNC_NAME, print_sync_info, False},
963 #endif /* HAVE_XSYNC */
965 {xieExtName, print_xie_info, False},
966 #endif /* HAVE_XIE */
968 {XTestExtensionName, print_xtest_info, False},
969 #endif /* HAVE_XTEST */
971 {"DOUBLE-BUFFER", print_dbe_info, False},
972 #endif /* HAVE_XDBE */
974 {"RECORD", print_record_info, False}
975 #endif /* HAVE_XRECORD */
976 /* add new extensions here */
977 /* wish list: PEX XKB LBX */
980 int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
983 print_known_extensions(f)
987 for (i = 0; i < num_known_extensions; i++)
989 fprintf(f, "%s ", known_extensions[i].extname);
994 mark_extension_for_printing(extname)
999 if (strcmp(extname, "all") == 0)
1001 for (i = 0; i < num_known_extensions; i++)
1002 known_extensions[i].printit = True;
1006 for (i = 0; i < num_known_extensions; i++)
1008 if (strcmp(extname, known_extensions[i].extname) == 0)
1010 known_extensions[i].printit = True;
1014 printf("%s extension not supported by %s\n", extname, ProgramName);
1019 print_marked_extensions(dpy)
1023 for (i = 0; i < num_known_extensions; i++)
1025 if (known_extensions[i].printit)
1028 if (! (*known_extensions[i].printfunc)(dpy,
1029 known_extensions[i].extname))
1031 printf("%s extension not supported by server\n",
1032 known_extensions[i].extname);
1038 static void usage ()
1040 fprintf (stderr, "usage: %s [options]\n", ProgramName);
1041 fprintf (stderr, "-display displayname\tserver to query\n");
1042 fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
1043 fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
1044 fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
1045 print_known_extensions(stderr);
1046 fprintf (stderr, "\n");
1050 int main (argc, argv)
1054 Display *dpy; /* X connection */
1055 char *displayname = NULL; /* server to contact */
1056 int i; /* temp variable: iterator */
1057 Bool multibuf = False;
1058 int mbuf_event_base, mbuf_error_base;
1060 ProgramName = argv[0];
1062 for (i = 1; i < argc; i++) {
1063 char *arg = argv[i];
1064 int len = strlen(arg);
1066 if (!strncmp("-display", arg, len)) {
1067 if (++i >= argc) usage ();
1068 displayname = argv[i];
1069 } else if (!strncmp("-queryExtensions", arg, len)) {
1070 queryExtensions = True;
1071 } else if (!strncmp("-ext", arg, len)) {
1072 if (++i >= argc) usage ();
1073 mark_extension_for_printing(argv[i]);
1078 dpy = XOpenDisplay (displayname);
1080 fprintf (stderr, "%s: unable to open display \"%s\".\n",
1081 ProgramName, XDisplayName (displayname));
1086 find_overlay_info (dpy);
1087 #endif /* HAVE_OVERLAY */
1089 print_display_info (dpy);
1090 for (i = 0; i < ScreenCount (dpy); i++) {
1091 print_screen_info (dpy, i);
1094 print_marked_extensions(dpy);
1096 XCloseDisplay (dpy);