Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.42 diff -u -2 -0 -r1.42 ChangeLog --- a/xc/ChangeLog 24 May 2004 19:06:57 -0000 1.42 +++ b/xc/ChangeLog 25 May 2004 01:57:45 -0000 @@ -1,20 +1,24 @@ +2004-05-24 Roland Mainz + * xc/programs/xdpyinfo/xdpyinfo.c + BugZilla #672: xdpyinfo should print information about print screens + 2004-05-24 Egbert Eich * Imakefile: * Makefile: * config/cf/Imake.rules: * config/cf/Imake.tmpl: * config/cf/Library.tmpl: * config/cf/X11.tmpl: * lib/SM/sm_genid.c: * lib/SM/sm_manager.c: * lib/X11/xlibi18n/Xi18nLib.conf: * lib/Xrandr/Imakefile: * lib/Xrandr/Xrandrint.h: * lib/Xtst/XRecord.c: * lib/dps/Imakefile: * lib/font/Speedo/spfont.c: * lib/font/Type1/arith.c: * lib/font/Type1/curves.c: * lib/font/Type1/hints.c: * lib/font/Type1/objects.c: Index: xc/programs/xdpyinfo/xdpyinfo.c =================================================================== RCS file: /cvs/xorg/xc/programs/xdpyinfo/xdpyinfo.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 xdpyinfo.c --- a/xc/programs/xdpyinfo/xdpyinfo.c 16 May 2004 21:52:44 -0000 1.3 +++ b/xc/programs/xdpyinfo/xdpyinfo.c 25 May 2004 01:57:55 -0000 @@ -289,111 +289,150 @@ break; } printf (" visual:\n"); printf (" visual id: 0x%lx\n", vip->visualid); printf (" class: %s\n", class); printf (" depth: %d plane%s\n", vip->depth, vip->depth == 1 ? "" : "s"); if (vip->class == TrueColor || vip->class == DirectColor) printf (" available colormap entries: %d per subfield\n", vip->colormap_size); else printf (" available colormap entries: %d\n", vip->colormap_size); printf (" red, green, blue masks: 0x%lx, 0x%lx, 0x%lx\n", vip->red_mask, vip->green_mask, vip->blue_mask); printf (" significant bits in color specification: %d bits\n", vip->bits_per_rgb); } +static +Bool hasExtension(Display *dpy, char *extname) +{ + int num_extensions, + i; + char **extensions; + extensions = XListExtensions(dpy, &num_extensions); + for (i = 0; i < num_extensions && + (strcmp(extensions[i], extname) != 0); i++); + XFreeExtensionList(extensions); + return i != num_extensions; +} + + static void print_screen_info(Display *dpy, int scr) { Screen *s = ScreenOfDisplay (dpy, scr); /* opaque structure */ XVisualInfo viproto; /* fill in for getting info */ XVisualInfo *vip; /* retured info */ int nvi; /* number of elements returned */ int i; /* temp variable: iterator */ char eventbuf[80]; /* want 79 chars per line + nul */ static char *yes = "YES", *no = "NO", *when = "WHEN MAPPED"; double xres, yres; int ndepths = 0, *depths = NULL; unsigned int width, height; - + Bool isPrintScreen = False; /* * there are 2.54 centimeters to an inch; so there are 25.4 millimeters. * * dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch)) * = N pixels / (M inch / 25.4) * = N * 25.4 pixels / M inch */ xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / ((double) DisplayWidthMM(dpy,scr))); yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) / ((double) DisplayHeightMM(dpy,scr))); printf ("\n"); printf ("screen #%d:\n", scr); - printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n", - DisplayWidth (dpy, scr), DisplayHeight (dpy, scr), - DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr)); - printf (" resolution: %dx%d dots per inch\n", - (int) (xres + 0.5), (int) (yres + 0.5)); + + /* Check whether this is a screen of a print DDX */ + if (hasExtension(dpy, XP_PRINTNAME)) { + Screen **pscreens; + int pscrcount; + + pscreens = XpQueryScreens(dpy, &pscrcount); + for( i = 0 ; (i < pscrcount) && pscreens ; i++ ) { + if (scr == (int)XScreenNumberOfScreen(pscreens[i])) { + isPrintScreen = True; + break; + } + } + XFree(pscreens); + } + printf (" print screen: %s\n", isPrintScreen?"yes":"no"); + + if (isPrintScreen) { + /* Print resolution is set on a per-printer basis (per-document + * or per-page), the screen itself has no "default" resolution */ + printf (" maximum dimensions: %dx%d pixels\n", + XDisplayWidth (dpy, scr), XDisplayHeight (dpy, scr)); + } + else + { + printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n", + XDisplayWidth (dpy, scr), XDisplayHeight (dpy, scr), + XDisplayWidthMM(dpy, scr), XDisplayHeightMM (dpy, scr)); + printf (" resolution: %dx%d dots per inch\n", + (int) (xres + 0.5), (int) (yres + 0.5)); + } depths = XListDepths (dpy, scr, &ndepths); if (!depths) ndepths = 0; printf (" depths (%d): ", ndepths); for (i = 0; i < ndepths; i++) { printf ("%d", depths[i]); if (i < ndepths - 1) { putchar (','); putchar (' '); } } putchar ('\n'); if (depths) XFree ((char *) depths); printf (" root window id: 0x%lx\n", RootWindow (dpy, scr)); printf (" depth of root window: %d plane%s\n", DisplayPlanes (dpy, scr), DisplayPlanes (dpy, scr) == 1 ? "" : "s"); printf (" number of colormaps: minimum %d, maximum %d\n", MinCmapsOfScreen(s), MaxCmapsOfScreen(s)); printf (" default colormap: 0x%lx\n", DefaultColormap (dpy, scr)); printf (" default number of colormap cells: %d\n", DisplayCells (dpy, scr)); printf (" preallocated pixels: black %ld, white %ld\n", BlackPixel (dpy, scr), WhitePixel (dpy, scr)); printf (" options: backing-store %s, save-unders %s\n", (DoesBackingStore (s) == NotUseful) ? no : ((DoesBackingStore (s) == Always) ? yes : when), DoesSaveUnders (s) ? yes : no); XQueryBestSize (dpy, CursorShape, RootWindow (dpy, scr), 65535, 65535, &width, &height); if (width == 65535 && height == 65535) printf (" largest cursor: unlimited\n"); else printf (" largest cursor: %dx%d\n", width, height); printf (" current input event mask: 0x%lx\n", EventMaskOfScreen (s)); (void) print_event_mask (eventbuf, 79, 4, EventMaskOfScreen (s)); - nvi = 0; viproto.screen = scr; vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); printf (" number of visuals: %d\n", nvi); printf (" default visual id: 0x%lx\n", XVisualIDFromVisual (DefaultVisual (dpy, scr))); for (i = 0; i < nvi; i++) { print_visual_info (vip+i); } if (vip) XFree ((char *) vip); } /* * The following routine prints out an event mask, wrapping events at nice * boundaries. */ #define MASK_NAME_WIDTH 25 @@ -1026,69 +1065,83 @@ const char *s = attrpool; printf(" %s:\n ", name); while( (c = *s++) != '\0' ) { if (c == '\n') { printf("\n "); } else { fputc(c, stdout); } } fputc('\n', stdout); } static int print_xprint_info(Display *dpy, char *extname) { - short majorrev, - minorrev; - int xp_event_base, - xp_error_base; - XPPrinterList printerlist; - int plcount, - i; + short majorrev, + minorrev; + int xp_event_base, + xp_error_base; + XPPrinterList printerlist; + Screen **pscreens; + int plcount, + pscrcount, + i; if (XpQueryVersion(dpy, &majorrev, &minorrev) == False) { return 0; } print_standard_extension_info(dpy, extname, majorrev, minorrev); if (XpQueryExtension(dpy, &xp_event_base, &xp_error_base) == False) { printf(" XpQueryExtension() failed.\n"); return 0; } + /* Print event info */ printf(" xp_event_base=%d, xp_error_base=%d\n", xp_event_base, xp_error_base); + + /* Print info which screens support the Xprint extension */ + printf(" Print screens = {"); + pscreens = XpQueryScreens(dpy, &pscrcount); + for( i = 0 ; i < pscrcount ; i++ ) { + printf("%s%d", ((i > 0)?(", "):("")), (int)XScreenNumberOfScreen(pscreens[i])); + } + XFree(pscreens); + printf("}\n"); + /* Enumerate the list of printers */ printerlist = XpGetPrinterList(dpy, NULL, &plcount); /* Print number of printers, then each printer name and description */ printf(" Found %d printers on this server.\n", plcount); for( i = 0 ; i < plcount ; i++) { printf(" printer %d: name='%s', descr='%s'\n", i, NULLSTR(printerlist[i].name), NULLSTR(printerlist[i].desc)); } + /* Enumerate the list of printers with details */ for( i = 0 ; i < plcount ; i++) { char *printername = printerlist[i].name; XPContext pcontext; char *s; printf(" Attributes of printer '%s':\n", NULLSTR(printername)); pcontext = XpCreateContext(dpy, printername); if (pcontext == None) { printf(" Error: Could not open printer.\n"); continue; } s=XpGetAttributes(dpy, pcontext, XPJobAttr); print_xprint_attrpool("XPJobAttr", s); XFree(s); s=XpGetAttributes(dpy, pcontext, XPDocAttr); print_xprint_attrpool("XPDocAttr", s); XFree(s); s=XpGetAttributes(dpy, pcontext, XPPageAttr); print_xprint_attrpool("XPPageAttr", s); XFree(s); s=XpGetAttributes(dpy, pcontext, XPPrinterAttr); print_xprint_attrpool("XPPrinterAttr", s); XFree(s); s=XpGetAttributes(dpy, pcontext, XPServerAttr); print_xprint_attrpool("XPServerAttr", s); XFree(s); XpDestroyContext(dpy, pcontext);