| 1 |
/* Xserver debugging functions, lifted from X11 R6.6's xdpyinfo.c. |
| 2 |
Original copyright follows: |
| 3 |
*/ |
| 4 |
|
| 5 |
/* |
| 6 |
Copyright 1988, 1998 The Open Group |
| 7 |
|
| 8 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 9 |
documentation for any purpose is hereby granted without fee, provided that |
| 10 |
the above copyright notice appear in all copies and that both that |
| 11 |
copyright notice and this permission notice appear in supporting |
| 12 |
documentation. |
| 13 |
|
| 14 |
The above copyright notice and this permission notice shall be included in |
| 15 |
all copies or substantial portions of the Software. |
| 16 |
|
| 17 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 21 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 |
|
| 24 |
Except as contained in this notice, the name of The Open Group shall not be |
| 25 |
used in advertising or otherwise to promote the sale, use or other dealings |
| 26 |
in this Software without prior written authorization from The Open Group. |
| 27 |
* |
| 28 |
* Author: Jim Fulton, MIT X Consortium |
| 29 |
*/ |
| 30 |
|
| 31 |
#include "xdvi-config.h" |
| 32 |
#include "xdvi.h" |
| 33 |
#include "xserver-info.h" |
| 34 |
|
| 35 |
#ifdef XSERVER_INFO |
| 36 |
|
| 37 |
static void |
| 38 |
print_display_info (Display *dpy) |
| 39 |
{ |
| 40 |
char dummybuf[40]; |
| 41 |
char *cp; |
| 42 |
int minkeycode, maxkeycode; |
| 43 |
int i, n; |
| 44 |
/* long req_size; */ |
| 45 |
XPixmapFormatValues *pmf; |
| 46 |
Window focuswin; |
| 47 |
int focusrevert; |
| 48 |
|
| 49 |
printf("name of display: %s\n", DisplayString (dpy)); |
| 50 |
printf("version number: %d.%d\n", |
| 51 |
ProtocolVersion (dpy), ProtocolRevision (dpy)); |
| 52 |
printf("vendor string: %s\n", ServerVendor (dpy)); |
| 53 |
printf("vendor release number: %d\n", VendorRelease (dpy)); |
| 54 |
/* apparently AIX 3 does not have XExtendedMaxRequestSize. |
| 55 |
We don't really need it either. |
| 56 |
*/ |
| 57 |
/* req_size = XExtendedMaxRequestSize (dpy); */ |
| 58 |
/* if (!req_size) req_size = XMaxRequestSize (dpy); */ |
| 59 |
/* printf("maximum request size: %ld bytes\n", req_size * 4); */ |
| 60 |
/* printf("motion buffer size: %lu\n", XDisplayMotionBufferSize (dpy)); */ |
| 61 |
|
| 62 |
switch (BitmapBitOrder (dpy)) { |
| 63 |
case LSBFirst: cp = "LSBFirst"; break; |
| 64 |
case MSBFirst: cp = "MSBFirst"; break; |
| 65 |
default: |
| 66 |
sprintf(dummybuf, "unknown order %d", BitmapBitOrder (dpy)); |
| 67 |
cp = dummybuf; |
| 68 |
break; |
| 69 |
} |
| 70 |
printf("bitmap unit: %d, bit order: %d (%s), padding: %d\n", |
| 71 |
BitmapUnit (dpy), BitmapBitOrder(dpy), cp, BitmapPad (dpy)); |
| 72 |
|
| 73 |
switch (ImageByteOrder (dpy)) { |
| 74 |
case LSBFirst: cp = "LSBFirst"; break; |
| 75 |
case MSBFirst: cp = "MSBFirst"; break; |
| 76 |
default: |
| 77 |
sprintf(dummybuf, "unknown order %d", ImageByteOrder (dpy)); |
| 78 |
cp = dummybuf; |
| 79 |
break; |
| 80 |
} |
| 81 |
printf("image byte order: %d (%s)\n", ImageByteOrder(dpy), cp); |
| 82 |
|
| 83 |
pmf = XListPixmapFormats (dpy, &n); |
| 84 |
printf("number of supported pixmap formats: %d\n", n); |
| 85 |
if (pmf) { |
| 86 |
printf("supported pixmap formats:\n"); |
| 87 |
for (i = 0; i < n; i++) { |
| 88 |
printf(" depth %d, bits_per_pixel %d, scanline_pad %d\n", |
| 89 |
pmf[i].depth, pmf[i].bits_per_pixel, pmf[i].scanline_pad); |
| 90 |
} |
| 91 |
XFree ((char *) pmf); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
/* |
| 96 |
* when we get interfaces to the PixmapFormat stuff, insert code here |
| 97 |
*/ |
| 98 |
|
| 99 |
XDisplayKeycodes (dpy, &minkeycode, &maxkeycode); |
| 100 |
printf("keycode range: minimum %d, maximum %d\n", |
| 101 |
minkeycode, maxkeycode); |
| 102 |
|
| 103 |
XGetInputFocus (dpy, &focuswin, &focusrevert); |
| 104 |
printf("focus: "); |
| 105 |
switch (focuswin) { |
| 106 |
case PointerRoot: |
| 107 |
printf("PointerRoot\n"); |
| 108 |
break; |
| 109 |
case None: |
| 110 |
printf("None\n"); |
| 111 |
break; |
| 112 |
default: |
| 113 |
printf("window 0x%lx, revert to ", focuswin); |
| 114 |
switch (focusrevert) { |
| 115 |
case RevertToParent: |
| 116 |
printf("Parent\n"); |
| 117 |
break; |
| 118 |
case RevertToNone: |
| 119 |
printf("None\n"); |
| 120 |
break; |
| 121 |
case RevertToPointerRoot: |
| 122 |
printf("PointerRoot\n"); |
| 123 |
break; |
| 124 |
default: /* should not happen */ |
| 125 |
printf("%d\n", focusrevert); |
| 126 |
break; |
| 127 |
} |
| 128 |
break; |
| 129 |
} |
| 130 |
|
| 131 |
/* print_extension_info (dpy); */ |
| 132 |
|
| 133 |
printf("default screen number: %d\n", DefaultScreen (dpy)); |
| 134 |
printf("number of screens: %d\n", ScreenCount (dpy)); |
| 135 |
} |
| 136 |
|
| 137 |
static void |
| 138 |
print_visual_info (XVisualInfo *vip) |
| 139 |
{ |
| 140 |
char errorbuf[40]; /* for sprintfing into */ |
| 141 |
char *class = NULL; /* for printing */ |
| 142 |
|
| 143 |
switch (vip->class) { |
| 144 |
case StaticGray: class = "StaticGray"; break; |
| 145 |
case GrayScale: class = "GrayScale"; break; |
| 146 |
case StaticColor: class = "StaticColor"; break; |
| 147 |
case PseudoColor: class = "PseudoColor"; break; |
| 148 |
case TrueColor: class = "TrueColor"; break; |
| 149 |
case DirectColor: class = "DirectColor"; break; |
| 150 |
default: |
| 151 |
sprintf(errorbuf, "unknown class %d", vip->class); |
| 152 |
class = errorbuf; |
| 153 |
break; |
| 154 |
} |
| 155 |
|
| 156 |
printf(" visual:\n"); |
| 157 |
printf(" visual id: 0x%lx\n", vip->visualid); |
| 158 |
printf(" class: %s\n", class); |
| 159 |
printf(" depth: %d plane%s\n", vip->depth, |
| 160 |
vip->depth == 1 ? "" : "s"); |
| 161 |
if (vip->class == TrueColor || vip->class == DirectColor) |
| 162 |
printf(" available colormap entries: %d per subfield\n", |
| 163 |
vip->colormap_size); |
| 164 |
else |
| 165 |
printf(" available colormap entries: %d\n", |
| 166 |
vip->colormap_size); |
| 167 |
printf(" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n", |
| 168 |
vip->red_mask, vip->green_mask, vip->blue_mask); |
| 169 |
printf(" significant bits in color specification: %d bits\n", |
| 170 |
vip->bits_per_rgb); |
| 171 |
} |
| 172 |
|
| 173 |
static void |
| 174 |
print_screen_info (Display *dpy, int scr) |
| 175 |
{ |
| 176 |
Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */ |
| 177 |
XVisualInfo viproto; /* fill in for getting info */ |
| 178 |
XVisualInfo *vip; /* retured info */ |
| 179 |
int nvi; /* number of elements returned */ |
| 180 |
int i; /* temp variable: iterator */ |
| 181 |
/* char eventbuf[80]; */ /* want 79 chars per line + nul */ |
| 182 |
static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED"; |
| 183 |
double xres, yres; |
| 184 |
int ndepths = 0, *depths = NULL; |
| 185 |
unsigned int width, height; |
| 186 |
|
| 187 |
|
| 188 |
/* |
| 189 |
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters. |
| 190 |
* |
| 191 |
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch)) |
| 192 |
* = N pixels / (M inch / 25.4) |
| 193 |
* = N * 25.4 pixels / M inch |
| 194 |
*/ |
| 195 |
|
| 196 |
xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / |
| 197 |
((double) DisplayWidthMM(dpy,scr))); |
| 198 |
yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) / |
| 199 |
((double) DisplayHeightMM(dpy,scr))); |
| 200 |
|
| 201 |
printf("\n"); |
| 202 |
printf("screen #%d:\n", scr); |
| 203 |
printf(" dimensions: %dx%d pixels (%dx%d millimeters)\n", |
| 204 |
DisplayWidth (dpy, scr), DisplayHeight (dpy, scr), |
| 205 |
DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr)); |
| 206 |
printf(" resolution: %dx%d dots per inch\n", |
| 207 |
(int) (xres + 0.5), (int) (yres + 0.5)); |
| 208 |
depths = XListDepths (dpy, scr, &ndepths); |
| 209 |
if (!depths) ndepths = 0; |
| 210 |
printf(" depths (%d): ", ndepths); |
| 211 |
for (i = 0; i < ndepths; i++) { |
| 212 |
printf("%d", depths[i]); |
| 213 |
if (i < ndepths - 1) { |
| 214 |
putchar (','); |
| 215 |
putchar (' '); |
| 216 |
} |
| 217 |
} |
| 218 |
putchar ('\n'); |
| 219 |
if (depths) XFree ((char *) depths); |
| 220 |
printf(" root window id: 0x%lx\n", RootWindow (dpy, scr)); |
| 221 |
printf(" depth of root window: %d plane%s\n", |
| 222 |
DisplayPlanes (dpy, scr), |
| 223 |
DisplayPlanes (dpy, scr) == 1 ? "" : "s"); |
| 224 |
printf(" number of colormaps: minimum %d, maximum %d\n", |
| 225 |
MinCmapsOfScreen(s), MaxCmapsOfScreen(s)); |
| 226 |
printf(" default colormap: 0x%lx\n", DefaultColormap (dpy, scr)); |
| 227 |
printf(" default number of colormap cells: %d\n", |
| 228 |
DisplayCells (dpy, scr)); |
| 229 |
printf(" preallocated pixels: black %lu, white %lu\n", |
| 230 |
BlackPixel (dpy, scr), WhitePixel (dpy, scr)); |
| 231 |
printf(" options: backing-store %s, save-unders %s\n", |
| 232 |
(DoesBackingStore (s) == NotUseful) ? no : |
| 233 |
((DoesBackingStore (s) == Always) ? yes : when), |
| 234 |
DoesSaveUnders (s) ? yes : no); |
| 235 |
XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535, |
| 236 |
&width, &height); |
| 237 |
if (width == 65535 && height == 65535) |
| 238 |
printf(" largest cursor: unlimited\n"); |
| 239 |
else |
| 240 |
printf(" largest cursor: %dx%d\n", width, height); |
| 241 |
printf(" current input event mask: 0x%lx\n", EventMaskOfScreen (s)); |
| 242 |
/* (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s)); */ |
| 243 |
|
| 244 |
|
| 245 |
nvi = 0; |
| 246 |
viproto.screen = scr; |
| 247 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
| 248 |
printf(" number of visuals: %d\n", nvi); |
| 249 |
printf(" default visual id: 0x%lx\n", |
| 250 |
XVisualIDFromVisual (DefaultVisual (dpy, scr))); |
| 251 |
for (i = 0; i < nvi; i++) { |
| 252 |
print_visual_info (vip+i); |
| 253 |
} |
| 254 |
if (vip) XFree ((char *) vip); |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
/* |
| 259 |
public function: when DBG_ALL is enabled, dump info on Xserver |
| 260 |
to stdout. |
| 261 |
*/ |
| 262 |
void |
| 263 |
print_xserver_info(void) |
| 264 |
{ |
| 265 |
int i; |
| 266 |
if (globals.debug & DBG_PK) { |
| 267 |
puts("========== Xserver properties info begin ==========\n"); |
| 268 |
print_display_info(DISP); |
| 269 |
for (i = 0; i < ScreenCount(DISP); i++) { |
| 270 |
print_screen_info(DISP, i); |
| 271 |
} |
| 272 |
puts("========== Xserver properties info end ==========\n"); |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
#else |
| 278 |
/* silence `empty compilation unit' warnings */ |
| 279 |
static void bar(void); static void foo(void) { bar(); } static void bar(void) { foo(); } |
| 280 |
#endif /* XSERVER_INFO */ |