2 * $Xorg: xdpyinfo.c,v 1.5 2001/02/09 02:05:41 xorgcvs Exp $
4 * xdpyinfo - print information about X display connecton
7 Copyright 1988, 1998 The Open Group
8 Copyright 2005 Hitachi, Ltd.
10 Permission to use, copy, modify, distribute, and sell this software and its
11 documentation for any purpose is hereby granted without fee, provided that
12 the above copyright notice appear in all copies and that both that
13 copyright notice and this permission notice appear in supporting
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of The Open Group shall not be
27 used in advertising or otherwise to promote the sale, use or other dealings
28 in this Software without prior written authorization from The Open Group.
30 * Author: Jim Fulton, MIT X Consortium
33 /* $XFree86: xc/programs/xdpyinfo/xdpyinfo.c,v 3.29 2003/04/14 20:38:10 herrb Exp $ */
37 # if HAVE_X11_EXTENSIONS_MULTIBUF_H
41 # if HAVE_X11_EXTENSIONS_XSHM_H
45 # if HAVE_X11_EXTENSIONS_XKB_H && HAVE_X11_XKBLIB_H
49 # if HAVE_X11_EXTENSIONS_XF86VMODE_H && HAVE_X11_EXTENSIONS_XF86VMSTR_H
53 # if HAVE_X11_EXTENSIONS_XF86DGA_H && HAVE_X11_EXTENSIONS_XF86DGASTR_H
57 # if HAVE_X11_EXTENSIONS_XF86MISC_H && HAVE_X11_EXTENSIONS_XF86MSCSTR_H
61 # if HAVE_X11_EXTENSIONS_XINPUT_H
65 # if HAVE_X11_EXTENSIONS_XRENDER_H
69 # if HAVE_X11_EXTENSIONS_XINERAMA_H
73 # if HAVE_X11_EXTENSIONS_DMXEXT_H
77 # if HAVE_X11_EXTENSIONS_PRINT_H
78 # define INCLUDE_XPRINT_SUPPORT
84 #include <X11/Xutil.h>
86 #include <X11/extensions/multibuf.h>
88 #include <X11/extensions/XTest.h>
89 #include <X11/extensions/sync.h>
90 #include <X11/Xproto.h>
91 #include <X11/extensions/Xdbe.h>
92 #include <X11/extensions/record.h>
93 #include <X11/extensions/shape.h>
95 #include <X11/extensions/XShm.h>
98 #include <X11/extensions/XKB.h>
99 #include <X11/XKBlib.h>
102 #include <X11/extensions/xf86vmode.h>
103 #include <X11/extensions/xf86vmstr.h>
106 #include <X11/extensions/xf86dga.h>
107 #include <X11/extensions/xf86dgastr.h>
110 #include <X11/extensions/xf86misc.h>
111 #include <X11/extensions/xf86mscstr.h>
114 #include <X11/extensions/XInput.h>
117 #include <X11/extensions/Xrender.h>
120 #include <X11/extensions/Xinerama.h>
123 #include <X11/extensions/dmxext.h>
125 #ifdef INCLUDE_XPRINT_SUPPORT
126 #include <X11/extensions/Print.h>
127 #endif /* INCLUDE_XPRINT_SUPPORT */
132 /* Turn a NULL pointer string into an empty string */
133 #define NULLSTR(x) (((x)!=NULL)?(x):(""))
136 Bool queryExtensions = False;
138 static int print_event_mask(char *buf, int lastcol, int indent, long mask);
140 static int StrCmp(const void *a, const void *b)
142 return strcmp(*(char **)a, *(char **)b);
146 print_extension_info(Display *dpy)
149 char **extlist = XListExtensions (dpy, &n);
151 printf ("number of extensions: %d\n", n);
155 int opcode, event, error;
157 qsort(extlist, n, sizeof(char *), StrCmp);
158 for (i = 0; i < n; i++) {
159 if (!queryExtensions) {
160 printf (" %s\n", extlist[i]);
163 XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
164 printf (" %s (opcode: %d", extlist[i], opcode);
166 printf (", base event: %d", event);
168 printf (", base error: %d", error);
171 /* do not free, Xlib can depend on contents being unaltered */
172 /* XFreeExtensionList (extlist); */
177 print_display_info(Display *dpy)
181 int minkeycode, maxkeycode;
184 XPixmapFormatValues *pmf;
188 printf ("name of display: %s\n", DisplayString (dpy));
189 printf ("version number: %d.%d\n",
190 ProtocolVersion (dpy), ProtocolRevision (dpy));
191 printf ("vendor string: %s\n", ServerVendor (dpy));
192 printf ("vendor release number: %d\n", VendorRelease (dpy));
194 if (strstr(ServerVendor (dpy), "XFree86")) {
195 int vendrel = VendorRelease(dpy);
197 printf("XFree86 version: ");
200 * vendrel was set incorrectly for 3.3.4 and 3.3.5, so handle
203 printf("%d.%d.%d", vendrel / 100,
206 } else if (vendrel < 3900) {
207 /* 3.3.x versions, other than the exceptions handled above */
208 printf("%d.%d", vendrel / 1000,
209 (vendrel / 100) % 10);
210 if (((vendrel / 10) % 10) || (vendrel % 10)) {
211 printf(".%d", (vendrel / 10) % 10);
213 printf(".%d", vendrel % 10);
216 } else if (vendrel < 40000000) {
218 printf("%d.%d", vendrel / 1000,
219 (vendrel / 10) % 10);
221 printf(".%d", vendrel % 10);
225 printf("%d.%d.%d", vendrel / 10000000,
226 (vendrel / 100000) % 100,
227 (vendrel / 1000) % 100);
228 if (vendrel % 1000) {
229 printf(".%d", vendrel % 1000);
235 if (strstr(ServerVendor (dpy), "X.Org")) {
236 int vendrel = VendorRelease(dpy);
238 printf("X.Org version: ");
239 printf("%d.%d.%d", vendrel / 10000000,
240 (vendrel / 100000) % 100,
241 (vendrel / 1000) % 100);
243 printf(".%d", vendrel % 1000);
247 if (strstr(ServerVendor (dpy), "DMX")) {
248 int vendrel = VendorRelease(dpy);
249 int major, minor, year, month, day;
251 major = vendrel / 100000000;
252 vendrel -= major * 100000000;
253 minor = vendrel / 1000000;
254 vendrel -= minor * 1000000;
255 year = vendrel / 10000;
256 vendrel -= year * 10000;
257 month = vendrel / 100;
258 vendrel -= month * 100;
261 /* Add other epoch tests here */
262 if (major > 0 && minor > 0) year += 2000;
264 /* Do some sanity tests in case there is
265 * another server with the same vendor
266 * string. That server could easily use
267 * values < 100000000, which would have
268 * the effect of keeping our major
270 if (major > 0 && major <= 20
271 && minor >= 0 && minor <= 99
273 && month >= 1 && month <= 12
274 && day >= 1 && day <= 31)
275 printf("DMX version: %d.%d.%04d%02d%02d\n",
276 major, minor, year, month, day);
279 req_size = XExtendedMaxRequestSize (dpy);
280 if (!req_size) req_size = XMaxRequestSize (dpy);
281 printf ("maximum request size: %ld bytes\n", req_size * 4);
282 printf ("motion buffer size: %ld\n", XDisplayMotionBufferSize (dpy));
284 switch (BitmapBitOrder (dpy)) {
285 case LSBFirst: cp = "LSBFirst"; break;
286 case MSBFirst: cp = "MSBFirst"; break;
288 sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
292 printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
293 BitmapUnit (dpy), cp, BitmapPad (dpy));
295 switch (ImageByteOrder (dpy)) {
296 case LSBFirst: cp = "LSBFirst"; break;
297 case MSBFirst: cp = "MSBFirst"; break;
299 sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
303 printf ("image byte order: %s\n", cp);
305 pmf = XListPixmapFormats (dpy, &n);
306 printf ("number of supported pixmap formats: %d\n", n);
308 printf ("supported pixmap formats:\n");
309 for (i = 0; i < n; i++) {
310 printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
311 pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
313 XFree ((char *) pmf);
318 * when we get interfaces to the PixmapFormat stuff, insert code here
321 XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
322 printf ("keycode range: minimum %d, maximum %d\n",
323 minkeycode, maxkeycode);
325 XGetInputFocus (dpy, &focuswin, &focusrevert);
329 printf ("PointerRoot\n");
335 printf("window 0x%lx, revert to ", focuswin);
336 switch (focusrevert) {
343 case RevertToPointerRoot:
344 printf ("PointerRoot\n");
346 default: /* should not happen */
347 printf ("%d\n", focusrevert);
353 print_extension_info (dpy);
355 printf ("default screen number: %d\n", DefaultScreen (dpy));
356 printf ("number of screens: %d\n", ScreenCount (dpy));
360 print_visual_info(XVisualInfo *vip)
362 char errorbuf[40]; /* for sprintfing into */
363 char *class = NULL; /* for printing */
365 switch (vip->class) {
366 case StaticGray: class = "StaticGray"; break;
367 case GrayScale: class = "GrayScale"; break;
368 case StaticColor: class = "StaticColor"; break;
369 case PseudoColor: class = "PseudoColor"; break;
370 case TrueColor: class = "TrueColor"; break;
371 case DirectColor: class = "DirectColor"; break;
373 sprintf (errorbuf, "unknown class %d", vip->class);
378 printf (" visual:\n");
379 printf (" visual id: 0x%lx\n", vip->visualid);
380 printf (" class: %s\n", class);
381 printf (" depth: %d plane%s\n", vip->depth,
382 vip->depth == 1 ? "" : "s");
383 if (vip->class == TrueColor || vip->class == DirectColor)
384 printf (" available colormap entries: %d per subfield\n",
387 printf (" available colormap entries: %d\n",
389 printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
390 vip->red_mask, vip->green_mask, vip->blue_mask);
391 printf (" significant bits in color specification: %d bits\n",
395 /* xc/programs/twm/twm.c has a copy of |hasExtension()|, please
396 * keep both versions in sync... */
398 Bool hasExtension(Display *dpy, char *extname)
403 extensions = XListExtensions(dpy, &num_extensions);
404 for (i = 0; i < num_extensions &&
405 (strcmp(extensions[i], extname) != 0); i++);
406 XFreeExtensionList(extensions);
407 return i != num_extensions;
410 #ifdef INCLUDE_XPRINT_SUPPORT
411 /* xc/programs/twm/twm.c has a copy of |IsPrintScreen()|, please
412 * keep both versions in sync... */
414 Bool IsPrintScreen(Screen *s)
416 Display *dpy = XDisplayOfScreen(s);
419 /* Check whether this is a screen of a print DDX */
420 if (hasExtension(dpy, XP_PRINTNAME)) {
424 pscreens = XpQueryScreens(dpy, &pscrcount);
425 for( i = 0 ; (i < pscrcount) && pscreens ; i++ ) {
426 if (s == pscreens[i]) {
434 #endif /* INCLUDE_XPRINT_SUPPORT */
437 print_screen_info(Display *dpy, int scr)
439 Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
440 XVisualInfo viproto; /* fill in for getting info */
441 XVisualInfo *vip; /* retured info */
442 int nvi; /* number of elements returned */
443 int i; /* temp variable: iterator */
444 char eventbuf[80]; /* want 79 chars per line + nul */
445 static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
447 int ndepths = 0, *depths = NULL;
448 unsigned int width, height;
449 Bool isPrintScreen = False; /* Initalise this if |INCLUDE_XPRINT_SUPPORT| is not set */
452 * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
454 * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
455 * = N pixels / (M inch / 25.4)
456 * = N * 25.4 pixels / M inch
459 xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
460 ((double) DisplayWidthMM(dpy,scr)));
461 yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
462 ((double) DisplayHeightMM(dpy,scr)));
465 printf ("screen #%d:\n", scr);
467 #ifdef INCLUDE_XPRINT_SUPPORT
468 /* Check whether this is a screen of a print DDX */
469 isPrintScreen = IsPrintScreen(s);
470 printf (" print screen: %s\n", isPrintScreen?"yes":"no");
471 #endif /* INCLUDE_XPRINT_SUPPORT */
474 /* Print resolution is set on a per-printer basis (per-document
475 * or per-page), the screen itself has no "default" resolution */
476 printf (" maximum dimensions: %dx%d pixels\n",
477 XDisplayWidth (dpy, scr), XDisplayHeight (dpy, scr));
481 printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
482 XDisplayWidth (dpy, scr), XDisplayHeight (dpy, scr),
483 XDisplayWidthMM(dpy, scr), XDisplayHeightMM (dpy, scr));
484 printf (" resolution: %dx%d dots per inch\n",
485 (int) (xres + 0.5), (int) (yres + 0.5));
487 depths = XListDepths (dpy, scr, &ndepths);
488 if (!depths) ndepths = 0;
489 printf (" depths (%d): ", ndepths);
490 for (i = 0; i < ndepths; i++) {
491 printf ("%d", depths[i]);
492 if (i < ndepths - 1) {
498 if (depths) XFree ((char *) depths);
499 printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
500 printf (" depth of root window: %d plane%s\n",
501 DisplayPlanes (dpy, scr),
502 DisplayPlanes (dpy, scr) == 1 ? "" : "s");
503 printf (" number of colormaps: minimum %d, maximum %d\n",
504 MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
505 printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
506 printf (" default number of colormap cells: %d\n",
507 DisplayCells (dpy, scr));
508 printf (" preallocated pixels: black %ld, white %ld\n",
509 BlackPixel (dpy, scr), WhitePixel (dpy, scr));
510 printf (" options: backing-store %s, save-unders %s\n",
511 (DoesBackingStore (s) == NotUseful) ? no :
512 ((DoesBackingStore (s) == Always) ? yes : when),
513 DoesSaveUnders (s) ? yes : no);
514 XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
516 if (width == 65535 && height == 65535)
517 printf (" largest cursor: unlimited\n");
519 printf (" largest cursor: %dx%d\n", width, height);
520 printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
521 (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
524 viproto.screen = scr;
525 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
526 printf (" number of visuals: %d\n", nvi);
527 printf (" default visual id: 0x%lx\n",
528 XVisualIDFromVisual (DefaultVisual (dpy, scr)));
529 for (i = 0; i < nvi; i++) {
530 print_visual_info (vip+i);
532 if (vip) XFree ((char *) vip);
536 * The following routine prints out an event mask, wrapping events at nice
540 #define MASK_NAME_WIDTH 25
542 static struct _event_table {
546 { "KeyPressMask ", KeyPressMask },
547 { "KeyReleaseMask ", KeyReleaseMask },
548 { "ButtonPressMask ", ButtonPressMask },
549 { "ButtonReleaseMask ", ButtonReleaseMask },
550 { "EnterWindowMask ", EnterWindowMask },
551 { "LeaveWindowMask ", LeaveWindowMask },
552 { "PointerMotionMask ", PointerMotionMask },
553 { "PointerMotionHintMask ", PointerMotionHintMask },
554 { "Button1MotionMask ", Button1MotionMask },
555 { "Button2MotionMask ", Button2MotionMask },
556 { "Button3MotionMask ", Button3MotionMask },
557 { "Button4MotionMask ", Button4MotionMask },
558 { "Button5MotionMask ", Button5MotionMask },
559 { "ButtonMotionMask ", ButtonMotionMask },
560 { "KeymapStateMask ", KeymapStateMask },
561 { "ExposureMask ", ExposureMask },
562 { "VisibilityChangeMask ", VisibilityChangeMask },
563 { "StructureNotifyMask ", StructureNotifyMask },
564 { "ResizeRedirectMask ", ResizeRedirectMask },
565 { "SubstructureNotifyMask ", SubstructureNotifyMask },
566 { "SubstructureRedirectMask ", SubstructureRedirectMask },
567 { "FocusChangeMask ", FocusChangeMask },
568 { "PropertyChangeMask ", PropertyChangeMask },
569 { "ColormapChangeMask ", ColormapChangeMask },
570 { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
574 print_event_mask(char *buf, /* string to write into */
575 int lastcol, /* strlen(buf)+1 */
576 int indent, /* amount by which to indent */
577 long mask) /* event mask */
579 struct _event_table *etp;
583 buf[0] = buf[lastcol] = '\0'; /* just in case */
585 #define INDENT() { register int i; len = indent; \
586 for (i = 0; i < indent; i++) buf[i] = ' '; }
590 for (etp = event_table; etp->name; etp++) {
591 if (mask & etp->value) {
592 if (len + MASK_NAME_WIDTH > lastcol) {
596 strcpy (buf+len, etp->name);
597 len += MASK_NAME_WIDTH;
602 if (bitsfound) puts (buf);
610 print_standard_extension_info(Display *dpy, char *extname,
611 int majorrev, int minorrev)
613 int opcode, event, error;
615 printf("%s version %d.%d ", extname, majorrev, minorrev);
617 XQueryExtension(dpy, extname, &opcode, &event, &error);
618 printf ("opcode: %d", opcode);
620 printf (", base event: %d", event);
622 printf (", base error: %d", error);
628 print_multibuf_info(Display *dpy, char *extname)
630 int i, j; /* temp variable: iterator */
631 int nmono, nstereo; /* count */
632 XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
634 " visual id, max buffers, depth: 0x%lx, %d, %d\n";
636 int majorrev, minorrev;
638 if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
641 print_standard_extension_info(dpy, extname, majorrev, minorrev);
643 for (i = 0; i < ScreenCount (dpy); i++)
645 if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
646 &nstereo, &stereo_info)) {
648 "%s: unable to get multibuffer info for screen %d\n",
651 printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
652 for (j = 0; j < nmono; j++) {
653 printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
656 printf (" number of stereo multibuffer types: %d\n", nstereo);
657 for (j = 0; j < nstereo; j++) {
658 printf (fmt, stereo_info[j].visualid,
659 stereo_info[j].max_buffers, stereo_info[j].depth);
661 if (mono_info) XFree ((char *) mono_info);
662 if (stereo_info) XFree ((char *) stereo_info);
666 } /* end print_multibuf_info */
670 print_xtest_info(Display *dpy, char *extname)
672 int majorrev, minorrev, foo;
674 if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
676 print_standard_extension_info(dpy, extname, majorrev, minorrev);
681 print_sync_info(Display *dpy, char *extname)
683 int majorrev, minorrev;
684 XSyncSystemCounter *syscounters;
687 if (!XSyncInitialize(dpy, &majorrev, &minorrev))
689 print_standard_extension_info(dpy, extname, majorrev, minorrev);
691 syscounters = XSyncListSystemCounters(dpy, &ncounters);
692 printf(" system counters: %d\n", ncounters);
693 for (i = 0; i < ncounters; i++)
695 printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
696 syscounters[i].name, (unsigned int)syscounters[i].counter,
697 XSyncValueLow32(syscounters[i].resolution),
698 XSyncValueHigh32(syscounters[i].resolution));
700 XSyncFreeSystemCounterList(syscounters);
705 print_shape_info(Display *dpy, char *extname)
707 int majorrev, minorrev;
709 if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
711 print_standard_extension_info(dpy, extname, majorrev, minorrev);
717 print_dga_info(Display *dpy, char *extname)
719 int majorrev, minorrev, width, bank, ram, offset, flags;
721 if (!XF86DGAQueryVersion(dpy, &majorrev, &minorrev))
723 print_standard_extension_info(dpy, extname, majorrev, minorrev);
725 if (!XF86DGAQueryDirectVideo(dpy, DefaultScreen(dpy), &flags)
726 || ! (flags & XF86DGADirectPresent) )
728 printf(" DGA not available on screen %d.\n", DefaultScreen(dpy));
732 if (!XF86DGAGetVideoLL(dpy, DefaultScreen(dpy), &offset,
733 &width, &bank, &ram))
735 printf(" Base address = 0x%X, Width = %d, Bank size = %d,"
736 " RAM size = %dk\n", offset, width, bank, ram);
743 #define V_PHSYNC 0x001
744 #define V_NHSYNC 0x002
745 #define V_PVSYNC 0x004
746 #define V_NVSYNC 0x008
747 #define V_INTERLACE 0x010
748 #define V_DBLSCAN 0x020
749 #define V_CSYNC 0x040
750 #define V_PCSYNC 0x080
751 #define V_NCSYNC 0x100
754 print_XF86VidMode_info(Display *dpy, char *extname)
756 int majorrev, minorrev, modecount, dotclock, i;
757 XF86VidModeMonitor monitor;
758 XF86VidModeModeLine modeline;
759 XF86VidModeModeInfo **modelines;
761 if (!XF86VidModeQueryVersion(dpy, &majorrev, &minorrev))
763 print_standard_extension_info(dpy, extname, majorrev, minorrev);
765 if (!XF86VidModeGetMonitor(dpy, DefaultScreen(dpy), &monitor))
767 printf(" Monitor Information:\n");
768 printf(" Vendor: %s, Model: %s\n", monitor.vendor, monitor.model);
769 printf(" Num hsync: %d, Num vsync: %d\n", monitor.nhsync, monitor.nvsync);
770 for (i = 0; i < monitor.nhsync; i++) {
771 printf(" hsync range %d: %6.2f - %6.2f\n", i, monitor.hsync[i].lo,
772 monitor.hsync[i].hi);
774 for (i = 0; i < monitor.nvsync; i++) {
775 printf(" vsync range %d: %6.2f - %6.2f\n", i, monitor.vsync[i].lo,
776 monitor.vsync[i].hi);
779 if ((majorrev > 0) || (majorrev == 0 && minorrev > 5)) {
780 if (!XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &modecount,
783 printf(" Available Video Mode Settings:\n");
784 printf(" Clock Hdsp Hbeg Hend Httl Vdsp Vbeg Vend Vttl Flags\n");
785 for (i = 0; i < modecount; i++) {
786 printf(" %6.2f %4d %4d %4d %4d %4d %4d %4d %4d ",
787 (float)modelines[i]->dotclock/1000.0,
788 modelines[i]->hdisplay, modelines[i]->hsyncstart,
789 modelines[i]->hsyncend, modelines[i]->htotal,
790 modelines[i]->vdisplay, modelines[i]->vsyncstart,
791 modelines[i]->vsyncend, modelines[i]->vtotal);
792 if (modelines[i]->flags & V_PHSYNC) printf(" +hsync");
793 if (modelines[i]->flags & V_NHSYNC) printf(" -hsync");
794 if (modelines[i]->flags & V_PVSYNC) printf(" +vsync");
795 if (modelines[i]->flags & V_NVSYNC) printf(" -vsync");
796 if (modelines[i]->flags & V_INTERLACE) printf(" interlace");
797 if (modelines[i]->flags & V_CSYNC) printf(" composite");
798 if (modelines[i]->flags & V_PCSYNC) printf(" +csync");
799 if (modelines[i]->flags & V_PCSYNC) printf(" -csync");
800 if (modelines[i]->flags & V_DBLSCAN) printf(" doublescan");
804 if (!XF86VidModeGetModeLine(dpy, DefaultScreen(dpy),
805 &dotclock, &modeline))
807 printf(" Current Video Mode Setting:\n");
808 printf(" %6.2f %4d %4d %4d %4d %4d %4d %4d %4d ",
809 (float)dotclock/1000.0,
810 modeline.hdisplay, modeline.hsyncstart,
811 modeline.hsyncend, modeline.htotal,
812 modeline.vdisplay, modeline.vsyncstart,
813 modeline.vsyncend, modeline.vtotal);
814 if (modeline.flags & V_PHSYNC) printf(" +hsync");
815 if (modeline.flags & V_NHSYNC) printf(" -hsync");
816 if (modeline.flags & V_PVSYNC) printf(" +vsync");
817 if (modeline.flags & V_NVSYNC) printf(" -vsync");
818 if (modeline.flags & V_INTERLACE) printf(" interlace");
819 if (modeline.flags & V_CSYNC) printf(" composite");
820 if (modeline.flags & V_PCSYNC) printf(" +csync");
821 if (modeline.flags & V_PCSYNC) printf(" -csync");
822 if (modeline.flags & V_DBLSCAN) printf(" doublescan");
832 char *kbdtable[] = { "Unknown", "84-key", "101-key", "Other", "Xqueue" };
833 char *msetable[] = { "None", "Microsoft", "MouseSystems", "MMSeries",
834 "Logitech", "BusMouse", "Mouseman", "PS/2", "MMHitTab",
835 "GlidePoint", "IntelliMouse", "ThinkingMouse",
836 "IMPS/2", "ThinkingMousePS/2", "MouseManPlusPS/2",
837 "GlidePointPS/2", "NetMousePS/2", "NetScrollPS/2",
838 "SysMouse", "Auto" };
839 char *flgtable[] = { "None", "ClearDTR", "ClearRTS",
840 "ClearDTR and ClearRTS" };
843 print_XF86Misc_info(Display *dpy, char *extname)
845 int majorrev, minorrev;
846 XF86MiscMouseSettings mouseinfo;
847 XF86MiscKbdSettings kbdinfo;
849 if (!XF86MiscQueryVersion(dpy, &majorrev, &minorrev))
851 print_standard_extension_info(dpy, extname, majorrev, minorrev);
853 if ((majorrev > 0) || (majorrev == 0 && minorrev > 0)) {
854 if (!XF86MiscGetKbdSettings(dpy, &kbdinfo))
856 printf(" Keyboard Settings- Type: %s, Rate: %d, Delay: %d, ServerNumLock: %s\n",
857 kbdtable[kbdinfo.type], kbdinfo.rate, kbdinfo.delay,
858 (kbdinfo.servnumlock? "yes": "no"));
860 if (!XF86MiscGetMouseSettings(dpy, &mouseinfo))
862 printf(" Mouse Settings- Device: %s, Type: ",
863 strlen(mouseinfo.device) == 0 ? "None": mouseinfo.device);
864 if (mouseinfo.type == MTYPE_XQUEUE)
866 else if (mouseinfo.type == MTYPE_OSMOUSE)
868 else if (mouseinfo.type <= MTYPE_AUTOMOUSE)
869 printf("%s\n", msetable[mouseinfo.type+1]);
872 printf(" BaudRate: %d, SampleRate: %d, Resolution: %d\n",
873 mouseinfo.baudrate, mouseinfo.samplerate, mouseinfo.resolution);
874 printf(" Emulate3Buttons: %s, Emulate3Timeout: %d ms\n",
875 mouseinfo.emulate3buttons? "yes": "no", mouseinfo.emulate3timeout);
876 printf(" ChordMiddle: %s, Flags: %s\n",
877 mouseinfo.chordmiddle? "yes": "no",
878 flgtable[(mouseinfo.flags & MF_CLEAR_DTR? 1: 0)
879 +(mouseinfo.flags & MF_CLEAR_RTS? 1: 0)] );
880 printf(" Buttons: %d\n", mouseinfo.buttons);
889 print_mitshm_info(Display *dpy, char *extname)
891 int majorrev, minorrev;
894 if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
896 print_standard_extension_info(dpy, extname, majorrev, minorrev);
897 printf(" shared pixmaps: ");
900 int format = XShmPixmapFormat(dpy);
901 printf("yes, format: %d\n", format);
913 print_xkb_info(Display *dpy, char *extname)
915 int opcode, eventbase, errorbase, majorrev, minorrev;
917 if (!XkbQueryExtension(dpy, &opcode, &eventbase, &errorbase,
918 &majorrev, &minorrev)) {
921 printf("%s version %d.%d ", extname, majorrev, minorrev);
923 printf ("opcode: %d", opcode);
925 printf (", base event: %d", eventbase);
927 printf (", base error: %d", errorbase);
935 print_dbe_info(Display *dpy, char *extname)
937 int majorrev, minorrev;
938 XdbeScreenVisualInfo *svi;
942 if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
945 print_standard_extension_info(dpy, extname, majorrev, minorrev);
946 svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
947 for (iscrn = 0; iscrn < numscreens; iscrn++)
949 printf(" Double-buffered visuals on screen %d\n", iscrn);
950 for (ivis = 0; ivis < svi[iscrn].count; ivis++)
952 printf(" visual id 0x%lx depth %d perflevel %d\n",
953 svi[iscrn].visinfo[ivis].visual,
954 svi[iscrn].visinfo[ivis].depth,
955 svi[iscrn].visinfo[ivis].perflevel);
958 XdbeFreeVisualInfo(svi);
963 print_record_info(Display *dpy, char *extname)
965 int majorrev, minorrev;
967 if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
969 print_standard_extension_info(dpy, extname, majorrev, minorrev);
975 print_xinput_info(Display *dpy, char *extname)
977 int loop, num_extensions, num_devices;
979 XDeviceInfo *devices;
980 XExtensionVersion *ext;
982 ext = XGetExtensionVersion(dpy, extname);
984 if (!ext || (ext == (XExtensionVersion*) NoSuchExtension))
987 print_standard_extension_info(dpy, extname, ext->major_version,
990 extensions = XListExtensions(dpy, &num_extensions);
991 for (loop = 0; loop < num_extensions &&
992 (strcmp(extensions[loop], extname) != 0); loop++);
993 XFreeExtensionList(extensions);
994 if (loop != num_extensions) {
995 printf(" Extended devices :\n");
996 devices = XListInputDevices(dpy, &num_devices);
997 for(loop=0; loop<num_devices; loop++) {
998 printf(" \"%s\" [", devices[loop].name ? devices[loop].name : "<noname>");
999 switch(devices[loop].use) {
1001 printf("XPointer]\n");
1004 printf("XKeyboard]\n");
1006 case IsXExtensionDevice:
1007 printf("XExtensionDevice]\n");
1010 printf("invalid value]\n");
1014 XFreeDeviceList(devices);
1024 print_xrender_info(Display *dpy, char *extname)
1026 int loop, num_extensions;
1028 XRenderPictFormat *pictform;
1032 XVisualInfo viproto; /* fill in for getting info */
1033 XVisualInfo *vip; /* retured info */
1034 int nvi; /* number of elements returned */
1035 int ndepths = 0, *depths = NULL;
1036 #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
1041 if (!XRenderQueryVersion (dpy, &major, &minor))
1044 print_standard_extension_info(dpy, extname, major, minor);
1046 extensions = XListExtensions(dpy, &num_extensions);
1047 for (loop = 0; loop < num_extensions &&
1048 (strcmp(extensions[loop], extname) != 0); loop++);
1049 XFreeExtensionList(extensions);
1050 if (loop != num_extensions) {
1051 printf (" Render formats :\n");
1052 for (count = 0; (pictform = XRenderFindFormat (dpy, 0, 0, count)); count++)
1054 printf (" pict format:\n");
1055 printf ("\tformat id: 0x%lx\n", pictform->id);
1056 printf ("\ttype: %s\n",
1057 pictform->type == PictTypeIndexed ? "Indexed" : "Direct");
1058 printf ("\tdepth: %d\n", pictform->depth);
1059 if (pictform->type == PictTypeDirect) {
1060 printf("\talpha: %2d mask 0x%x\n", pictform->direct.alpha, pictform->direct.alphaMask);
1061 printf("\tred: %2d mask 0x%x\n", pictform->direct.red, pictform->direct.redMask);
1062 printf("\tgreen: %2d mask 0x%x\n", pictform->direct.green, pictform->direct.greenMask);
1063 printf("\tblue: %2d mask 0x%x\n", pictform->direct.blue, pictform->direct.blueMask);
1066 printf("\tcolormap 0x%lx\n", pictform->colormap);
1068 printf (" Screen formats :\n");
1069 for (i = 0; i < ScreenCount (dpy); i++) {
1072 vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
1073 printf (" Screen %d", i);
1074 #if RENDER_MAJOR > 0 || RENDER_MINOR >= 6
1075 switch (XRenderQuerySubpixelOrder (dpy, i)) {
1076 case SubPixelUnknown: printf (" (sub-pixel order Unknown)"); break;
1077 case SubPixelHorizontalRGB: printf (" (sub-pixel order Horizontal RGB)"); break;
1078 case SubPixelHorizontalBGR: printf (" (sub-pixel order Horizontal BGR)"); break;
1079 case SubPixelVerticalRGB: printf (" (sub-pixel order Vertical RGB)"); break;
1080 case SubPixelVerticalBGR: printf (" (sub-pixel order Vertical BGR)"); break;
1081 case SubPixelNone: printf (" (sub-pixel order None)"); break;
1084 filters = XRenderQueryFilters (dpy, RootWindow (dpy, i));
1087 printf (" filters: ");
1088 for (f = 0; f < filters->nfilter; f++)
1090 printf ("%s", filters->filter[f]);
1091 if (f < filters->nalias && filters->alias[f] != FilterAliasNone)
1092 printf ("(%s)", filters->filter[filters->alias[f]]);
1093 if (f < filters->nfilter - 1)
1100 for (j = 0; j < nvi; j++)
1102 printf (" visual format:\n");
1103 printf (" visual id: 0x%lx\n", vip[j].visualid);
1104 pictform = XRenderFindVisualFormat (dpy, vip[j].visual);
1106 printf(" pict format id: 0x%lx\n", pictform->id);
1108 printf(" pict format id: None\n");
1110 if (vip) XFree ((char *) vip);
1111 depths = XListDepths (dpy, i, &ndepths);
1112 if (!depths) ndepths = 0;
1113 for (j = 0; j < ndepths; j++)
1115 XRenderPictFormat templ;
1117 templ.depth = depths[j];
1118 printf (" depth formats:\n");
1119 printf (" depth %d\n", depths[j]);
1120 for (count = 0; (pictform = XRenderFindFormat (dpy, PictFormatDepth, &templ, count)); count++)
1121 printf(" pict format id: 0x%lx\n", pictform->id);
1129 #endif /* XRENDER */
1135 print_xinerama_info(Display *dpy, char *extname)
1137 int majorrev, minorrev;
1139 if (!XineramaQueryVersion (dpy, &majorrev, &minorrev))
1142 print_standard_extension_info(dpy, extname, majorrev, minorrev);
1144 if (!XineramaIsActive(dpy)) {
1145 printf(" Xinerama is inactive.\n");
1148 XineramaScreenInfo *xineramaScreens = XineramaQueryScreens(dpy, &count);
1150 for (i = 0; i < count; i++) {
1151 XineramaScreenInfo *xs = &xineramaScreens[i];
1152 printf(" head #%d: %dx%d @ %d,%d\n", xs->screen_number,
1153 xs->width, xs->height, xs->x_org, xs->y_org);
1156 XFree(xineramaScreens);
1162 #endif /* PANORAMIX */
1165 static const char *core(DMXInputAttributes *iinfo)
1167 if (iinfo->isCore) return "core";
1168 else if (iinfo->sendsCore) return "extension (sends core)";
1169 else return "extension";
1172 static int print_dmx_info(Display *dpy, char *extname)
1174 int event_base, error_base;
1175 int major_version, minor_version, patch_version;
1176 DMXScreenAttributes sinfo;
1177 DMXInputAttributes iinfo;
1181 if (!DMXQueryExtension(dpy, &event_base, &error_base)
1182 || !DMXQueryVersion(dpy, &major_version, &minor_version,
1183 &patch_version)) return 0;
1184 print_standard_extension_info(dpy, extname, major_version, minor_version);
1185 printf(" Version stamp: %d\n", patch_version);
1187 if (!DMXGetScreenCount(dpy, &count)) return 1;
1188 printf(" Screen count: %d\n", count);
1189 for (i = 0; i < count; i++) {
1190 if (DMXGetScreenAttributes(dpy, i, &sinfo)) {
1191 printf(" %2d %s %ux%u+%d+%d %d @%dx%d\n",
1192 i, sinfo.displayName,
1193 sinfo.screenWindowWidth, sinfo.screenWindowHeight,
1194 sinfo.screenWindowXoffset, sinfo.screenWindowYoffset,
1195 sinfo.logicalScreen,
1196 sinfo.rootWindowXorigin, sinfo.rootWindowYorigin);
1200 if (major_version != 1
1201 || minor_version < 1
1202 || !DMXGetInputCount(dpy, &count))
1205 printf(" Input count = %d\n", count);
1206 for (i = 0; i < count; i++) {
1209 char *backendname = NULL;
1211 if (DMXGetInputAttributes(dpy, i, &iinfo)) {
1212 switch (iinfo.inputType) {
1213 case DMXLocalInputType:
1214 printf(" %2d local %s", i, core(&iinfo));
1216 case DMXConsoleInputType:
1217 printf(" %2d console %s %s", i, core(&iinfo),
1220 case DMXBackendInputType:
1222 if (iinfo.physicalId >= 0) {
1223 if ((backend = XOpenDisplay(iinfo.name))) {
1224 XExtensionVersion *ext
1225 = XGetExtensionVersion(backend, INAME);
1227 && ext != (XExtensionVersion *)NoSuchExtension) {
1230 XDeviceInfo *devInfo = XListInputDevices(backend,
1233 for (i = 0; i < count; i++) {
1234 if ((unsigned)iinfo.physicalId
1236 && devInfo[i].name) {
1237 backendname = strdup(devInfo[i].name);
1241 XFreeDeviceList(devInfo);
1244 XCloseDisplay(backend);
1248 printf(" %2d backend %s o%d/%s",i, core(&iinfo),
1249 iinfo.physicalScreen, iinfo.name);
1250 if (iinfo.physicalId >= 0) printf("/id%d", iinfo.physicalId);
1253 printf("=%s", backendname);
1267 #ifdef INCLUDE_XPRINT_SUPPORT
1269 void print_xprint_attrpool(const char *name, const char *attrpool)
1272 const char *s = attrpool;
1274 printf(" %s:\n ", name);
1276 while( (c = *s++) != '\0' )
1286 fputc('\n', stdout);
1290 print_xprint_info(Display *dpy, char *extname)
1297 XPPrinterList printerlist;
1303 if (XpQueryVersion(dpy, &majorrev, &minorrev) == False) {
1307 print_standard_extension_info(dpy, extname, majorrev, minorrev);
1309 if (XpQueryExtension(dpy, &xp_event_base, &xp_error_base) == False) {
1310 printf(" XpQueryExtension() failed.\n");
1314 /* Print event info */
1315 printf(" xp_event_base=%d, xp_error_base=%d\n", xp_event_base, xp_error_base);
1317 /* Print info which screens support the Xprint extension */
1318 printf(" Print screens = {");
1319 pscreens = XpQueryScreens(dpy, &pscrcount);
1320 for( i = 0 ; i < pscrcount ; i++ ) {
1321 printf("%s%d", ((i > 0)?(", "):("")), (int)XScreenNumberOfScreen(pscreens[i]));
1326 /* Enumerate the list of printers */
1327 printerlist = XpGetPrinterList(dpy, NULL, &plcount);
1328 /* Print number of printers, then each printer name and description */
1329 printf(" Found %d printers on this server.\n", plcount);
1330 for( i = 0 ; i < plcount ; i++) {
1331 printf(" printer %d: name='%s', descr='%s'\n",
1332 i, NULLSTR(printerlist[i].name), NULLSTR(printerlist[i].desc));
1335 /* Enumerate the list of printers with details */
1336 for( i = 0 ; i < plcount ; i++) {
1337 char *printername = printerlist[i].name;
1341 printf(" Attributes of printer '%s':\n", NULLSTR(printername));
1343 pcontext = XpCreateContext(dpy, printername);
1344 if (pcontext == None) {
1345 printf(" Error: Could not open printer.\n");
1349 s=XpGetAttributes(dpy, pcontext, XPJobAttr); print_xprint_attrpool("XPJobAttr", s); XFree(s);
1350 s=XpGetAttributes(dpy, pcontext, XPDocAttr); print_xprint_attrpool("XPDocAttr", s); XFree(s);
1351 s=XpGetAttributes(dpy, pcontext, XPPageAttr); print_xprint_attrpool("XPPageAttr", s); XFree(s);
1352 s=XpGetAttributes(dpy, pcontext, XPPrinterAttr); print_xprint_attrpool("XPPrinterAttr", s); XFree(s);
1353 s=XpGetAttributes(dpy, pcontext, XPServerAttr); print_xprint_attrpool("XPServerAttr", s); XFree(s);
1355 XpDestroyContext(dpy, pcontext);
1358 XpFreePrinterList(printerlist);
1362 #endif /* INCLUDE_XPRINT_SUPPORT */
1364 /* utilities to manage the list of recognized extensions */
1367 typedef int (*ExtensionPrintFunc)(
1373 ExtensionPrintFunc printfunc;
1375 } ExtensionPrintInfo;
1377 ExtensionPrintInfo known_extensions[] =
1380 {"MIT-SHM", print_mitshm_info, False},
1383 {XkbName, print_xkb_info, False},
1386 {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
1388 {"SHAPE", print_shape_info, False},
1389 {SYNC_NAME, print_sync_info, False},
1391 {XF86DGANAME, print_dga_info, False},
1392 #endif /* XFreeXDGA */
1394 {XF86VIDMODENAME, print_XF86VidMode_info, False},
1395 #endif /* XF86VIDMODE */
1397 {XF86MISCNAME, print_XF86Misc_info, False},
1398 #endif /* XF86MISC */
1399 {XTestExtensionName, print_xtest_info, False},
1400 {"DOUBLE-BUFFER", print_dbe_info, False},
1401 {"RECORD", print_record_info, False},
1403 {INAME, print_xinput_info, False},
1406 {RENDER_NAME, print_xrender_info, False},
1409 {"XINERAMA", print_xinerama_info, False},
1412 {"DMX", print_dmx_info, False},
1414 #ifdef INCLUDE_XPRINT_SUPPORT
1415 {XP_PRINTNAME, print_xprint_info, False},
1416 #endif /* INCLUDE_XPRINT_SUPPORT */
1417 /* add new extensions here */
1420 int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
1423 print_known_extensions(FILE *f)
1426 for (i = 0, col = 6; i < num_known_extensions; i++)
1428 if ((col += strlen(known_extensions[i].extname)+1) > 79)
1433 fprintf(f, "%s ", known_extensions[i].extname);
1438 mark_extension_for_printing(char *extname)
1442 if (strcmp(extname, "all") == 0)
1444 for (i = 0; i < num_known_extensions; i++)
1445 known_extensions[i].printit = True;
1449 for (i = 0; i < num_known_extensions; i++)
1451 if (strcmp(extname, known_extensions[i].extname) == 0)
1453 known_extensions[i].printit = True;
1457 printf("%s extension not supported by %s\n", extname, ProgramName);
1462 print_marked_extensions(Display *dpy)
1465 for (i = 0; i < num_known_extensions; i++)
1467 if (known_extensions[i].printit)
1470 if (! (*known_extensions[i].printfunc)(dpy,
1471 known_extensions[i].extname))
1473 printf("%s extension not supported by server\n",
1474 known_extensions[i].extname);
1483 fprintf (stderr, "usage: %s [options]\n", ProgramName);
1484 fprintf (stderr, "-display displayname\tserver to query\n");
1485 fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
1486 fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
1487 fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
1488 print_known_extensions(stderr);
1489 fprintf (stderr, "\n");
1494 main(int argc, char *argv[])
1496 Display *dpy; /* X connection */
1497 char *displayname = NULL; /* server to contact */
1498 int i; /* temp variable: iterator */
1500 ProgramName = argv[0];
1502 for (i = 1; i < argc; i++) {
1503 char *arg = argv[i];
1504 int len = strlen(arg);
1506 if (!strncmp("-display", arg, len)) {
1507 if (++i >= argc) usage ();
1508 displayname = argv[i];
1509 } else if (!strncmp("-queryExtensions", arg, len)) {
1510 queryExtensions = True;
1511 } else if (!strncmp("-ext", arg, len)) {
1512 if (++i >= argc) usage ();
1513 mark_extension_for_printing(argv[i]);
1518 dpy = XOpenDisplay (displayname);
1520 fprintf (stderr, "%s: unable to open display \"%s\".\n",
1521 ProgramName, XDisplayName (displayname));
1525 print_display_info (dpy);
1526 for (i = 0; i < ScreenCount (dpy); i++) {
1527 print_screen_info (dpy, i);
1530 print_marked_extensions(dpy);
1532 XCloseDisplay (dpy);