Index: xc/programs/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Imakefile,v retrieving revision 1.9 diff -u -2 -0 -r1.9 Imakefile --- xc/programs/Imakefile 13 Oct 2004 22:51:04 -0000 1.9 +++ xc/programs/Imakefile 20 Oct 2004 01:09:21 -0000 @@ -73,80 +73,83 @@ MKFONTSCALEDIR = mkfontscale #endif #if BuildXInputLib XINPUTCLIENTDIRS = xsetmode xsetpointer #endif #if BuildXTrapLibrary XTRAPCLIENTDIRS = xtrap #endif /* makepsres should be considered as part of the DPS libraries */ #if BuildDPSLibraries MAKEPSRESDIR = makepsres #endif /* on the other hand, the following are independent clients */ #if BuildDPSClients DPSCLIENTDIRS = dpsinfo dpsexec texteroids #endif +#if BuildDBElib && BuildXprintClients + DBECLIENTDIRS = xdbedizzy +#endif XPMCLIENTDIRS = cxpm sxpm #if BuildGLXLibrary GLXCLIENTDIRS = glxinfo glxgears #endif XLOADDIR = xload #if BuildRandRLibrary XRANDRDIR = xrandr #endif #if BuildXcursorgen XCURSORGENDIR = xcursorgen #endif #if BuildFontconfigLibrary FCDIRS = fc-cache fc-list #endif #if 0 FCLANGDIR = fc-lang #endif #if BuildXDriInfo XDRIINFO = xdriinfo #endif #if BuildXaw XMORE = xmore #endif #if BuildServersOnly || !BuildClients SUBDIRS = $(XSSRCDIR) #else SUBDIRS = \ appres bdftopcf bitmap \ $(SCREENSAVESRCDIR) editres $(FCDIRS) $(FCLANGDIR) fslsfonts fstobdf \ iceauth ico listres luit \ - $(MAKEPSRESDIR) $(DPSCLIENTDIRS) \ + $(MAKEPSRESDIR) $(DPSCLIENTDIRS) $(DBECLIENTDIRS) \ $(MKCFMSRCDIR) \ mkfontdir $(MKFONTSCALEDIR) oclock $(PROXYMGRSRCDIR) \ $(RGBSRCDIR) $(RSTARTSRCDIR) showfont \ $(SMPROXYSRCDIR) $(TWMSRCDIR) viewres x11perf xauth xbiff xcalc \ xclipboard xclock \ xcmsdb $(XCONSOLESRCDIR) xditview $(XDMSRCDIR) xdpyinfo \ $(XF86DGASRCDIR) xedit xev xeyes xfd xfontsel $(XFSSRCDIR) xfsinfo \ $(XFINDPROXYSRCDIR) $(XFWPSRCDIR) $(XGAMMASRCDIR) xgc $(XHOSTSRCDIR) \ $(XINITSRCDIR) $(XKBSRCDIRS) xkill $(XLOADDIR) xlogo xlsatoms \ xlsclients xlsfonts xmag xman xmessage xmh xmodmap $(XMORE) xprop \ xrdb xrefresh $(XRXSRCDIR) xset \ xsetroot $(XSMSRCDIR) xstdcmap $(XINPUTCLIENTDIRS) \ $(XTERMSRCDIR) $(XTRAPCLIENTDIRS) $(XVIDTUNESRCDIR) xwd xwininfo xwud \ $(XPMCLIENTDIRS) $(XVINFOSRCDIR) \ $(XSSRCDIR) $(XASSRCDIR) $(LBXPROXYSRCDIR) $(XPSRCDIRS) $(SCRIPTSDIR) \ $(GLXCLIENTDIRS) $(XRANDRDIR) $(XCURSORGENDIR) $(XDRIINFO) #endif MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) Index: xc/programs/xdbedizzy/Imakefile =================================================================== RCS file: xc/programs/xdbedizzy/Imakefile diff -N xc/programs/xdbedizzy/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xdbedizzy/Imakefile 20 Oct 2004 01:09:33 -0000 @@ -0,0 +1,16 @@ +XCOMM $XConsortium: Imakefile,v 1.1 95/05/31 14:59:30 dpw Exp $ + + DEFINES = ExtensionDefines + DEPLIBS = $(DEPXPLIB) $(DEPXLIB) +LOCAL_LIBRARIES = -lXprintUtil $(XPLIB) $(XLIB) + SYS_LIBRARIES = MathLibrary + +SimpleProgramTarget(xdbedizzy) + +#ifdef HasDocBookTools +all:: xdbedizzy.man xdbedizzy.html + +ConvertDocBookToManPage(xdbedizzy.sgml, xdbedizzy.man) +ConvertDocBookToHTML(xdbedizzy.sgml, xdbedizzy.html) +#endif /* HasDocBookTools */ + Index: xc/programs/xdbedizzy/xdbedizzy.c =================================================================== RCS file: xc/programs/xdbedizzy/xdbedizzy.c diff -N xc/programs/xdbedizzy/xdbedizzy.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xdbedizzy/xdbedizzy.c 20 Oct 2004 01:09:33 -0000 @@ -0,0 +1,799 @@ +/* Xorg: xdbedizzy.c /main/3 2004/10/18 14:21:35 gisburn $ */ +/****************************************************************************** + * + * Copyright (c) 1994, 1995 Silicon Graphics Inc. + * Copyright (c) 2004 Roland Mainz + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting + * documentation, and that the name of Silicon Graphics not be + * used in advertising or publicity pertaining to distribution + * of the software without specific prior written permission. + * Silicon Graphics makes no representation about the suitability + * of this software for any purpose. It is provided "as is" + * without any express or implied warranty. + * + * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + * THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + *****************************************************************************/ + +/* + * xdbedizzy - demo of DBE creating a double buffered spinning scene + * + * Original dizzy program written by Mark Kilgard. + * + * Adapted to use DBE for double buffering by Allen Leinwand, 2/24/1995 . + * Print support added by Roland Mainz, 10/18/2004 + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) +#define Log(x) { if(verbose) printf x; } + +/* Global variables */ +static char *ProgramName = NULL; +static Display *dpy = NULL; +static Screen *screen = NULL; +static int screennum = -1; +static XPContext pcontext = None; /* Xprint context */ +static XRectangle winrect = { 0 }; +static unsigned long c_black, c_pink, c_green, c_orange, c_blue; +static Window win = None; +static XID buf = None; +static XdbeSwapInfo swapInfo = { 0 }; +static GC gc_black, gc_pink, gc_green, gc_orange, gc_blue; +static float rotation = 0.0; +static float delta = 0.05; +static Bool paused = False; +static Bool manual_paused = False; +static int xp_event_base, /* XpExtension even base */ + xp_error_base; /* XpExtension error base */ +static long dpi = 0L; /* Current page resolution */ +static int numPages = 5, /* Numer of pages to print */ + currNumPages = 0; /* Current page number */ +static Bool doPrint = False; /* Print to printer ? */ + +/* Default values for unspecified command line arguments */ +static char *display_name = NULL; +static int visclass = PseudoColor; +static int depth = 0; +static Bool listVis = False; +static Bool do_slow = False; +static int spokes = 12; +static Bool do_db = True; +static Bool verbose = False; +static Bool synchronous = False; +static VisualID visid = 0; + +static const char *help_message[] = { +" where options include:", +" -display host:dpy X server connection to use.", +" -print Use printer instead of video card for output.", +" -printer printername Name of printer to use.", +" -printfile printername Output file for print job.", +" -numpages count Number of pages to print.", +" -delta dlt Rotate per frame (video) or page (printer).", +" -class classname Class of visual to use.", +" -depth n Depth of visual to use.", +" -visid [nn,0xnn] Visual ID to use (ignore -class, -depth).", +" -list List double buffer capable visuals.", +" -nodb Single buffer (ignore -class, -depth, -visid).", +" -help Print this message.", +" -slow Rotate image slowly.", +" -sync Use synchronous X connection.", +" -spokes n Specify number of spokes to draw.", +" -verbose Produce chatty messages while running.", +NULL}; + +static +void usage(void) +{ + const char **cpp; + + fprintf (stderr, "\nusage: %s [-options ...]\n", ProgramName); + for (cpp = help_message; *cpp; cpp++) { + fprintf (stderr, "%s\n", *cpp); + } + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + + +static +unsigned long getColor(Colormap cmap, const char *color_name) +{ + XColor color; + XColor exact; + int status; + + status = XAllocNamedColor(dpy, cmap, color_name, &color, &exact); + if (status == 0) { + fprintf(stderr, "%s: Couldn't get color: %s\n", ProgramName, color_name); + exit(EXIT_FAILURE); + } + return (color.pixel); +} + + + +#define RATIO1 0.4 +#define RATIO2 0.7 +#define RATIO3 0.95 + +#ifndef M_PI +#define M_PI 3.1415927 +#endif + +#define S_ANGLE(s) (M_PI*2./(s)) + +static +void redraw(void) +{ + int i; + int x, y; + XPoint pnt[4]; + + Log(("redraw.\n")); + + /* the double-buffer extension will clear the buffer itself */ + if (!do_db) { + XClearWindow(dpy, win); + } + x = winrect.width / 2; + x += (int) (sin(rotation * 2) * 20); + y = winrect.height / 2; + y += (int) (cos(rotation * 2) * 20); + for (i = 5; i < 26; i += 3) { + XDrawArc(dpy, buf, gc_orange, x - i * 10, y - i * 10, i * 20, i * 20, 0, 360 * 64); + XDrawArc(dpy, buf, gc_green, x - i * 10 - 5, y - i * 10 - 5, i * 20 + 10, i * 20 + 10, 0, 360 * 64); + XDrawArc(dpy, buf, gc_blue, x - i * 10 - 10, y - i * 10 - 10, i * 20 + 20, i * 20 + 20, 0, 360 * 64); + } + + x = winrect.width / 2; + y = winrect.height / 2; + pnt[0].x = x; + pnt[0].y = y; + for (i = 0; i < spokes; i++) { + pnt[1].x = (int) (cos(i * S_ANGLE(spokes) + rotation) * (RATIO1 * x)) + x; + pnt[1].y = (int) (sin(i * S_ANGLE(spokes) + rotation) * (RATIO1 * y)) + y; + pnt[2].x = (int) (cos(i * S_ANGLE(spokes) + rotation - 0.1) * (RATIO2 * x)) + x; + pnt[2].y = (int) (sin(i * S_ANGLE(spokes) + rotation - 0.1) * (RATIO2 * y)) + y; + pnt[3].x = (int) (cos(i * S_ANGLE(spokes) + rotation - 0.2) * (RATIO3 * x)) + x; + pnt[3].y = (int) (sin(i * S_ANGLE(spokes) + rotation - 0.2) * (RATIO3 * y)) + y; + XDrawLines(dpy, buf, gc_pink, pnt, 4, CoordModeOrigin); + } + + if (do_db) { + XdbeSwapBuffers(dpy, &swapInfo, 1); + } +} + + +static +Visual * +choose_DB_visual( /* Input */ Display *dpy, Bool listVis, int visclass, + /* Input, Output */ int *pDepth) +{ + Drawable screen_list[1]; + int num_screens; + XdbeScreenVisualInfo *DBEvisInfo; + int i, nitems; + int chosenDepth = 0; + Visual *chosenVisual = NULL; + XVisualInfo vinfo_template, *XvisInfo; + + screen_list[0] = XRootWindowOfScreen(screen); + num_screens = 1; + DBEvisInfo = XdbeGetVisualInfo(dpy, screen_list, &num_screens); + if (DBEvisInfo == NULL) { + fprintf(stderr, "XdbeGetVisualInfo returned NULL\n"); + return (NULL); + } + + if (listVis) { + printf("\nThe double buffer capable visuals are:\n"); + printf(" visual ID depth class\n"); + } + for (i = 0; i < DBEvisInfo->count; i++) { + + vinfo_template.visualid = DBEvisInfo->visinfo[i].visual; + XvisInfo = XGetVisualInfo(dpy, VisualIDMask, + &vinfo_template, &nitems); + if (XvisInfo == NULL) { + fprintf(stderr, + "%s: XGetVisualInfo returned NULL for visual %d\n", + ProgramName, (int)vinfo_template.visualid); + return (NULL); + } + if (listVis) { + char visualClassName[64]; + + switch( XvisInfo->class ) { + case TrueColor: strcpy(visualClassName, "TrueColor"); break; + case DirectColor: strcpy(visualClassName, "DirectColor"); break; + case PseudoColor: strcpy(visualClassName, "PseudoColor"); break; + case StaticColor: strcpy(visualClassName, "StaticColor"); break; + case GrayScale: strcpy(visualClassName, "GrayScale"); break; + case StaticGray: strcpy(visualClassName, "StaticGray"); break; + default: + sprintf(visualClassName, "unknown_visual_class_%x", (int)XvisInfo->class); + break; + } + + printf(" %#4x %4d %s\n", + (int)DBEvisInfo->visinfo[i].visual, + (int)DBEvisInfo->visinfo[i].depth, + visualClassName); + } + + if (visid) { + if (XvisInfo->visualid == visid) { + chosenVisual = XvisInfo->visual; + chosenDepth = XvisInfo->depth; + } + } + else if (XvisInfo->class == visclass) { + if (*pDepth == 0) { + /* Choose first deepest visual of matching class. */ + if (DBEvisInfo->visinfo[i].depth > chosenDepth) { + chosenVisual = XvisInfo->visual; + chosenDepth = XvisInfo->depth; + } + } + else { + /* Choose last visual of matching depth and class. */ + if (DBEvisInfo->visinfo[i].depth == *pDepth) { + chosenVisual = XvisInfo->visual; + chosenDepth = XvisInfo->depth; + } + } + } + } + + if (chosenVisual) { + if (listVis) { + printf("\n"); + } + *pDepth = chosenDepth; + return (chosenVisual); + } + else { + return (NULL); + } +} + +static +void main_loop(void) +{ + fd_set select_mask; + int fd; + struct timeval timeout; + int new_event; + int pending; + Bool done = False; + + fd = XConnectionNumber(dpy); + FD_ZERO(&select_mask); + FD_SET(fd, &select_mask); + + while (!done) { + XEvent event; + + if (!paused && !manual_paused && !doPrint) { + pending = XEventsQueued(dpy, QueuedAfterFlush); + if (pending == 0) { + do { + FD_ZERO(&select_mask); + FD_SET(fd, &select_mask); + if (do_slow) { + timeout.tv_sec = 2; + timeout.tv_usec = 0; + } else { + timeout.tv_sec = 0; + timeout.tv_usec = 100000; + } + new_event = select(fd + 1, &select_mask, NULL, NULL, &timeout); + + /* When we print we only render on Expose events and bump + * |rotation| when the page number changes*/ + rotation = rotation + delta; + redraw(); + XFlush(dpy); + } while (new_event == 0); + } + } + + XNextEvent(dpy, &event); + + /* XpExtension event ? */ + if( doPrint && + (event.type == xp_event_base+XPPrintNotify) ) + { + XPPrintEvent *pev = (XPPrintEvent *)&event; + + switch( pev->detail ) { + case XPStartJobNotify: + Log(("XPStartJobNotify: Starting first page...\n")); + XpStartPage(dpy, win); + break; + case XPEndJobNotify: + Log(("XPEndJobNotify: Job done...")); + /* Job done... */ + done = True; + break; + case XPStartDocNotify: + Log(("XPStartJobNotify: Nop\n")); + break; + case XPEndDocNotify: + Log(("XPEndDocNotify: Nop\n")); + break; + case XPStartPageNotify: + /* XpStartPage() will automatically trigger an Expose event */ + + Log(("XPStartPageNotify: Page end reached.\n")); + XpEndPage(dpy); + break; + case XPEndPageNotify: + /* next page or exit */ + currNumPages++; + + rotation = rotation + delta; + + if( currNumPages < numPages ) { + Log(("Starting next page (%d)...\n", currNumPages)); + XpStartPage(dpy, win); + } + else + { + Log(("XPEndPageNotify: Finishing job...\n")); + XpEndJob(dpy); + } + break; + default: + Log(("--> other XPPrintEvent event, detail=%x\n", (int)pev->detail)); + break; + } + } + else + { + switch (event.type) { + case MapNotify: + Log(("MapNotify: resuming...\n")); + paused = False; + break; + case UnmapNotify: + Log(("UnmapNotify: pausing...\n")); + paused = True; + break; + case VisibilityNotify: + switch (event.xvisibility.state) { + case VisibilityUnobscured: + Log(("VisibilityUnobscured: resuming...\n")); + paused = False; + break; + case VisibilityPartiallyObscured: + Log(("VisibilityPartiallyObscured: resuming...\n")); + paused = False; + break; + case VisibilityFullyObscured: + Log(("VisibilityFullyObscured: pausing...\n")); + paused = True; + break; + } + break; + case Expose: + Log(("Expose: rendering.\n")); + + /* Swallow any extra Expose events (only needed for video + * display, the Xprint server is non-interactive and + * therefore cannot create extra Expose events caused + * by user input) */ + if (!doPrint) { + while (XCheckTypedEvent(dpy, Expose, &event)) + ; + } + + redraw(); + break; + case ButtonPress: + switch (event.xbutton.button) { + case 1: + printf("ButtonPress: faster: %g\n", delta); + delta += 0.005; + break; + case 2: + printf("ButtonPress: slower: %g\n", delta); + delta += -0.005; + break; + case 3: + if (manual_paused) { + printf("ButtonPress: manual resume.\n"); + manual_paused = False; + } else { + printf("ButtonPress: manual pause.\n"); + manual_paused = True; + } + } + break; + case KeyPress: + printf("KeyPress: done.\n"); + done = True; + break; + case ConfigureNotify: + Log(("ConfigureNotify:resizing.\n")); + winrect.width = event.xconfigure.width; + winrect.height = event.xconfigure.height; + break; + } + } + } +} + + +int main(int argc, char *argv[]) +{ + int i; + XSetWindowAttributes attrs; + Visual *visual; + Colormap cmap; + XGCValues gcvals; + void *printtofile_handle = NULL; /* "context" when printing to file */ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist = NULL; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + unsigned short dummy; + + ProgramName = argv[0]; + + for (i = 1; i < argc; i++) { + char *arg; + + arg = argv[i]; + if (!strcmp(arg, "-display")) { + if (++i >= argc) { + fprintf(stderr, "%s: Missing argument to -display\n", ProgramName); + exit(EXIT_FAILURE); + } + display_name = argv[i]; + } + else if (!strcmp(arg, "-print")) { + doPrint = True; + } + else if (!strcmp(arg, "-printer")) { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strcmp(arg, "-printfile")) { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strcmp(arg, "-numpages")) { + if (++i >= argc) + usage(); + errno = 0; /* reset errno to catch |atoi()|-errors */ + numPages = atoi(argv[i]); + if ((numPages <= 0) || (errno != 0)) + usage(); + doPrint = True; + } + else if (!strcmp(arg, "-delta")) { + if (++i >= argc) + usage(); + errno = 0; /* reset errno to catch |atof()|-errors */ + delta = atof(argv[i]); + if (errno != 0) + usage(); + } + else if (!strcmp(arg, "-class")) { + arg = argv[++i]; + if (arg == NULL) { + fprintf(stderr, "%s: Missing argument to -class\n", ProgramName); + exit(EXIT_FAILURE); + } + if ((!strcmp(arg, "TrueColor")) || (!strcmp(arg, "True"))) + visclass = TrueColor; + else if (!strcmp(arg, "DirectColor")) + visclass = DirectColor; + else if ((!strcmp(arg, "PseudoColor")) || (!strcmp(arg, "Pseudo"))) + visclass = PseudoColor; + else if (!strcmp(arg, "StaticColor")) + visclass = StaticColor; + else if (!strcmp(arg, "GrayScale")) + visclass = GrayScale; + else if (!strcmp(arg, "StaticGray")) + visclass = StaticGray; + else { + fprintf(stderr, "%s: Wrong argument %s for -class\n", ProgramName, arg); + exit(EXIT_FAILURE); + } + } else if (!strcmp(arg, "-depth")) { + arg = argv[++i]; + if (arg == NULL) { + fprintf(stderr, "%s: Missing argument to -depth\n", ProgramName); + exit(EXIT_FAILURE); + } + errno = 0; /* reset errno to catch |atoi()|-errors */ + depth = atoi(arg); + if (errno != 0) + usage(); + } else if (!strcmp(arg, "-help")) { + usage(); + } else if (!strcmp(arg, "-list")) { + listVis = True; + } else if (!strcmp(arg, "-slow")) { + do_slow = True; + } else if (!strcmp(arg, "-spokes")) { + arg = argv[++i]; + if (arg == NULL) { + fprintf(stderr, "%s: Missing argument to -spokes\n", ProgramName); + exit(EXIT_FAILURE); + } + errno = 0; /* reset errno to catch |atoi()|-errors */ + spokes = atoi(arg); + if (errno != 0) + usage(); + } else if (!strcmp(arg, "-nodb")) { + do_db = False; + } else if (!strcmp(arg, "-visid")) { + arg = argv[++i]; + if (arg == NULL) { + fprintf(stderr, "%s: Missing argument to -visid\n", ProgramName); + exit(EXIT_FAILURE); + } + /* |atol()| only uses base10, |strtol(..., ..., 0)| takes any base */ + visid = (int) strtol(arg, (char **)NULL, 0); + } else if (!strcmp(arg, "-verbose")) { + verbose = True; + } else if (!strcmp(arg, "-sync")) { + synchronous = True; + } + else { + fprintf(stderr, "%s: Unrecognized option %s\n", ProgramName, arg); + usage(); + } + } + + /* Display and printing at the same time not implemented */ + if (doPrint && display_name) { + usage(); + } + + if (doPrint) { + plist = XpuGetPrinterList(printername, &plist_count); + + if (!plist) { + fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", + ProgramName, NULLSTR(printername)); + return EXIT_FAILURE; + } + + printername = plist[0].name; + + Log(("Using printer '%s'\n", printername)); + + if (XpuGetPrinter(printername, &dpy, &pcontext) != 1) { + fprintf(stderr, "%s: Cannot open printer '%s'\n", ProgramName, printername); + return EXIT_FAILURE; + } + + if (synchronous) { + Log(("Running in synchronous X mode.\n")); + XSynchronize(dpy, True); + } + + if (XpQueryExtension(dpy, &xp_event_base, &xp_error_base) == False) { + fprintf(stderr, "%s: XpQueryExtension() failed.\n", ProgramName); + XpuClosePrinterDisplay(dpy, pcontext); + return EXIT_FAILURE; + } + + /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). + * This is mandatory as Xp(Start|End)(Job|Doc|Page) functions are _not_ + * syncronous !! + * Not waiting for such events may cause that subsequent data may be + * destroyed/corrupted!! + */ + XpSelectInput(dpy, pcontext, XPPrintMask); + + /* Set job title */ + XpuSetJobTitle(dpy, pcontext, "xdbedizzy for Xprint"); + + /* Set print context + * Note that this modifies the available fonts, including builtin printer prints. + * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print + * context to obtain the proper fonts. + */ + XpSetContext(dpy, pcontext); + + /* Get default printer reolution */ + if (XpuGetResolution(dpy, pcontext, &dpi) != 1) { + fprintf(stderr, "%s: No default resolution for printer '%s'.\n", + ProgramName, printername); + XpuClosePrinterDisplay(dpy, pcontext); + return EXIT_FAILURE; + } + + if (toFile) { + Log(("starting job (to file '%s').\n", toFile)); + printtofile_handle = XpuStartJobToFile(dpy, pcontext, toFile); + if( !printtofile_handle ) { + fprintf(stderr, "%s: Error: %s while trying to print to file.\n", + ProgramName, strerror(errno)); + XpuClosePrinterDisplay(dpy, pcontext); + return EXIT_FAILURE; + } + } + else + { + Log(("starting job.\n")); + XpuStartJobToSpooler(dpy); + } + + screen = XpGetScreenOfContext(dpy, pcontext); + screennum = XScreenNumberOfScreen(screen); + + /* Obtain some info about page geometry */ + XpGetPageDimensions(dpy, pcontext, &dummy, &dummy, &winrect); + } + else + { + dpy = XOpenDisplay(display_name); + if (dpy == NULL) { + fprintf(stderr, "%s: Cannot open display %s\n", + ProgramName, XDisplayName(display_name)); + exit(EXIT_FAILURE); + } + + if (synchronous) { + Log(("Running in synchronous X mode.\n")); + XSynchronize(dpy, True); + } + + screen = XDefaultScreenOfDisplay(dpy); + screennum = XScreenNumberOfScreen(screen); + pcontext = None; + + winrect.x = 10; + winrect.y = 10; + winrect.width = 400; + winrect.height = 400; + + dpi = 100L; /* hack-style - but enougth for our needs */ + } + + if (do_db) { + int dbeMajorVersion, + dbeMinorVersion; + + if (!XdbeQueryExtension (dpy, &dbeMajorVersion, &dbeMinorVersion)) { + fprintf(stderr, "%s: XdbeQueryExtension() failed.\n", ProgramName); + exit(EXIT_FAILURE); + } + + if ((visual = choose_DB_visual(dpy, listVis, visclass, &depth)) == NULL) { + fprintf(stderr, "%s: Failed to find matching double buffer capable visual.\n", ProgramName); + exit(EXIT_FAILURE); + } + fprintf(stdout, "%s: Chose visual ID: %#4x depth: %d\n\n", + ProgramName, (int)visual->visualid, depth); + } + else { + /* No double buffering: ignore class, depth; use default visual. */ + visual = XDefaultVisual(dpy, screennum); + depth = XDefaultDepth(dpy, screennum); + } + + cmap = XCreateColormap(dpy, XRootWindowOfScreen(screen), visual, AllocNone); + c_black = getColor(cmap, "black"); + c_pink = getColor(cmap, "pink"); + c_green = getColor(cmap, "green"); + c_orange = getColor(cmap, "orange"); + c_blue = getColor(cmap, "blue"); + attrs.colormap = cmap; + attrs.background_pixel = c_black; + attrs.border_pixel = c_black; + win = XCreateWindow(dpy, XRootWindowOfScreen(screen), + winrect.x, winrect.y, winrect.width, winrect.height, + 0, depth, InputOutput, visual, + CWBorderPixel | CWColormap | CWBackPixel, &attrs); + if (win == None) { + fprintf(stderr, "%s: Couldn't window.\n", ProgramName); + exit(EXIT_FAILURE); + } + + XSetStandardProperties(dpy, win, "DBE dizzy demo", ProgramName, None, + argv, argc, NULL); + XSelectInput(dpy, win, + VisibilityChangeMask | ExposureMask | ButtonPressMask | KeyPressMask | + StructureNotifyMask); + if (do_db) { + swapInfo.swap_action = XdbeBackground; + buf = XdbeAllocateBackBufferName (dpy, win, swapInfo.swap_action); + if (buf == None) { + fprintf(stderr, "%s: Couldn't create buffers\n", ProgramName); + exit(EXIT_FAILURE); + } + else { + swapInfo.swap_window = win; + } + } + else { + buf = win; /* No double buffering. */ + } + + /* Create GCs, one per color (to avoid pipeline flushing + * when the GC is changed) */ + gcvals.line_width = (8 * dpi) / 100L; /* scale line with DPI */ + gcvals.cap_style = CapRound; +#define CREATECOLORGC(cl) (gcvals.foreground = (cl), \ + XCreateGC(dpy, win, GCForeground | GCLineWidth | GCCapStyle, &gcvals)) + gc_black = CREATECOLORGC(c_black); + gc_pink = CREATECOLORGC(c_pink); + gc_green = CREATECOLORGC(c_green); + gc_orange = CREATECOLORGC(c_orange); + gc_blue = CREATECOLORGC(c_blue); +#undef CREATECOLORGC + + XMapWindow(dpy, win); + + main_loop(); + + if (doPrint) { + /* End the print job - the final results are sent by the X print + * server to the spooler sub system. + */ + Log(("finishing print job.\n")); + + if (toFile) { + if (XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished) { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + XpuClosePrinterDisplay(dpy, pcontext); + return EXIT_FAILURE; + } + } + + XDestroyWindow(dpy, win); + XpuClosePrinterDisplay(dpy, pcontext); + + XpuFreePrinterList(plist); + } + else + { + XDestroyWindow(dpy, win); + XCloseDisplay(dpy); + } + + Log(("Done.")); + + return EXIT_SUCCESS; +} + + Index: xc/programs/xdbedizzy/xdbedizzy.man =================================================================== RCS file: xc/programs/xdbedizzy/xdbedizzy.man diff -N xc/programs/xdbedizzy/xdbedizzy.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xdbedizzy/xdbedizzy.man 20 Oct 2004 01:09:33 -0000 @@ -0,0 +1,99 @@ +.\" -*- coding: us-ascii -*- +.TH xdbedizzy __appmansuffix__ "19 October 2004" +.SH NAME +xdbedizzy \- demo of DBE creating a double buffered spinning scene +.SH SYNOPSIS +.ad l +\fBxdbedizzy\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-display \fBhost:dpy\fR\fR] [\fB\-delta \fBdlt\fR\fR] [\fB\-class \fBvisclass\fR\fR] [\fB\-depth \fBvisdepth\fR\fR] [\fB\-visid \fBvisualid\fR\fR] [\fB\-list\fR] [\fB\-nodb\fR] [\fB\-help\fR] [\fB\-slow\fR] [\fB\-sync\fR] [\fB\-spokes \fBn\fR\fR] [\fB\-verbose\fR] +'in \n(.iu-\nxu +.ad b +.PP +.ad l +\fBxdbedizzy\fR \kx +.if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) +'in \n(.iu+\nxu +[\fB\-print\fR] [\fB\-printer \fBprintername\fR\fR] [\fB\-printfile \fBfile\fR\fR] [\fB\-delta \fBdlt\fR\fR] [\fB\-class \fBvisclass\fR\fR] [\fB\-depth \fBvisdepth\fR\fR] [\fB\-visid \fBvisualid\fR\fR] [\fB\-list\fR] [\fB\-nodb\fR] [\fB\-help\fR] [\fB\-slow\fR] [\fB\-sync\fR] [\fB\-spokes \fBn\fR\fR] [\fB\-verbose\fR] +'in \n(.iu-\nxu +.ad b +.SH DESCRIPTION +xdbedizzy is a demo of DBE creating a double +buffered spinning scene. +.SH OPTIONS +.TP +\fB\-display \fIhost:dpy\fB\fR +This option specifies the X server to contact. +.TP +\fB\-print\fR +Switches to printer output (default is video output). +If no other printer arguments are given the default printer +is being used. +.TP +\fB\-printer \fIprintername\fB\fR +This option specifies the Xprint printer to contact. +.TP +\fB\-printfile \fIfilename\fB\fR +Redirects the PDL (Printer Desktoption Language, usually +Postscript, PDF, PCL, etc.) stream to the specified file. +.TP +\fB\-numpages \fIcount\fB\fR +Number of pages to print. Default is 5. +.TP +\fB\-delta \fIdlt\fB\fR +Delta value used to rotate the scene for each frame (video output) +or page (printer output). +.TP +\fB\-class \fIvisclass\fB\fR +Name of visual to choose. Valid values are +TrueColor, DirectColor, PseudoColor, StaticColor, Grayscale, StaticGray +.TP +\fB\-depth \fIdepth\fB\fR +Depth of visual to use. +.TP +\fB\-visid \fIvisualid\fB\fR +Visual ID to use (ignore \fB\-class\fR, +\fB\-depth\fR). +.TP +\fB\-list\fR +List double buffer capable visuals. +.TP +\fB\-nodb\fR +Single buffer (ignore \fB\-class\fR, +\fB\-depth\fR, \fB\-visid\fR). +.TP +\fB\-help\fR +Prints usage and exists. +.TP +\fB\-slow\fR +Rotate scene slowly (no-op in print mode). +.TP +\fB\-sync\fR +Use synchronous X connection. +.TP +\fB\-spokes \fInumber\fB\fR +Specify number of spokes to draw. The default is 12. +.TP +\fB\-verbose\fR +Print verbose output. +.SH "SEE ALSO" +\fBX\fR(__miscmansuffix__), \fBXprint\fR(__miscmansuffix__), \fBXserver\fR(__appmansuffix__) +.SH ENVIRONMENT +.TP +\fBDISPLAY\fR +\fBDISPLAY\fR must be set to get the default host and display to use. +.TP +\fBXPSERVERLIST\fR +\fBXPSERVERLIST\fR must be set for the \fB\-printer\fR option +identifying the available Xprint servers. +See \fBXprint\fR(__miscmansuffix__) +for more details. +.SH AUTHOR + +Mark Kilgard +.PP +Allen Leinwand +.PP +Roland Mainz + Index: xc/programs/xdbedizzy/xdbedizzy.sgml =================================================================== RCS file: xc/programs/xdbedizzy/xdbedizzy.sgml diff -N xc/programs/xdbedizzy/xdbedizzy.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xdbedizzy/xdbedizzy.sgml 20 Oct 2004 01:09:33 -0000 @@ -0,0 +1,342 @@ + + + + + + + xdbedizzy + __appmansuffix__ + + + + xdbedizzy + demo of DBE creating a double buffered spinning scene + + + + + + xdbedizzy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + xdbedizzy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DESCRIPTION + + + xdbedizzy is a demo of DBE creating a double + buffered spinning scene. + + + + + OPTIONS + + + + + + + + This option specifies the X server to contact. + + + + + + + + + + Switches to printer output (default is video output). + If no other printer arguments are given the default printer + is being used. + + + + + + + + + + This option specifies the Xprint printer to contact. + + + + + + + + + + Redirects the PDL (Printer Desktoption Language, usually + Postscript, PDF, PCL, etc.) stream to the specified file. + + + + + + + + + + Number of pages to print. Default is 5. + + + + + + + + + + Delta value used to rotate the scene for each frame (video output) + or page (printer output). + + + + + + + + + + Name of visual to choose. Valid values are + + TrueColor + DirectColor + PseudoColor + StaticColor + Grayscale + StaticGray + + + + + + + + + + + Depth of visual to use. + + + + + + + + + + Visual ID to use (ignore , + ). + + + + + + + + + + List double buffer capable visuals. + + + + + + + + + + Single buffer (ignore , + , ). + + + + + + + + + + Prints usage and exists. + + + + + + + + + + Rotate scene slowly (no-op in print mode). + + + + + + + + + + Use synchronous X connection. + + + + + + + + + + Specify number of spokes to draw. The default is 12. + + + + + + + + + + Print verbose output. + + + + + + + + SEE ALSO + + + X__miscmansuffix__ + Xprint__miscmansuffix__ + Xserver__appmansuffix__ + + + + + + ENVIRONMENT + + + + DISPLAY + + + DISPLAY must be set to get the default host and display to use. + + + + + + XPSERVERLIST + + + XPSERVERLIST must be set for the option + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + + AUTHOR + + + + Mark Kilgard + Allen Leinwand + Roland Mainz University Giessen + + + + + + +