Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glxdpyinfo.c 30KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. /*
  2. * $TOG: xdpyinfo.c /main/35 1998/02/09 13:57:05 kaleb $
  3. *
  4. * xdpyinfo - print information about X display connecton
  5. *
  6. *
  7. Copyright 1988, 1998 The Open Group
  8. All Rights Reserved.
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  15. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall not be
  18. used in advertising or otherwise to promote the sale, use or other dealings
  19. in this Software without prior written authorization from The Open Group.
  20. *
  21. * Author: Jim Fulton, MIT X Consortium
  22. * GLX and Overlay support added by Jamie Zawinski <jwz@jwz.org>, 11-Nov-99
  23. *
  24. * To compile:
  25. * cc -DHAVE_GLX glxdpyinfo.c -o glxdpyinfo -lGL -lX11 -lXext -lm
  26. *
  27. * Other defines to consider:
  28. * -DHAVE_XIE -DHAVE_XTEST -DHAVE_XRECORD
  29. */
  30. #define HAVE_GLX /* added by Brian Paul */
  31. #include <X11/Xlib.h>
  32. #include <X11/Xutil.h>
  33. #include <X11/Xproto.h> /* for CARD32 */
  34. #include <X11/extensions/multibuf.h>
  35. #ifdef HAVE_XIE
  36. #include <X11/extensions/XIElib.h>
  37. #endif /* HAVE_XIE */
  38. #ifdef HAVE_XTEST
  39. #include <X11/extensions/XTest.h>
  40. #endif /* HAVE_XTEST */
  41. #include <X11/extensions/sync.h>
  42. #include <X11/extensions/Xdbe.h>
  43. #ifdef HAVE_XRECORD
  44. #include <X11/extensions/record.h>
  45. #endif /* HAVE_XRECORD */
  46. #ifdef MITSHM
  47. #include <X11/extensions/XShm.h>
  48. #endif
  49. #include <X11/Xos.h>
  50. #include <stdio.h>
  51. #include <stdlib.h>
  52. #ifdef HAVE_GLX
  53. # include <GL/gl.h>
  54. # include <GL/glx.h>
  55. #endif /* HAVE_GLX */
  56. #define HAVE_OVERLAY /* jwz: no compile-time deps, so do this all the time */
  57. char *ProgramName;
  58. Bool queryExtensions = False;
  59. static int StrCmp(a, b)
  60. char **a, **b;
  61. {
  62. return strcmp(*a, *b);
  63. }
  64. static int print_event_mask (char *buf, int lastcol, int indent, long mask);
  65. #ifdef HAVE_GLX /* Added by jwz, 11-Nov-99 */
  66. static void
  67. print_glx_versions (dpy)
  68. Display *dpy;
  69. {
  70. /* Note: with Mesa 3.0, this lies: it prints the info from the
  71. client's GL library, rather than the info from the GLX server.
  72. Note also that we can't protect these calls by only doing
  73. them when the GLX extension is present, because with Mesa,
  74. the server doesn't have that extension (but the GL library
  75. works anyway.)
  76. */
  77. int scr = DefaultScreen (dpy);
  78. const char *vend, *vers;
  79. vend = glXQueryServerString (dpy, scr, GLX_VENDOR);
  80. if (!vend) return;
  81. vers = glXQueryServerString (dpy, scr, GLX_VERSION);
  82. printf ("GLX vendor: %s (%s)\n",
  83. vend, (vers ? vers : "unknown version"));
  84. }
  85. static void
  86. print_glx_visual_info (dpy, vip)
  87. Display *dpy;
  88. XVisualInfo *vip;
  89. {
  90. int status, value = False;
  91. status = glXGetConfig (dpy, vip, GLX_USE_GL, &value);
  92. if (status == GLX_NO_EXTENSION)
  93. /* dpy does not support the GLX extension. */
  94. return;
  95. if (status == GLX_BAD_VISUAL || value == False)
  96. {
  97. printf (" GLX supported: no\n");
  98. return;
  99. }
  100. else
  101. {
  102. printf (" GLX supported: yes\n");
  103. }
  104. if (!glXGetConfig (dpy, vip, GLX_LEVEL, &value) &&
  105. value != 0)
  106. printf (" GLX level: %d\n", value);
  107. if (!glXGetConfig (dpy, vip, GLX_RGBA, &value) && value)
  108. {
  109. int r=0, g=0, b=0, a=0;
  110. glXGetConfig (dpy, vip, GLX_RED_SIZE, &r);
  111. glXGetConfig (dpy, vip, GLX_GREEN_SIZE, &g);
  112. glXGetConfig (dpy, vip, GLX_BLUE_SIZE, &b);
  113. glXGetConfig (dpy, vip, GLX_ALPHA_SIZE, &a);
  114. printf (" GLX type: RGBA (%2d, %2d, %2d, %2d)\n",
  115. r, g, b, a);
  116. r=0, g=0, b=0, a=0;
  117. glXGetConfig (dpy, vip, GLX_ACCUM_RED_SIZE, &r);
  118. glXGetConfig (dpy, vip, GLX_ACCUM_GREEN_SIZE, &g);
  119. glXGetConfig (dpy, vip, GLX_ACCUM_BLUE_SIZE, &b);
  120. glXGetConfig (dpy, vip, GLX_ACCUM_ALPHA_SIZE, &a);
  121. printf (" GLX accum: RGBA (%2d, %2d, %2d, %2d)\n",
  122. r, g, b, a);
  123. }
  124. else
  125. {
  126. value = 0;
  127. glXGetConfig (dpy, vip, GLX_BUFFER_SIZE, &value);
  128. printf (" GLX type: indexed (%d)\n", value);
  129. }
  130. # if 0 /* redundant */
  131. if (!glXGetConfig (dpy, vip, GLX_X_VISUAL_TYPE_EXT, &value))
  132. printf (" GLX class: %s\n",
  133. (value == GLX_TRUE_COLOR_EXT ? "TrueColor" :
  134. value == GLX_DIRECT_COLOR_EXT ? "DirectColor" :
  135. value == GLX_PSEUDO_COLOR_EXT ? "PseudoColor" :
  136. value == GLX_STATIC_COLOR_EXT ? "StaticColor" :
  137. value == GLX_GRAY_SCALE_EXT ? "Grayscale" :
  138. value == GLX_STATIC_GRAY_EXT ? "StaticGray" : "???"));
  139. # endif
  140. # ifdef GLX_VISUAL_CAVEAT_EXT
  141. if (!glXGetConfig (dpy, vip, GLX_VISUAL_CAVEAT_EXT, &value) &&
  142. value != GLX_NONE_EXT)
  143. printf (" GLX rating: %s\n",
  144. (value == GLX_NONE_EXT ? "none" :
  145. value == GLX_SLOW_VISUAL_EXT ? "slow" :
  146. # ifdef GLX_NON_CONFORMANT_EXT
  147. value == GLX_NON_CONFORMANT_EXT ? "non-conformant" :
  148. # endif
  149. "???"));
  150. # endif
  151. if (!glXGetConfig (dpy, vip, GLX_DOUBLEBUFFER, &value))
  152. printf (" GLX double-buffer: %s\n", (value ? "yes" : "no"));
  153. if (!glXGetConfig (dpy, vip, GLX_STEREO, &value) &&
  154. value)
  155. printf (" GLX stereo: %s\n", (value ? "yes" : "no"));
  156. if (!glXGetConfig (dpy, vip, GLX_AUX_BUFFERS, &value) &&
  157. value != 0)
  158. printf (" GLX aux buffers: %d\n", value);
  159. if (!glXGetConfig (dpy, vip, GLX_DEPTH_SIZE, &value))
  160. printf (" GLX depth size: %d\n", value);
  161. if (!glXGetConfig (dpy, vip, GLX_STENCIL_SIZE, &value) &&
  162. value != 0)
  163. printf (" GLX stencil size: %d\n", value);
  164. # ifdef GLX_SAMPLE_BUFFERS_SGIS
  165. if (!glXGetConfig (dpy, vip, GLX_SAMPLE_BUFFERS_SGIS, &value) &&
  166. value != 0)
  167. {
  168. int bufs = value;
  169. if (!glXGetConfig (dpy, vip, GLX_SAMPLES_SGIS, &value))
  170. printf (" GLX multisamplers: %d (%d)\n", bufs, value);
  171. }
  172. # endif
  173. if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_TYPE_EXT, &value) &&
  174. value != GLX_NONE_EXT)
  175. {
  176. if (value == GLX_NONE_EXT)
  177. printf (" GLX transparency: none\n");
  178. else if (value == GLX_TRANSPARENT_INDEX_EXT)
  179. {
  180. if (!glXGetConfig (dpy, vip, GLX_TRANSPARENT_INDEX_VALUE_EXT,&value))
  181. printf (" GLX transparency: indexed (%d)\n", value);
  182. }
  183. else if (value == GLX_TRANSPARENT_RGB_EXT)
  184. {
  185. int r=0, g=0, b=0, a=0;
  186. glXGetConfig (dpy, vip, GLX_TRANSPARENT_RED_VALUE_EXT, &r);
  187. glXGetConfig (dpy, vip, GLX_TRANSPARENT_GREEN_VALUE_EXT, &g);
  188. glXGetConfig (dpy, vip, GLX_TRANSPARENT_BLUE_VALUE_EXT, &b);
  189. glXGetConfig (dpy, vip, GLX_TRANSPARENT_ALPHA_VALUE_EXT, &a);
  190. printf (" GLX transparency: RGBA (%2d, %2d, %2d, %2d)\n",
  191. r, g, b, a);
  192. }
  193. }
  194. }
  195. #endif /* HAVE_GLX */
  196. #ifdef HAVE_OVERLAY /* Added by jwz, 11-Nov-99 */
  197. /* If the server's root window contains a SERVER_OVERLAY_VISUALS property,
  198. then that identifies the visuals which correspond to the video hardware's
  199. overlay planes. Windows created in these kinds of visuals may have
  200. transparent pixels that let other layers shine through.
  201. This might not be an X Consortium standard, but it turns out that
  202. SGI, HP, DEC, and IBM all use this same mechanism. So that's close
  203. enough for me.
  204. Documentation on the SERVER_OVERLAY_VISUALS property can be found at:
  205. http://www.hp.com/xwindow/sharedInfo/Whitepapers/Visuals/server_overlay_visuals.html
  206. */
  207. struct overlay
  208. {
  209. CARD32 visual_id;
  210. CARD32 transparency; /* 0: none; 1: pixel; 2: mask */
  211. CARD32 value; /* the transparent pixel */
  212. CARD32 layer; /* -1: underlay; 0: normal; 1: popup; 2: overlay */
  213. };
  214. struct overlay_list
  215. {
  216. int count;
  217. struct overlay *list;
  218. };
  219. static struct overlay_list *overlays = 0;
  220. static void
  221. find_overlay_info (dpy)
  222. Display *dpy;
  223. {
  224. int screen;
  225. Atom OVERLAY = XInternAtom (dpy, "SERVER_OVERLAY_VISUALS", False);
  226. overlays = (struct overlay_list *) calloc (sizeof (struct overlay_list),
  227. ScreenCount (dpy));
  228. for (screen = 0; screen < ScreenCount (dpy); screen++)
  229. {
  230. Window window = RootWindow (dpy, screen);
  231. Atom actual_type;
  232. int actual_format;
  233. unsigned long nitems, bytes_after;
  234. struct overlay *data = 0;
  235. int result = XGetWindowProperty (dpy, window, OVERLAY,
  236. 0, (65536 / sizeof (long)), False,
  237. OVERLAY, &actual_type, &actual_format,
  238. &nitems, &bytes_after,
  239. (unsigned char **) &data);
  240. if (result == Success &&
  241. actual_type == OVERLAY &&
  242. actual_format == 32 &&
  243. nitems > 0)
  244. {
  245. overlays[screen].count = (nitems /
  246. (sizeof(struct overlay) / sizeof(CARD32)));
  247. overlays[screen].list = data;
  248. }
  249. else if (data)
  250. XFree((char *) data);
  251. }
  252. }
  253. static void
  254. print_overlay_visual_info (vip)
  255. XVisualInfo *vip;
  256. {
  257. int i;
  258. int vis = vip->visualid;
  259. int scr = vip->screen;
  260. if (!overlays) return;
  261. for (i = 0; i < overlays[scr].count; i++)
  262. if (vis == overlays[scr].list[i].visual_id)
  263. {
  264. struct overlay *ov = &overlays[scr].list[i];
  265. printf (" Overlay info: layer %ld (%s), ",
  266. (long) ov->layer,
  267. (ov->layer == -1 ? "underlay" :
  268. ov->layer == 0 ? "normal" :
  269. ov->layer == 1 ? "popup" :
  270. ov->layer == 2 ? "overlay" : "???"));
  271. if (ov->transparency == 1)
  272. printf ("transparent pixel %lu\n", (unsigned long) ov->value);
  273. else if (ov->transparency == 2)
  274. printf ("transparent mask 0x%x\n", (unsigned) ov->value);
  275. else
  276. printf ("opaque\n");
  277. }
  278. }
  279. #endif /* HAVE_OVERLAY */
  280. static void
  281. print_extension_info (dpy)
  282. Display *dpy;
  283. {
  284. int n = 0;
  285. char **extlist = XListExtensions (dpy, &n);
  286. printf ("number of extensions: %d\n", n);
  287. if (extlist) {
  288. register int i;
  289. int opcode, event, error;
  290. qsort(extlist, n, sizeof(char *), StrCmp);
  291. for (i = 0; i < n; i++) {
  292. if (!queryExtensions) {
  293. printf (" %s\n", extlist[i]);
  294. continue;
  295. }
  296. XQueryExtension(dpy, extlist[i], &opcode, &event, &error);
  297. printf (" %s (opcode: %d", extlist[i], opcode);
  298. if (event)
  299. printf (", base event: %d", event);
  300. if (error)
  301. printf (", base error: %d", error);
  302. printf(")\n");
  303. }
  304. /* do not free, Xlib can depend on contents being unaltered */
  305. /* XFreeExtensionList (extlist); */
  306. }
  307. }
  308. static void
  309. print_display_info (dpy)
  310. Display *dpy;
  311. {
  312. char dummybuf[40];
  313. char *cp;
  314. int minkeycode, maxkeycode;
  315. int i, n;
  316. long req_size;
  317. XPixmapFormatValues *pmf;
  318. Window focuswin;
  319. int focusrevert;
  320. printf ("name of display: %s\n", DisplayString (dpy));
  321. printf ("version number: %d.%d\n",
  322. ProtocolVersion (dpy), ProtocolRevision (dpy));
  323. printf ("vendor string: %s\n", ServerVendor (dpy));
  324. printf ("vendor release number: %d\n", VendorRelease (dpy));
  325. #ifdef HAVE_GLX
  326. print_glx_versions (dpy);
  327. #endif /* HAVE_GLX */
  328. req_size = XExtendedMaxRequestSize (dpy);
  329. if (!req_size) req_size = XMaxRequestSize (dpy);
  330. printf ("maximum request size: %ld bytes\n", req_size * 4);
  331. printf ("motion buffer size: %d\n", (int) XDisplayMotionBufferSize(dpy));
  332. switch (BitmapBitOrder (dpy)) {
  333. case LSBFirst: cp = "LSBFirst"; break;
  334. case MSBFirst: cp = "MSBFirst"; break;
  335. default:
  336. sprintf (dummybuf, "unknown order %d", BitmapBitOrder (dpy));
  337. cp = dummybuf;
  338. break;
  339. }
  340. printf ("bitmap unit, bit order, padding: %d, %s, %d\n",
  341. BitmapUnit (dpy), cp, BitmapPad (dpy));
  342. switch (ImageByteOrder (dpy)) {
  343. case LSBFirst: cp = "LSBFirst"; break;
  344. case MSBFirst: cp = "MSBFirst"; break;
  345. default:
  346. sprintf (dummybuf, "unknown order %d", ImageByteOrder (dpy));
  347. cp = dummybuf;
  348. break;
  349. }
  350. printf ("image byte order: %s\n", cp);
  351. pmf = XListPixmapFormats (dpy, &n);
  352. printf ("number of supported pixmap formats: %d\n", n);
  353. if (pmf) {
  354. printf ("supported pixmap formats:\n");
  355. for (i = 0; i < n; i++) {
  356. printf (" depth %d, bits_per_pixel %d, scanline_pad %d\n",
  357. pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad);
  358. }
  359. XFree ((char *) pmf);
  360. }
  361. /*
  362. * when we get interfaces to the PixmapFormat stuff, insert code here
  363. */
  364. XDisplayKeycodes (dpy, &minkeycode, &maxkeycode);
  365. printf ("keycode range: minimum %d, maximum %d\n",
  366. minkeycode, maxkeycode);
  367. XGetInputFocus (dpy, &focuswin, &focusrevert);
  368. printf ("focus: ");
  369. switch (focuswin) {
  370. case PointerRoot:
  371. printf ("PointerRoot\n");
  372. break;
  373. case None:
  374. printf ("None\n");
  375. break;
  376. default:
  377. printf("window 0x%lx, revert to ", focuswin);
  378. switch (focusrevert) {
  379. case RevertToParent:
  380. printf ("Parent\n");
  381. break;
  382. case RevertToNone:
  383. printf ("None\n");
  384. break;
  385. case RevertToPointerRoot:
  386. printf ("PointerRoot\n");
  387. break;
  388. default: /* should not happen */
  389. printf ("%d\n", focusrevert);
  390. break;
  391. }
  392. break;
  393. }
  394. print_extension_info (dpy);
  395. printf ("default screen number: %d\n", DefaultScreen (dpy));
  396. printf ("number of screens: %d\n", ScreenCount (dpy));
  397. }
  398. static void
  399. print_visual_info (vip)
  400. XVisualInfo *vip;
  401. {
  402. char errorbuf[40]; /* for sprintfing into */
  403. char *class = NULL; /* for printing */
  404. switch (vip->class) {
  405. case StaticGray: class = "StaticGray"; break;
  406. case GrayScale: class = "GrayScale"; break;
  407. case StaticColor: class = "StaticColor"; break;
  408. case PseudoColor: class = "PseudoColor"; break;
  409. case TrueColor: class = "TrueColor"; break;
  410. case DirectColor: class = "DirectColor"; break;
  411. default:
  412. sprintf (errorbuf, "unknown class %d", vip->class);
  413. class = errorbuf;
  414. break;
  415. }
  416. printf (" visual:\n");
  417. printf (" visual id: 0x%lx\n", vip->visualid);
  418. printf (" class: %s\n", class);
  419. printf (" depth: %d plane%s\n", vip->depth,
  420. vip->depth == 1 ? "" : "s");
  421. if (vip->class == TrueColor || vip->class == DirectColor)
  422. printf (" available colormap entries: %d per subfield\n",
  423. vip->colormap_size);
  424. else
  425. printf (" available colormap entries: %d\n",
  426. vip->colormap_size);
  427. printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n",
  428. vip->red_mask, vip->green_mask, vip->blue_mask);
  429. printf (" significant bits in color specification: %d bits\n",
  430. vip->bits_per_rgb);
  431. }
  432. static void
  433. print_screen_info (dpy, scr)
  434. Display *dpy;
  435. int scr;
  436. {
  437. Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */
  438. XVisualInfo viproto; /* fill in for getting info */
  439. XVisualInfo *vip; /* retured info */
  440. int nvi; /* number of elements returned */
  441. int i; /* temp variable: iterator */
  442. char eventbuf[80]; /* want 79 chars per line + nul */
  443. static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED";
  444. double xres, yres;
  445. int ndepths = 0, *depths = NULL;
  446. unsigned int width, height;
  447. /*
  448. * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
  449. *
  450. * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
  451. * = N pixels / (M inch / 25.4)
  452. * = N * 25.4 pixels / M inch
  453. */
  454. xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
  455. ((double) DisplayWidthMM(dpy,scr)));
  456. yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) /
  457. ((double) DisplayHeightMM(dpy,scr)));
  458. printf ("\n");
  459. printf ("screen #%d:\n", scr);
  460. printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n",
  461. DisplayWidth (dpy, scr), DisplayHeight (dpy, scr),
  462. DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr));
  463. printf (" resolution: %dx%d dots per inch\n",
  464. (int) (xres + 0.5), (int) (yres + 0.5));
  465. depths = XListDepths (dpy, scr, &ndepths);
  466. if (!depths) ndepths = 0;
  467. printf (" depths (%d): ", ndepths);
  468. for (i = 0; i < ndepths; i++) {
  469. printf ("%d", depths[i]);
  470. if (i < ndepths - 1) {
  471. putchar (',');
  472. putchar (' ');
  473. }
  474. }
  475. putchar ('\n');
  476. if (depths) XFree ((char *) depths);
  477. printf (" root window id: 0x%lx\n", RootWindow (dpy, scr));
  478. printf (" depth of root window: %d plane%s\n",
  479. DisplayPlanes (dpy, scr),
  480. DisplayPlanes (dpy, scr) == 1 ? "" : "s");
  481. printf (" number of colormaps: minimum %d, maximum %d\n",
  482. MinCmapsOfScreen(s), MaxCmapsOfScreen(s));
  483. printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr));
  484. printf (" default number of colormap cells: %d\n",
  485. DisplayCells (dpy, scr));
  486. printf (" preallocated pixels: black %ld, white %ld\n",
  487. BlackPixel (dpy, scr), WhitePixel (dpy, scr));
  488. printf (" options: backing-store %s, save-unders %s\n",
  489. (DoesBackingStore (s) == NotUseful) ? no :
  490. ((DoesBackingStore (s) == Always) ? yes : when),
  491. DoesSaveUnders (s) ? yes : no);
  492. XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535,
  493. &width, &height);
  494. if (width == 65535 && height == 65535)
  495. printf (" largest cursor: unlimited\n");
  496. else
  497. printf (" largest cursor: %dx%d\n", width, height);
  498. printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s));
  499. (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s));
  500. nvi = 0;
  501. viproto.screen = scr;
  502. vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi);
  503. printf (" number of visuals: %d\n", nvi);
  504. printf (" default visual id: 0x%lx\n",
  505. XVisualIDFromVisual (DefaultVisual (dpy, scr)));
  506. for (i = 0; i < nvi; i++) {
  507. print_visual_info (vip+i);
  508. #ifdef HAVE_OVERLAY
  509. print_overlay_visual_info (vip+i);
  510. #endif /* HAVE_OVERLAY */
  511. #ifdef HAVE_GLX
  512. print_glx_visual_info (dpy, vip+i);
  513. #endif /* HAVE_GLX */
  514. }
  515. if (vip) XFree ((char *) vip);
  516. }
  517. /*
  518. * The following routine prints out an event mask, wrapping events at nice
  519. * boundaries.
  520. */
  521. #define MASK_NAME_WIDTH 25
  522. static struct _event_table {
  523. char *name;
  524. long value;
  525. } event_table[] = {
  526. { "KeyPressMask ", KeyPressMask },
  527. { "KeyReleaseMask ", KeyReleaseMask },
  528. { "ButtonPressMask ", ButtonPressMask },
  529. { "ButtonReleaseMask ", ButtonReleaseMask },
  530. { "EnterWindowMask ", EnterWindowMask },
  531. { "LeaveWindowMask ", LeaveWindowMask },
  532. { "PointerMotionMask ", PointerMotionMask },
  533. { "PointerMotionHintMask ", PointerMotionHintMask },
  534. { "Button1MotionMask ", Button1MotionMask },
  535. { "Button2MotionMask ", Button2MotionMask },
  536. { "Button3MotionMask ", Button3MotionMask },
  537. { "Button4MotionMask ", Button4MotionMask },
  538. { "Button5MotionMask ", Button5MotionMask },
  539. { "ButtonMotionMask ", ButtonMotionMask },
  540. { "KeymapStateMask ", KeymapStateMask },
  541. { "ExposureMask ", ExposureMask },
  542. { "VisibilityChangeMask ", VisibilityChangeMask },
  543. { "StructureNotifyMask ", StructureNotifyMask },
  544. { "ResizeRedirectMask ", ResizeRedirectMask },
  545. { "SubstructureNotifyMask ", SubstructureNotifyMask },
  546. { "SubstructureRedirectMask ", SubstructureRedirectMask },
  547. { "FocusChangeMask ", FocusChangeMask },
  548. { "PropertyChangeMask ", PropertyChangeMask },
  549. { "ColormapChangeMask ", ColormapChangeMask },
  550. { "OwnerGrabButtonMask ", OwnerGrabButtonMask },
  551. { NULL, 0 }};
  552. static int print_event_mask (char *buf, int lastcol, int indent, long mask)
  553. {
  554. struct _event_table *etp;
  555. int len;
  556. int bitsfound = 0;
  557. buf[0] = buf[lastcol] = '\0'; /* just in case */
  558. #define INDENT() { register int i; len = indent; \
  559. for (i = 0; i < indent; i++) buf[i] = ' '; }
  560. INDENT ();
  561. for (etp = event_table; etp->name; etp++) {
  562. if (mask & etp->value) {
  563. if (len + MASK_NAME_WIDTH > lastcol) {
  564. puts (buf);
  565. INDENT ();
  566. }
  567. strcpy (buf+len, etp->name);
  568. len += MASK_NAME_WIDTH;
  569. bitsfound++;
  570. }
  571. }
  572. if (bitsfound) puts (buf);
  573. #undef INDENT
  574. return (bitsfound);
  575. }
  576. static void
  577. print_standard_extension_info(dpy, extname, majorrev, minorrev)
  578. Display *dpy;
  579. char *extname;
  580. int majorrev, minorrev;
  581. {
  582. int opcode, event, error;
  583. printf("%s version %d.%d ", extname, majorrev, minorrev);
  584. XQueryExtension(dpy, extname, &opcode, &event, &error);
  585. printf ("opcode: %d", opcode);
  586. if (event)
  587. printf (", base event: %d", event);
  588. if (error)
  589. printf (", base error: %d", error);
  590. printf("\n");
  591. }
  592. static int
  593. print_multibuf_info(dpy, extname)
  594. Display *dpy;
  595. char *extname;
  596. {
  597. int i, j; /* temp variable: iterator */
  598. int nmono, nstereo; /* count */
  599. XmbufBufferInfo *mono_info = NULL, *stereo_info = NULL; /* arrays */
  600. static char *fmt =
  601. " visual id, max buffers, depth: 0x%lx, %d, %d\n";
  602. int scr = 0;
  603. int majorrev, minorrev;
  604. if (!XmbufGetVersion(dpy, &majorrev, &minorrev))
  605. return 0;
  606. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  607. for (i = 0; i < ScreenCount (dpy); i++)
  608. {
  609. if (!XmbufGetScreenInfo (dpy, RootWindow(dpy, scr), &nmono, &mono_info,
  610. &nstereo, &stereo_info)) {
  611. fprintf (stderr,
  612. "%s: unable to get multibuffer info for screen %d\n",
  613. ProgramName, scr);
  614. } else {
  615. printf (" screen %d number of mono multibuffer types: %d\n", i, nmono);
  616. for (j = 0; j < nmono; j++) {
  617. printf (fmt, mono_info[j].visualid, mono_info[j].max_buffers,
  618. mono_info[j].depth);
  619. }
  620. printf (" number of stereo multibuffer types: %d\n", nstereo);
  621. for (j = 0; j < nstereo; j++) {
  622. printf (fmt, stereo_info[j].visualid,
  623. stereo_info[j].max_buffers, stereo_info[j].depth);
  624. }
  625. if (mono_info) XFree ((char *) mono_info);
  626. if (stereo_info) XFree ((char *) stereo_info);
  627. }
  628. }
  629. return 1;
  630. } /* end print_multibuf_info */
  631. /* XIE stuff */
  632. #ifdef HAVE_XIE
  633. char *subset_names[] = { NULL, "FULL", "DIS" };
  634. char *align_names[] = { NULL, "Alignable", "Arbitrary" };
  635. char *group_names[] = { /* 0 */ "Default",
  636. /* 2 */ "ColorAlloc",
  637. /* 4 */ "Constrain",
  638. /* 6 */ "ConvertFromRGB",
  639. /* 8 */ "ConvertToRGB",
  640. /* 10 */ "Convolve",
  641. /* 12 */ "Decode",
  642. /* 14 */ "Dither",
  643. /* 16 */ "Encode",
  644. /* 18 */ "Gamut",
  645. /* 20 */ "Geometry",
  646. /* 22 */ "Histogram",
  647. /* 24 */ "WhiteAdjust"
  648. };
  649. int
  650. print_xie_info(dpy, extname)
  651. Display *dpy;
  652. char *extname;
  653. {
  654. XieExtensionInfo *xieInfo;
  655. int i;
  656. int ntechs;
  657. XieTechnique *techs;
  658. XieTechniqueGroup prevGroup;
  659. if (!XieInitialize(dpy, &xieInfo ))
  660. return 0;
  661. print_standard_extension_info(dpy, extname,
  662. xieInfo->server_major_rev, xieInfo->server_minor_rev);
  663. printf(" service class: %s\n", subset_names[xieInfo->service_class]);
  664. printf(" alignment: %s\n", align_names[xieInfo->alignment]);
  665. printf(" uncnst_mantissa: %d\n", xieInfo->uncnst_mantissa);
  666. printf(" uncnst_min_exp: %d\n", xieInfo->uncnst_min_exp);
  667. printf(" uncnst_max_exp: %d\n", xieInfo->uncnst_max_exp);
  668. printf(" cnst_levels:");
  669. for (i = 0; i < xieInfo->n_cnst_levels; i++)
  670. printf(" %d", xieInfo->cnst_levels[i]);
  671. printf("\n");
  672. if (!XieQueryTechniques(dpy, xieValAll, &ntechs, &techs))
  673. return 1;
  674. prevGroup = -1;
  675. for (i = 0; i < ntechs; i++)
  676. {
  677. if (techs[i].group != prevGroup)
  678. {
  679. printf(" technique group: %s\n", group_names[techs[i].group >> 1]);
  680. prevGroup = techs[i].group;
  681. }
  682. printf(" %s\tspeed: %d needs_param: %s number: %d\n",
  683. techs[i].name,
  684. techs[i].speed, (techs[i].needs_param ? "True " : "False"),
  685. techs[i].number);
  686. }
  687. return 1;
  688. } /* end print_xie_info */
  689. #endif /* HAVE_XIE */
  690. #ifdef HAVE_XTEST
  691. int
  692. print_xtest_info(dpy, extname)
  693. Display *dpy;
  694. char *extname;
  695. {
  696. int majorrev, minorrev, foo;
  697. if (!XTestQueryExtension(dpy, &foo, &foo, &majorrev, &minorrev))
  698. return 0;
  699. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  700. return 1;
  701. }
  702. #endif /* HAVE_XTEST */
  703. static int
  704. print_sync_info(dpy, extname)
  705. Display *dpy;
  706. char *extname;
  707. {
  708. int majorrev, minorrev;
  709. XSyncSystemCounter *syscounters;
  710. int ncounters, i;
  711. if (!XSyncInitialize(dpy, &majorrev, &minorrev))
  712. return 0;
  713. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  714. syscounters = XSyncListSystemCounters(dpy, &ncounters);
  715. printf(" system counters: %d\n", ncounters);
  716. for (i = 0; i < ncounters; i++)
  717. {
  718. printf(" %s id: 0x%08x resolution_lo: %d resolution_hi: %d\n",
  719. syscounters[i].name, (int) syscounters[i].counter,
  720. (int) XSyncValueLow32(syscounters[i].resolution),
  721. (int) XSyncValueHigh32(syscounters[i].resolution));
  722. }
  723. XSyncFreeSystemCounterList(syscounters);
  724. return 1;
  725. }
  726. static int
  727. print_shape_info(dpy, extname)
  728. Display *dpy;
  729. char *extname;
  730. {
  731. int majorrev, minorrev;
  732. if (!XShapeQueryVersion(dpy, &majorrev, &minorrev))
  733. return 0;
  734. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  735. return 1;
  736. }
  737. #ifdef MITSHM
  738. static int
  739. print_mitshm_info(dpy, extname)
  740. Display *dpy;
  741. char *extname;
  742. {
  743. int majorrev, minorrev;
  744. Bool sharedPixmaps;
  745. if (!XShmQueryVersion(dpy, &majorrev, &minorrev, &sharedPixmaps))
  746. return 0;
  747. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  748. printf(" shared pixmaps: ");
  749. if (sharedPixmaps)
  750. {
  751. int format = XShmPixmapFormat(dpy);
  752. printf("yes, format: %d\n", format);
  753. }
  754. else
  755. {
  756. printf("no\n");
  757. }
  758. return 1;
  759. }
  760. #endif /* MITSHM */
  761. static int
  762. print_dbe_info(dpy, extname)
  763. Display *dpy;
  764. char *extname;
  765. {
  766. int majorrev, minorrev;
  767. XdbeScreenVisualInfo *svi;
  768. int numscreens = 0;
  769. int iscrn, ivis;
  770. if (!XdbeQueryExtension(dpy, &majorrev, &minorrev))
  771. return 0;
  772. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  773. svi = XdbeGetVisualInfo(dpy, (Drawable *)NULL, &numscreens);
  774. for (iscrn = 0; iscrn < numscreens; iscrn++)
  775. {
  776. printf(" Double-buffered visuals on screen %d\n", iscrn);
  777. for (ivis = 0; ivis < svi[iscrn].count; ivis++)
  778. {
  779. printf(" visual id 0x%lx depth %d perflevel %d\n",
  780. svi[iscrn].visinfo[ivis].visual,
  781. svi[iscrn].visinfo[ivis].depth,
  782. svi[iscrn].visinfo[ivis].perflevel);
  783. }
  784. }
  785. XdbeFreeVisualInfo(svi);
  786. return 1;
  787. }
  788. #ifdef HAVE_XRECORD
  789. static int
  790. print_record_info(dpy, extname)
  791. Display *dpy;
  792. char *extname;
  793. {
  794. int majorrev, minorrev;
  795. if (!XRecordQueryVersion(dpy, &majorrev, &minorrev))
  796. return 0;
  797. print_standard_extension_info(dpy, extname, majorrev, minorrev);
  798. return 1;
  799. }
  800. #endif /* HAVE_XRECORD */
  801. /* utilities to manage the list of recognized extensions */
  802. typedef int (*ExtensionPrintFunc)(
  803. #if NeedFunctionPrototypes
  804. Display *, char *
  805. #endif
  806. );
  807. typedef struct {
  808. char *extname;
  809. ExtensionPrintFunc printfunc;
  810. Bool printit;
  811. } ExtensionPrintInfo;
  812. ExtensionPrintInfo known_extensions[] =
  813. {
  814. #ifdef MITSHM
  815. {"MIT-SHM", print_mitshm_info, False},
  816. #endif /* MITSHM */
  817. {MULTIBUFFER_PROTOCOL_NAME, print_multibuf_info, False},
  818. {"SHAPE", print_shape_info, False},
  819. {SYNC_NAME, print_sync_info, False},
  820. #ifdef HAVE_XIE
  821. {xieExtName, print_xie_info, False},
  822. #endif /* HAVE_XIE */
  823. #ifdef HAVE_XTEST
  824. {XTestExtensionName, print_xtest_info, False},
  825. #endif /* HAVE_XTEST */
  826. {"DOUBLE-BUFFER", print_dbe_info, False},
  827. #ifdef HAVE_XRECORD
  828. {"RECORD", print_record_info, False}
  829. #endif /* HAVE_XRECORD */
  830. /* add new extensions here */
  831. /* wish list: PEX XKB LBX */
  832. };
  833. int num_known_extensions = sizeof known_extensions / sizeof known_extensions[0];
  834. static void
  835. print_known_extensions(f)
  836. FILE *f;
  837. {
  838. int i;
  839. for (i = 0; i < num_known_extensions; i++)
  840. {
  841. fprintf(f, "%s ", known_extensions[i].extname);
  842. }
  843. }
  844. static void
  845. mark_extension_for_printing(extname)
  846. char *extname;
  847. {
  848. int i;
  849. if (strcmp(extname, "all") == 0)
  850. {
  851. for (i = 0; i < num_known_extensions; i++)
  852. known_extensions[i].printit = True;
  853. }
  854. else
  855. {
  856. for (i = 0; i < num_known_extensions; i++)
  857. {
  858. if (strcmp(extname, known_extensions[i].extname) == 0)
  859. {
  860. known_extensions[i].printit = True;
  861. return;
  862. }
  863. }
  864. printf("%s extension not supported by %s\n", extname, ProgramName);
  865. }
  866. }
  867. static void
  868. print_marked_extensions(dpy)
  869. Display *dpy;
  870. {
  871. int i;
  872. for (i = 0; i < num_known_extensions; i++)
  873. {
  874. if (known_extensions[i].printit)
  875. {
  876. printf("\n");
  877. if (! (*known_extensions[i].printfunc)(dpy,
  878. known_extensions[i].extname))
  879. {
  880. printf("%s extension not supported by server\n",
  881. known_extensions[i].extname);
  882. }
  883. }
  884. }
  885. }
  886. static void usage ()
  887. {
  888. fprintf (stderr, "usage: %s [options]\n", ProgramName);
  889. fprintf (stderr, "-display displayname\tserver to query\n");
  890. fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
  891. fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
  892. fprintf (stderr, "-ext extension-name\tprint detailed info for extension-name if one of:\n ");
  893. print_known_extensions(stderr);
  894. fprintf (stderr, "\n");
  895. exit (1);
  896. }
  897. int main (argc, argv)
  898. int argc;
  899. char *argv[];
  900. {
  901. Display *dpy; /* X connection */
  902. char *displayname = NULL; /* server to contact */
  903. int i; /* temp variable: iterator */
  904. ProgramName = argv[0];
  905. for (i = 1; i < argc; i++) {
  906. char *arg = argv[i];
  907. int len = strlen(arg);
  908. if (!strncmp("-display", arg, len)) {
  909. if (++i >= argc) usage ();
  910. displayname = argv[i];
  911. } else if (!strncmp("-queryExtensions", arg, len)) {
  912. queryExtensions = True;
  913. } else if (!strncmp("-ext", arg, len)) {
  914. if (++i >= argc) usage ();
  915. mark_extension_for_printing(argv[i]);
  916. } else
  917. usage ();
  918. }
  919. dpy = XOpenDisplay (displayname);
  920. if (!dpy) {
  921. fprintf (stderr, "%s: unable to open display \"%s\".\n",
  922. ProgramName, XDisplayName (displayname));
  923. exit (1);
  924. }
  925. #ifdef HAVE_OVERLAY
  926. find_overlay_info (dpy);
  927. #endif /* HAVE_OVERLAY */
  928. print_display_info (dpy);
  929. for (i = 0; i < ScreenCount (dpy); i++) {
  930. print_screen_info (dpy, i);
  931. }
  932. print_marked_extensions(dpy);
  933. XCloseDisplay (dpy);
  934. exit (0);
  935. }