Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.632 diff -u -2 -0 -r1.632 ChangeLog --- xc/ChangeLog 2 Jan 2005 11:24:48 -0000 1.632 +++ xc/ChangeLog 3 Jan 2005 00:56:18 -0000 @@ -1,20 +1,57 @@ +2005-01-03 Roland Mainz + * xc/lib/XprintAppUtil/xpapputil.c + * xc/lib/XprintAppUtil/xpapputil.h + * xc/lib/XprintUtil/xprintutil.c + * xc/lib/XprintUtil/xprintutil.h + * xc/programs/glxgears/glxgears.c + * xc/programs/xdbedizzy/xdbedizzy.c + * xc/programs/xedit/Xedit-xprint.ad + * xc/programs/xedit/commands.c + * xc/programs/xlogo/print.c + * xc/programs/xlsfonts/xlsfonts.c + * xc/programs/xlsfonts/xlsfonts.man + * xc/programs/xlsfonts/xlsfonts.sgml + * xc/programs/xman/Xman-xprint.ad + * xc/programs/xman/handler.c + * xc/programs/xman/print.c + * xc/programs/xman/print.h + * xc/programs/xmore/XMore.ad + * xc/programs/xmore/print.c + * xc/programs/xmore/print.h + * xc/programs/xmore/printdialog.c + * xc/programs/xmore/printdialog.h + * xc/programs/xmore/printdialogprivates.h + * xc/programs/xmore/xmore.c + * xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c + * xc/programs/xphelloworld/xphelloworld/xphelloworld.c + * xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c + * xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c + * xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c + * xc/programs/xplsprinters/xplsprinters.c + * xc/util/memleak/getretmips.c + Bugzilla #1706 (https://bugs.freedesktop.org/show_bug.cgi?id=1706) + attachment #xxx (https://bugs.freedesktop.org/attachment.cgi?id=xxx): + XprintUtils 2004/Q3 update + Patch by Roland Mainz and Julien Lafon + . + 2005-01-02 Matthieu Herrb * doc/man/Xt/XtNextEv.man: Fix formatting. 2005-01-02 Felix Kuehling * programs/Xserver/hw/xfree86/drivers/savage/savage_dri.c: (SAVAGEInitVisualConfigs): Make 32-bit visuals match the set of visuals supported by the DRI driver. 2005-01-02 Felix Kuehling * programs/Xserver/hw/xfree86/drivers/savage/savage_dri.c: (SAVAGEDRIScreenInit), (SAVAGEDRIFinishScreenInit), (SAVAGEDRIInitBuffers), (SAVAGEDRIMoveBuffers): Reenabled SAVAGEDRIInitBuffers and SAVAGEDRIMoveBuffers and fixed lockups they were causing. InitBuffers now uses the DRM clear command, MoveBuffers needs to wait for 3D idle. Some related @@ -143,41 +180,41 @@ make sure you set "usefbdev" to false. (bug 2089) * programs/Xserver/hw/xfree86/drivers/ati/radeon.h: * programs/Xserver/hw/xfree86/drivers/ati/radeon.man: * programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c: (RADEONEngineRestore): * programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c: (RADEONProbePLLParameters), (RADEONGetPanelInfoFromReg), (RADEONGetLVDSInfo), (RADEONGetPanelInfo), (RADEONGetClockInfo), (RADEONQueryConnectedMonitors), (RADEONUpdatePanelSize), (RADEONDDCModes), (RADEONValidateDDCModes), (RADEONPreInitModes), (RADEONPreInit), (RADEONSave), (RADEONRestore), (RADEONInitDispBandwidth), (RADEONInitCrtc2Registers), (RADEONInitPLLRegisters), (RADEONInitPLL2Registers), (RADEONInit), (RADEONFreeScreen): - Apply Benjamin Herrenschmidt's radeon patches (bug 2064) 2004-12-16 Vladimir Dergachev Modified: - * programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c + * programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c * programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c Move DMA robustness fix into radeon_dri.c::RADEONEnterServer() as per suggestion by Michel Dänzer. I could not trigger a lockup, even with r300_demo (possibly it has code that flushes cache inside ?), so this must be good enough.. 2004-12-16 Vladimir Dergachev Modified: * programs/Xserver/hw/xfree86/drivers/ati/radeon_accel.c Add DMA robustness fix from Nicolai Haehnle. TODO: move this fix into DRM driver or other parts of Xserver when R300 support is more stable. This fix affects only R300 and later variants and results in Index: xc/lib/XprintAppUtil/xpapputil.c =================================================================== RCS file: /cvs/xorg/xc/lib/XprintAppUtil/xpapputil.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpapputil.c --- xc/lib/XprintAppUtil/xpapputil.c 23 Apr 2004 18:43:46 -0000 1.2 +++ xc/lib/XprintAppUtil/xpapputil.c 3 Jan 2005 00:56:32 -0000 @@ -114,49 +114,47 @@ return XpAuError_success; } else if( !strcasecmp(arg_name, "medium") || !strcasecmp(arg_name, "papersize")) { if( !(context->medium_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM)) ) return XpAuError_unsupported_medium; /* XXX: What about the tray name ? */ docvalues->medium = XpuFindMediumSourceSizeByName(context->medium_list, context->medium_num_list_entries, NULL, arg_value); if( !docvalues->medium ) return XpAuError_unsupported_medium; *docvaluemask |= XpauVMedium; return XpAuError_success; } else if( !strcasecmp(arg_name, "resolution") ) - { - int arg_res = atoi(arg_value); - + { if( !(context->resolution_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION)) ) return XpAuError_unsupported_resolution; - docvalues->resolution = XpuFindResolution(context->resolution_list, + docvalues->resolution = XpuFindResolutionByName(context->resolution_list, context->resolution_num_list_entries, - arg_res, arg_res); + arg_value); if( !docvalues->resolution ) return XpAuError_unsupported_resolution; *docvaluemask |= XpauVResolution; return XpAuError_success; } else if( !strcasecmp(arg_name, "orientation") ) { if( !(context->orientation_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION)) ) return XpAuError_unsupported_orientation; docvalues->orientation = XpuFindOrientationByName(context->orientation_list, context->orientation_num_list_entries, arg_value); if( !docvalues->orientation ) return XpAuError_unsupported_orientation; *docvaluemask |= XpauVOrientation; @@ -392,75 +390,76 @@ if( printerfile ) { context->print_to_filehandle = XpuStartJobToFile(context->pdpy, context->pcontext, printerfile); if( context->print_to_filehandle ) { result = XpAuError_success; } else { result = XpAuError_errno; } } else { XpuStartJobToSpooler(context->pdpy); result = XpAuError_success; } /* Get default printer resolution */ - if( XpuGetResolution(context->pdpy, context->pcontext, &context->document_dpi) != 1 ) + if( XpuGetResolution(context->pdpy, context->pcontext, &context->document_dpi_x, &context->document_dpi_y) != 1 ) { result = XpAuError_no_dpi_set; } if( result == XpAuError_success ) { context->inJob = True; context->pscreen = XpGetScreenOfContext(context->pdpy, context->pcontext); context->pscreennumber = XScreenNumberOfScreen(context->pscreen); } return result; } XpAuErrorValue XpauEndJob( XpauContext *context ) { XPAU_RETURN_IF_FAIL(context->inJob, XpAuError_not_inside_job); /* End the print job - the final results are sent by the X print * server to the spooler sub system. */ XpEndJob(context->pdpy); /* Be sure to process the X traffic (remember that we registered a * "consumer" hook via Xlib internal magic when we print to a * file) * FixMe: |XpuWaitForPrintFileChild()| should call XFlush() instead! */ XFlush(context->pdpy); - context->inJob = False; - context->pscreen = NULL; - context->pscreennumber = -1; - context->document_dpi = 0L; + context->inJob = False; + context->pscreen = NULL; + context->pscreennumber = -1; + context->document_dpi_x = 0L; + context->document_dpi_y = 0L; if( context->print_to_filehandle ) { if( XpuWaitForPrintFileChild(context->print_to_filehandle) != XPGetDocFinished ) { return XpAuError_errno; } } return XpAuError_success; } XpAuErrorValue XpauStartDocument( XpauContext *context, XPDocumentType type ) { XPAU_RETURN_IF_FAIL(context->inJob == True, XpAuError_not_inside_job); XPAU_RETURN_IF_FAIL(context->inDocument == False, XpAuError_inside_document); XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page); XpStartDoc(context->pdpy, type); context->inDocument = True; Index: xc/lib/XprintAppUtil/xpapputil.h =================================================================== RCS file: /cvs/xorg/xc/lib/XprintAppUtil/xpapputil.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpapputil.h --- xc/lib/XprintAppUtil/xpapputil.h 23 Apr 2004 18:43:46 -0000 1.2 +++ xc/lib/XprintAppUtil/xpapputil.h 3 Jan 2005 00:56:32 -0000 @@ -54,41 +54,42 @@ #endif /* DEBUG */ /* * Struct for XpauGetContext(), XpauReleaseContext() * */ typedef struct { Display *pdpy; XPContext pcontext; int xp_event_base, xp_error_base; Bool inJob; Bool inDocument; Bool inPage; void *print_to_filehandle; Screen *pscreen; int pscreennumber; - long document_dpi; + long document_dpi_x, + document_dpi_y; XpuSupportedFlags supported_job_attributes; XpuSupportedFlags supported_doc_attributes; XpuSupportedFlags supported_page_attributes; XpuMediumSourceSizeList medium_list; int medium_num_list_entries; XpuResolutionList resolution_list; int resolution_num_list_entries; XpuOrientationList orientation_list; int orientation_num_list_entries; XpuPlexList plex_list; int plex_num_list_entries; } XpauContext; #define XpauVFilename (1L<<0) #define XpauVMedium (1L<<1) #define XpauVResolution (1L<<2) #define XpauVOrientation (1L<<3) Index: xc/lib/XprintUtil/xprintutil.c =================================================================== RCS file: /cvs/xorg/xc/lib/XprintUtil/xprintutil.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xprintutil.c --- xc/lib/XprintUtil/xprintutil.c 23 Apr 2004 18:43:47 -0000 1.2 +++ xc/lib/XprintUtil/xprintutil.c 3 Jan 2005 00:56:33 -0000 @@ -25,43 +25,43 @@ ** dealings in this Software without prior written authorization from said ** copyright holders. ** ****************************************************************************** *****************************************************************************/ #include "xprintutil.h" #include #include #include #include #include #include #include #ifdef XPU_USE_NSPR #include "plstr.h" #undef strtok_r #define strtok_r(s1, s2, x) PL_strtok_r((s1), (s2), (x)) -#endif /* USE_MOZILLA_TYPES */ +#endif /* XPU_USE_NSPR */ -/* List of tokens which can be used to seperate entries in the +/* List of tokens which can be used to separate entries in the * $XPSERVERLIST env var */ static const char XPServerListSeparators[] = " \t\v\n\r\f"; /* conformace only; X11 API does (currrently) not make use of |const|. * If Xlib API gets fixed these macros can be turned into empty * placeholders... (|#define MAKE_STRING_WRITABLE(x)|) :-) */ #define MAKE_STRING_WRITABLE(str) (((str)?((str) = strdup(str)):0)) #define FREE_WRITABLE_STRING(str) free((void *)(str)) #define STRING_AS_WRITABLE(str) ((char *)(str)) /* Local prototypes */ static const char *XpuGetDefaultXpPrintername(void); static const char *XpuGetXpServerList( void ); static const char *XpuEnumerateXpAttributeValue( const char *value, void **vcptr ); static const char *XpuGetCurrentAttributeGroup( void **vcptr ); static void XpuDisposeEnumerateXpAttributeValue( void **vc ); static Bool XpuEnumerateMediumSourceSizes( Display *pdpy, XPContext pcontext, const char **tray_name, const char **medium_name, int *mbool, @@ -117,40 +117,69 @@ } } return s; } static const char *XpuGetXpServerList( void ) { const char *s; /* BUG/TODO: XpServerList resource needs to be sourced first, then append * contents of XPSERVERLIST, then remove duplicates... */ s = getenv("XPSERVERLIST"); if( s == NULL ) s = ""; return(s); } +Bool XpuXprintServersAvailable( void ) +{ + const char *s; + int c = 0; + /* BUGs/ToDo: + * - XpServerList resource needs to be sourced, too... + * (see comment for |XpuGetXpServerList|, too) + * - There should be some validation whether the server entries + * are + * a) valid (easy :) + * and + * b) available (hard to implement when XOpenDisplay() should be avoided) + */ + s = getenv("XPSERVERLIST"); + /* Check if serverlist is non-empty */ + if (s) + { + while( *s++ ) + { + if( !isspace(*s) ) + c++; + } + } + /* a valid server name must at least contain the ':'-seperator + * and a number (e.g. ":1") */ + return( c >= 2 ); +} + + static int XpuGetPrinter2( char *printer, char *display, Display **pdpyptr, XPContext *pcontextptr ) { Display *pdpy; XPContext pcontext; XPU_DEBUG_ONLY(printf("XpuGetPrinter2: probing display '%s' for '%s'\n", XPU_NULLXSTR(display), XPU_NULLXSTR(printer))); if( (pdpy = XOpenDisplay(display)) != NULL ) { if( XpuCheckExtension(pdpy) ) { XPPrinterList list; int list_count; /* get list of available printers... */ list = XpGetPrinterList(pdpy, printer, &list_count); if( list != NULL ) XpFreePrinterList(list); /* ...and check if printer exists... */ @@ -314,41 +343,47 @@ if( !strcmp(s, query) ) { XFree(value); XpuDisposeEnumerateXpAttributeValue(&tok_lasts); return(1); } } XpuDisposeEnumerateXpAttributeValue(&tok_lasts); XFree(value); } return(0); } int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title ) { if( XpuGetSupportedJobAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_JOB_NAME ) { - XpuSetOneAttribute(pdpy, pcontext, XPJobAttr, "*job-name", title, XPAttrMerge); + char *encoded_title; + + encoded_title = XpuResourceEncode(title); + if (!encoded_title) + return(0); + XpuSetOneAttribute(pdpy, pcontext, XPJobAttr, "*job-name", encoded_title, XPAttrMerge); + XpuResourceFreeString(encoded_title); return(1); } else { XPU_DEBUG_ONLY(printf("XpuSetJobTitle: XPUATTRIBUTESUPPORTED_JOB_NAME not supported ('%s')\n", XPU_NULLXSTR(title))); return(0); } } int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result ) { char *s; MAKE_STRING_WRITABLE(attribute_name); if( attribute_name == NULL ) return(0); s = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name)); if(s && *s) { @@ -644,41 +679,41 @@ /* alloc buffer for |medium_name| and |boolbuf| in one step * (both must be large enougth to hold at least |strlen(value)+1| bytes) */ name = (char *)malloc(value_len*2 + 4); boolbuf = name + value_len+2; /* |boolbuf| starts directly after |name| */ /* remove '{' && '}' */ s = value; d = name; do { *d = tolower(*s); if( *s!='{' && *s!='}' ) d++; s++; } while(*s); *d = '\0'; - /* seperate medium name from string */ + /* separate medium name from string */ d = (char *)search_next_space(name); if( !d ) { free(name); return(False); } *d = '\0'; *medium_name = name; /* ... continue to parse the remaining string... */ d++; /* Force C/POSIX radix for scanf()-parsing (see bug 131831 ("Printing * does not work in de_AT@euro locale")), do the parsing and restore * the original locale. * XXX: This may affect all threads and not only the calling one... */ { #define CUR_LOCALE_SIZE 256 @@ -1149,194 +1184,203 @@ if( ((tray_name && curr->tray_name)?(!strcasecmp(curr->tray_name, tray_name)):(tray_name==NULL)) && ((medium_name)?(!strcasecmp(curr->medium_name, medium_name)):(True)) ) { return(curr); } } return(NULL); } XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) { XpuResolutionList list = NULL; int rec_count = 1; /* Allocate one more |XpuResolutionRec| structure * as terminator */ char *value; char *tok_lasts; const char *s; long default_resolution = -1; int default_resolution_rec_index = -1; + char namebuf[64]; /* Get default document resolution */ if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &default_resolution) != 1 ) { default_resolution = -1; } value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "printer-resolutions-supported"); if (!value) { fprintf(stderr, "XpuGetResolutionList: Internal error, no 'printer-resolutions-supported' XPPrinterAttr found.\n"); return(NULL); } for( s = strtok_r(value, " ", &tok_lasts) ; s != NULL ; s = strtok_r(NULL, " ", &tok_lasts) ) { long tmp; tmp = strtol(s, (char **)NULL, 10); if( ((tmp == 0L) || (tmp == LONG_MIN) || (tmp == LONG_MAX)) && ((errno == ERANGE) || (errno == EINVAL)) ) { fprintf(stderr, "XpuGetResolutionList: Internal parser errror for '%s'.\n", s); continue; } rec_count++; list = (XpuResolutionRec *)realloc(list, sizeof(XpuResolutionRec)*rec_count); if( !list ) return(NULL); - list[rec_count-2].dpi = tmp; + sprintf(namebuf, "%lddpi", tmp); + list[rec_count-2].name = strdup(namebuf); + list[rec_count-2].x_dpi = tmp; + list[rec_count-2].y_dpi = tmp; if( default_resolution != -1 ) { /* Is this the default resolution ? */ - if( list[rec_count-2].dpi == default_resolution ) + if( (list[rec_count-2].x_dpi == default_resolution) && + (list[rec_count-2].y_dpi == default_resolution) ) { default_resolution_rec_index = rec_count-2; } } } XFree(value); if( list ) { /* users: DO NOT COUNT ON THIS DETAIL - * (this is only to make current impl. of XpuFreeMediumSourceSizeList() easier) - * I may remove this implementation detail in a later revision of + * (this is only to make current impl. of XpuGetResolutionList() easier) + * We may remove this implementation detail in a later revision of * the library! */ - list[rec_count-1].dpi = -1; + list[rec_count-1].name = NULL; + list[rec_count-1].x_dpi = -1; + list[rec_count-1].y_dpi = -1; rec_count--; } else { rec_count = 0; } /* Make the default resolution always the first item in the list... */ if( (default_resolution_rec_index != -1) && list ) { XpuResolutionRec tmp; tmp = list[0]; list[0] = list[default_resolution_rec_index]; list[default_resolution_rec_index] = tmp; } *numEntriesPtr = rec_count; return(list); } void XpuFreeResolutionList( XpuResolutionList list ) { if( list ) { + XpuResolutionRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->name != NULL ) + { + free((void *)curr->name); + curr++; + } + free(list); } } /* Find resolution in resolution list. - * Lower resolutions are preferred over larger resolution if |dpi_a| <= |dpi_b|, - * otherwise larger resolutions are preferred over small resolutions */ -XpuResolutionRec *XpuFindResolution( XpuResolutionList list, int list_count, long dpi_a, long dpi_b ) +XpuResolutionRec *XpuFindResolutionByName( XpuResolutionList list, int list_count, const char *name) { - XpuResolutionRec *match = NULL; - int i; + int i; - if( dpi_a <= dpi_b ) - { - /* Search list, lower resolutions are better... */ - for( i = 0 ; i < list_count ; i++ ) - { - XpuResolutionRec *curr = &list[i]; - - if( curr->dpi >= dpi_a && curr->dpi <= dpi_b ) - { - if( !match || (curr->dpi < match->dpi) ) - { - match = curr; - } - } - } - } - else + for( i = 0 ; i < list_count ; i++ ) { - /* Search list, higher resolutions are better... */ - for( i = 0 ; i < list_count ; i++ ) + XpuResolutionRec *curr = &list[i]; + if (!strcasecmp(curr->name, name)) + return curr; + + /* Search by plain DPI value (no "dpi" suffix )*/ + if (curr->x_dpi == curr->x_dpi) { - XpuResolutionRec *curr = &list[i]; - - if( curr->dpi >= dpi_b && curr->dpi <= dpi_a ) - { - if( !match || (curr->dpi > match->dpi) ) - { - match = curr; - } - } + char buf[32]; + sprintf(buf, "%ld", curr->x_dpi); + if (!strcasecmp(buf, name)) + return curr; } } - return(match); + return NULL; } /* Get default page (if defined) or document resolution * this function may fail in the following conditions: * - No default resolution set yet * - X DPI != Y DPI (not yet implemented in Xprt) */ -Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *dpi_ptr ) +Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *x_dpi_ptr, long *y_dpi_ptr ) { + long dpi; + /* Try to get the current page's resolution (pages may differ in resolution if the DDX supports this) */ - if( XpuGetOneLongAttribute(pdpy, pcontext, XPPageAttr, "default-printer-resolution", dpi_ptr) == 1 ) + if( XpuGetOneLongAttribute(pdpy, pcontext, XPPageAttr, "default-printer-resolution", &dpi) == 1 ) { + *x_dpi_ptr = dpi; + *y_dpi_ptr = dpi; return True; } /* Get document resolution */ - if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", dpi_ptr) == 1 ) + if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &dpi) == 1 ) { + *x_dpi_ptr = dpi; + *y_dpi_ptr = dpi; return True; } return False; } static int XpuSetResolution( Display *pdpy, XPContext pcontext, XPAttributes type, XpuResolutionRec *rec ) { - XpuSetOneLongAttribute(pdpy, pcontext, type, "*default-printer-resolution", rec->dpi, XPAttrMerge); + if( rec->x_dpi != rec->y_dpi ) + { + fprintf(stderr, "XpuSetResolution: internal error: x_dpi != y_dpi not supported yet.\n"); + return 0; + } + + XpuSetOneLongAttribute(pdpy, pcontext, type, "*default-printer-resolution", rec->x_dpi, XPAttrMerge); return( 1 ); } /* Set document resolution * Retun error if printer does not support setting a resolution */ int XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec ) { if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 ) return( 0 ); return XpuSetResolution(pdpy, pcontext, XPDocAttr, rec); } /* Set page medium size * Retun error if printer does not support setting a resolution or if per-page * resolution changes are not allowed. */ int XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec ) { @@ -1602,77 +1646,466 @@ { if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 ) return( 0 ); return XpuSetContentPlex(pdpy, pcontext, XPDocAttr, rec); } /* Set page plex * Retun error if printer does not support setting an plex or if * per-page plex changes are not allowed */ int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ) { if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 ) return( 0 ); return XpuSetContentPlex(pdpy, pcontext, XPPageAttr, rec); } +XpuColorspaceList XpuGetColorspaceList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) +{ + XpuColorspaceList list = NULL; + int rec_count = 1; /* Allocate one more |XpuColorspaceRec| structure + * as terminator */ + char namebuf[256]; /* Temporary name buffer for colorspace names */ + int i; /* Loop counter */ + int nvi; /* Number of visuals */ + Screen *pscreen; /* Print screen */ + XVisualInfo viproto; /* fill in for getting info */ + XVisualInfo *vip; /* retured info */ + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + + nvi = 0; + viproto.screen = XScreenNumberOfScreen(pscreen); + vip = XGetVisualInfo(pdpy, VisualScreenMask, &viproto, &nvi); + if (!vip) + { + fprintf(stderr, "XpuGetColorspaceList: Internal error: vip == NULL\n"); + return NULL; + } + + for( i = 0 ; i < nvi ; i++ ) + { + XVisualInfo *vcurr = vip+i; + char cbuff[64]; + const char *class = NULL; + +#ifdef USE_MOZILLA_TYPES + /* Workaround for the current limitation of the gfx/src/xlibrgb code + * which cannot handle depths > 24bit yet */ + if( vcurr->depth > 24 ) + continue; +#endif /* USE_MOZILLA_TYPES */ + + rec_count++; + list = (XpuColorspaceRec *)realloc(list, sizeof(XpuColorspaceRec)*rec_count); + if( !list ) + return NULL; + + /* ToDO: This needs to be updated for the COLORSPACE X11 extension + * once it is ready and approved by the XOrg arch board. */ + switch (vcurr->class) { + case StaticGray: class = "StaticGray"; break; + case GrayScale: class = "GrayScale"; break; + case StaticColor: class = "StaticColor"; break; + case PseudoColor: class = "PseudoColor"; break; + case TrueColor: class = "TrueColor"; break; + case DirectColor: class = "DirectColor"; break; + default: /* Needed for forward compatibility to the COLORSPACE extension */ + sprintf (cbuff, "unknown_class_%x", vcurr->class); + class = cbuff; + break; + } + + if (vcurr->bits_per_rgb == 8) + { + sprintf(namebuf, "%s/%dbit", class, vcurr->depth); + } + else + { + sprintf(namebuf, "%s/%dbit/%dbpg", class, vcurr->depth, vcurr->bits_per_rgb); + } + list[rec_count-2].name = strdup(namebuf); + list[rec_count-2].visualinfo = *vcurr; + } + + XFree((char *)vip); + + if( list ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuGetResolutionList() easier) + * We may remove this implementation detail in a later revision of + * the library! */ + list[rec_count-1].name = NULL; + rec_count--; + } + else + { + rec_count = 0; + } + + *numEntriesPtr = rec_count; + return(list); +} + +void XpuFreeColorspaceList( XpuColorspaceList list ) +{ + if( list ) + { + XpuColorspaceRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->name != NULL ) + { + free((void *)curr->name); + curr++; + } + + free(list); + } +} + +XpuColorspaceRec * +XpuFindColorspaceByName( XpuColorspaceList list, int list_count, const char *name ) +{ + int i; + + for( i = 0 ; i < list_count ; i++ ) + { + XpuColorspaceRec *curr = &list[i]; + if (!strcmp(curr->name, name)) + return curr; + } + + return(NULL); +} + +Bool XpuGetEnableFontDownload( Display *pdpy, XPContext pcontext ) +{ + Bool enableFontDownload; + char *value; + + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported"); + if( !value ) + { + fprintf(stderr, "XpuGetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n"); + return False; + } + + enableFontDownload = (strstr(value, "xp-list-glyph-fonts") != NULL); + XFree(value); + return enableFontDownload; +} + +int XpuSetEnableFontDownload( Display *pdpy, XPContext pcontext, Bool enableFontDownload ) +{ + char *value, + *newvalue; + + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported"); + if( !value ) + { + fprintf(stderr, "XpuSetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n"); + return 0; /* failure */ + } + + /* Set "xp-list-glyph-fonts" */ + if( enableFontDownload ) + { + /* Return success if "xp-list-glyph-fonts" is already set */ + if( strstr(value, "xp-list-glyph-fonts") != NULL ) + { + XFree(value); + return 1; /* success */ + } + + newvalue = malloc(strlen(value) + 33); + if( !newvalue ) + { + XFree(value); + return 0; /* failure */ + } + + sprintf(newvalue, "%s xp-list-glyph-fonts", value); + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", newvalue, XPAttrMerge); + + free(newvalue); + XFree(value); + return 1; /* success */ + } + else + { + char *s, /* copy string "source" */ + *d; /* copy string "destination" */ + + /* Return success if "xp-list-glyph-fonts" not set */ + d = strstr(value, "xp-list-glyph-fonts"); + if( d == NULL ) + { + XFree(value); + return 1; /* success */ + } + + /* strip "xp-list-glyph-fonts" from |value| */ + s = d+19/*strlen("xp-list-glyph-fonts")*/; + while( (*d++ = *s++) != '\0' ) + ; + + XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", value, XPAttrMerge); + + XFree(value); + return 1; /* success */ + } +} + /* Return flags to indicate which attributes are supported and which not... */ static XpuSupportedFlags XpuGetSupportedAttributes( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name ) { char *value; void *tok_lasts; XpuSupportedFlags flags = 0; MAKE_STRING_WRITABLE(attribute_name); if( attribute_name == NULL ) return(0); value = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name)); FREE_WRITABLE_STRING(attribute_name); if( value != NULL ) { const char *s; for( s = XpuEnumerateXpAttributeValue(value, &tok_lasts) ; s != NULL ; s = XpuEnumerateXpAttributeValue(NULL, &tok_lasts) ) { if( !strcmp(s, "job-name") ) flags |= XPUATTRIBUTESUPPORTED_JOB_NAME; else if( !strcmp(s, "job-owner") ) flags |= XPUATTRIBUTESUPPORTED_JOB_OWNER; else if( !strcmp(s, "notification-profile") ) flags |= XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE; else if( !strcmp(s, "copy-count") ) flags |= XPUATTRIBUTESUPPORTED_COPY_COUNT; else if( !strcmp(s, "document-format") ) flags |= XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT; else if( !strcmp(s, "content-orientation") ) flags |= XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION; else if( !strcmp(s, "default-printer-resolution") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION; else if( !strcmp(s, "default-input-tray") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY; else if( !strcmp(s, "default-medium") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM; else if( !strcmp(s, "plex") ) flags |= XPUATTRIBUTESUPPORTED_PLEX; + else if( !strcmp(s, "xp-listfonts-modes") ) flags |= XPUATTRIBUTESUPPORTED_LISTFONTS_MODES; } XpuDisposeEnumerateXpAttributeValue(&tok_lasts); XFree(value); } return(flags); } XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext) { return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "job-attributes-supported"); } XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext) { return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "document-attributes-supported"); } XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext) { return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "xp-page-attributes-supported"); } +/* Encode string for usage in a Xrm resource database as + * defined in X(7): [...] To allow a Value to begin + * with whitespace, the two-character sequence ``\space'' + * (backslash followed by space) is recognized and replaced by + * a space character, and the two-character sequence ``\tab'' + * (backslash followed by horizontal tab) is recognized and + * replaced by a horizontal tab character. To allow a Value to + * contain embedded newline characters, the two-character + * sequence ``\n'' is recognized and replaced by a newline + * character. To allow a Value to be broken across multiple + * lines in a text file, the two-character sequence ``\new- + * line'' (backslash followed by newline) is recognized and + * removed from the value. To allow a Value to contain arbi- + * trary character codes, the four-character sequence ``\nnn'', + * where each n is a digit character in the range of + * ``0''-``7'', is recognized and replaced with a single byte + * that contains the octal value specified by the sequence. + * Finally, the two-character sequence ``\\'' is recognized and + * replaced with a single backslash. + */ +char *XpuResourceEncode( const char *s ) +{ + size_t slen; + char *res; + char *d; + int i, + c; + + slen = strlen(s); + res = malloc(slen*4+1); + if (!res) + return NULL; + + d = res; + i = slen; + while (i--) { + c = *s++; + if (c == '\n') { + if (i) { + *d++ = '\\'; + *d++ = 'n'; + *d++ = '\\'; + *d++ = '\n'; + } + else { + *d++ = '\\'; + *d++ = 'n'; + } + } else if (c == '\\') { + *d++ = '\\'; + *d++ = '\\'; + } + else if ((c < ' ' && c != '\t') || + ((unsigned char)c >= 0x7F && (unsigned char)c < 0xA0)) { + sprintf(d, "\\%03o", (unsigned char)c); + d += 4; + } + else { + *d++ = c; + } + } + + *d = '\0'; + + return res; +} + +#ifdef XXXJULIEN_NOTNOW +char *XpuResourceDecode( const char *str ) +{ +} +#endif /* XXXJULIEN_NOTNOW */ + +void XpuResourceFreeString( char *s ) +{ + free(s); +} + +const char *XpuXmbToCompoundText(Display *dpy, const char *xmbtext) +{ + XTextProperty xtp; + int xcr; + char *xtl[2]; + char *ct; + + if (strlen(xmbtext) == 0) + return strdup(xmbtext); + + memset(&xtp, 0, sizeof(xtp)); + xtl[0] = (char *)xmbtext; + xtl[1] = NULL; + + xcr = XmbTextListToTextProperty(dpy, xtl, 1, XCompoundTextStyle, &xtp); + + if (xcr == XNoMemory || xcr == XLocaleNotSupported) + { + fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure.\n"); + return strdup(xmbtext); + } + + /* Did conversion succeed (some unconvertible characters + * are not a problem) ? */ + if ( !((xcr == Success) || (xcr > 0)) || + (xtp.value == NULL)) + { + fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure 2.\n"); + return strdup(xmbtext); + } + + ct = malloc(xtp.nitems+1); + if (!ct) + { + XFree(xtp.value); + return NULL; + } + memcpy(ct, xtp.value, xtp.nitems); + ct[xtp.nitems] = '\0'; + + XFree(xtp.value); + + return ct; +} + +void XpuFreeCompundTextString( const char *s ) +{ + free((void *)s); +} + +const char *XpuCompoundTextToXmb(Display *dpy, const char *ct) +{ + XTextProperty xtp; + int xcr; + char **xtl = NULL; + int xtl_count = 0; + char *xmb; + int xmb_len = 0; + int i; + + if (strlen(ct) == 0) + return strdup(ct); + + xtp.value = (unsigned char *)ct; + xtp.nitems = strlen(ct); + xtp.encoding = XInternAtom(dpy, "COMPOUND_TEXT", False); + xtp.format = 8; + + xcr = XmbTextPropertyToTextList(dpy, &xtp, &xtl, &xtl_count); + + if (xcr == XNoMemory || xcr == XLocaleNotSupported) + { + fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 1.\n"); + return strdup(ct); + } + + /* Did conversion succeed (some unconvertible characters + * are not a problem) ? */ + if ( !((xcr == Success) || (xcr > 0)) || + (xtl == NULL)) + { + fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 2.\n"); + return strdup(ct); + } + + for (i = 0; i < xtl_count; i++) + { + xmb_len += strlen(xtl[i]); + } + xmb = malloc (xmb_len + 1); + if (!xmb) + { + XFreeStringList(xtl); + return NULL; + } + xmb[0] = '\0'; /* Catch zero-length case */ + for (i = 0; i < xtl_count; i++) + { + strcat(xmb, xtl[i]); + } + + XFreeStringList(xtl); + + return xmb; +} + +void XpuFreeXmbString( const char *s ) +{ + free((void *)s); +} + /* EOF. */ Index: xc/lib/XprintUtil/xprintutil.h =================================================================== RCS file: /cvs/xorg/xc/lib/XprintUtil/xprintutil.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xprintutil.h --- xc/lib/XprintUtil/xprintutil.h 23 Apr 2004 18:43:47 -0000 1.2 +++ xc/lib/XprintUtil/xprintutil.h 3 Jan 2005 00:56:33 -0000 @@ -14,41 +14,40 @@ ** furnished to do so, subject to the following conditions: ** ** The above copyright notice and this permission notice shall be included in ** all copies or substantial portions of the Software. ** ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ** IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ** ** Except as contained in this notice, the names of the copyright holders shall ** not be used in advertising or otherwise to promote the sale, use or other ** dealings in this Software without prior written authorization from said ** copyright holders. ** ****************************************************************************** *****************************************************************************/ - /* Force ANSI C prototypes from X11 headers */ #ifndef FUNCPROTO #define FUNCPROTO 15 #endif /* !FUNCPROTO */ #include #include #include /* I don't know how to make this "better" yet... ;-( */ #ifdef USE_MOZILLA_TYPES #include #include #include #define XPU_USE_NSPR 1 /* * Disabled for now - Threaded codepath does not work properly always. * See bug 134570 ("Print-to-file not working with threaded XprintUtil") * #define XPU_USE_THREADS 1 */ @@ -71,88 +70,99 @@ #define XPU_NULLXSTR(s) (((s)!=NULL)?(s):("")) /* * Struct for XpuGetMediumSourceSizeList(), XpuFreeMediumSourceSizeList(), * XpuSetDocMediumSourceSize(), XpuSetPageMediumSourceSize(), * XpuFindMediumSourceSizeBy*() */ typedef struct { const char *tray_name; const char *medium_name; int mbool; float ma1; float ma2; float ma3; float ma4; } XpuMediumSourceSizeRec, *XpuMediumSourceSizeList; /* * Struct for XpuGetResolutionList(), XpuFreeResolutionList(), * XpuGetResolution(), XpuSetPageResolution(), XpuSetDocResolution(), - * XpuFindResolution() + * XpuFindResolutionByName() */ typedef struct { - long dpi; - /* ToDo: Support for Xdpi != Ydpi */ + const char *name; + long x_dpi; + long y_dpi; } XpuResolutionRec, *XpuResolutionList; /* * Struct for XpuGetOrientationList(), XpuFreeOrientationList(), * XpuFindOrientationBy*(), XpuSetPageResolution(), * XpuSetDocOrientation() */ typedef struct { const char *orientation; } XpuOrientationRec, *XpuOrientationList; /* * Struct for XpuGetPlexList(), XpuFreePlexList(), XpuFindPlexBy*(), * XpuSetDocPlex(), XpuSetPagePlex() */ typedef struct { const char *plex; } XpuPlexRec, *XpuPlexList; +/* + * Struct for XpuGetColorspaceList(), XpuFreeColorspaceList() + */ +typedef struct +{ + const char *name; + XVisualInfo visualinfo; +} XpuColorspaceRec, *XpuColorspaceList; /* XPUATTRIBUTESUPPORTED_*: * Flags which indicate whether it is allowed to set/change a specific attribute */ typedef long XpuSupportedFlags; /* Job attributes */ #define XPUATTRIBUTESUPPORTED_JOB_NAME (1L<<0) #define XPUATTRIBUTESUPPORTED_JOB_OWNER (1L<<1) #define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE (1L<<2) /* Document/Page attributes */ #define XPUATTRIBUTESUPPORTED_COPY_COUNT (1L<<3) #define XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT (1L<<4) #define XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION (1L<<5) #define XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION (1L<<6) #define XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY (1L<<7) #define XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM (1L<<8) #define XPUATTRIBUTESUPPORTED_PLEX (1L<<9) +#define XPUATTRIBUTESUPPORTED_LISTFONTS_MODES (1L<<10) /* prototypes */ _XFUNCPROTOBEGIN int XpuCheckExtension( Display *pdpy ); /* Create/destroy connection to printer */ +Bool XpuXprintServersAvailable( void ); int XpuGetPrinter( const char *printername, Display **pdpyptr, XPContext *pcontextptr ); void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext); /* Misc. functions */ void XpuSetOneAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule ); void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule ); int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query ); int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title ); int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result ); #ifdef DEBUG void dumpXpAttributes( Display *pdpy, XPContext pcontext ); #endif /* DEBUG */ void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail ); /* Get list of printers */ XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count ); void XpuFreePrinterList( XPPrinterList list ); @@ -160,60 +170,81 @@ int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies ); /* Get/Set/Query supported mediums (paper sizes) */ XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list ); int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ); int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ); XpuMediumSourceSizeRec * XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count, float page_width_mm, float page_height_mm, float tolerance ); XpuMediumSourceSizeRec * XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count, float m1, float m2, float m3, float m4, float tolerance ); XpuMediumSourceSizeRec * XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count, const char *tray_name, const char *medium_name ); /* Get/Set resolution */ XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); void XpuFreeResolutionList( XpuResolutionList list ); -Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *dpi ); +Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *x_dpi, long *y_dpi ); Bool XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * ); Bool XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * ); -XpuResolutionRec *XpuFindResolution( XpuResolutionList list, int list_count, long min_dpi, long max_dpi ); +XpuResolutionRec *XpuFindResolutionByName( XpuResolutionList list, int list_count, const char *resolution_name); /* Get/Set orientation */ XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); void XpuFreeOrientationList( XpuOrientationList list ); XpuOrientationRec * XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation ); int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ); int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ); /* Get/set plex modes */ XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); void XpuFreePlexList( XpuPlexList list ); XpuPlexRec *XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex ); int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ); int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ); +/* Set/get usage of fonts */ +Bool XpuGetEnableFontDownload( Display *pdpy, XPContext pcontext ); +int XpuSetEnableFontDownload( Display *pdpy, XPContext pcontext, Bool enableFontDownload ); + +/* Get per-printer colorspace information */ +XpuColorspaceList XpuGetColorspaceList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); +void XpuFreeColorspaceList( XpuColorspaceList list ); +XpuColorspaceRec *XpuFindColorspaceByName( XpuColorspaceList list, int list_count, const char *colorspace ); + /* Start job to printer (spooler) or file */ void XpuStartJobToSpooler(Display *pdpy); void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename ); XPGetDocStatus XpuWaitForPrintFileChild( void *handle ); /* Get flags which indicate whether it is allowed to set/change a specific attribute */ XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext); XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext); XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext); +/* Encode/decode resource strings */ +char *XpuResourceEncode( const char *str ); +char *XpuResourceDecode( const char *str ); +void XpuResourceFreeString( char *s ); + +/* COMPOUND_TEXT <----> local encoding string converters */ +const char *XpuXmbToCompoundText(Display *dpy, const char *xmbtext); +void XpuFreeCompundTextString( const char *s ); +const char *XpuCompoundTextToXmb(Display *dpy, const char *ct); +void XpuFreeXmbString( const char *s ); + + _XFUNCPROTOEND #define XpuGetJobAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPJobAttr ) #define XpuGetDocAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPDocAttr ) #define XpuGetPageAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPageAttr ) #define XpuGetPrinterAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr ) #define XpuGetServerAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPServerAttr ) #endif /* !XPRINTUTIL_H */ /* EOF. */ Index: xc/programs/glxgears/glxgears.c =================================================================== RCS file: /cvs/xorg/xc/programs/glxgears/glxgears.c,v retrieving revision 1.7 diff -u -2 -0 -r1.7 glxgears.c --- xc/programs/glxgears/glxgears.c 2 Oct 2004 01:48:00 -0000 1.7 +++ xc/programs/glxgears/glxgears.c 3 Jan 2005 00:56:37 -0000 @@ -607,41 +607,42 @@ sched_yield(); #endif /* TIMING */ } } } int main(int argc, char *argv[]) { Bool use_threadsafe_api = False; Display *dpy; Window win; Screen *screen; GLXContext ctx; char *dpyName = NULL; int i; XRectangle winrect; #ifdef BUILD_PRINTSUPPORT - long dpi; + long dpi_x = 0L, + dpi_y = 0L; XPContext pcontext = None; /* Xprint context */ void *printtofile_handle = NULL; /* "context" when printing to file */ Bool doPrint = FALSE; /* Print to printer ? */ const char *printername = NULL; /* printer to query */ const char *toFile = NULL; /* output file (instead of printer) */ int numPages = 5; /* Numer of pages to print */ XPPrinterList plist = NULL; /* list of printers */ int plist_count; /* number of entries in |plist|-array */ unsigned short dummy; #endif /* BUILD_PRINTSUPPORT */ ProgramName = argv[0]; for (i = 1; i < argc; i++) { const char *arg = argv[i]; int len = strlen(arg); if (strcmp(argv[i], "-display") == 0) { if (++i >= argc) usage(); @@ -748,41 +749,41 @@ /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). * This is mantatory 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, "glxgears 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) { + if (XpuGetResolution(dpy, pcontext, &dpi_x, &dpi_y) != 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; } XpuWaitForPrintNotify(dpy, xp_event_base, XPStartJobNotify); } else { Index: xc/programs/xdbedizzy/xdbedizzy.c =================================================================== RCS file: /cvs/xorg/xc/programs/xdbedizzy/xdbedizzy.c,v retrieving revision 1.1 diff -u -2 -0 -r1.1 xdbedizzy.c --- xc/programs/xdbedizzy/xdbedizzy.c 20 Oct 2004 04:37:06 -0000 1.1 +++ xc/programs/xdbedizzy/xdbedizzy.c 3 Jan 2005 00:56:39 -0000 @@ -55,41 +55,42 @@ /* 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 float speed = 20.0; 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 long dpi_x = 0L, /* Current page resolution */ + dpi_y = 0L; 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 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.", @@ -631,41 +632,41 @@ /* 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) { + if (XpuGetResolution(dpy, pcontext, &dpi_x, &dpi_y) != 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); @@ -683,41 +684,41 @@ 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 */ + dpi_x = dpi_y = 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. */ @@ -748,41 +749,41 @@ 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.line_width = (8L * ((dpi_x+dpi_y)/2L)) / 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")); Index: xc/programs/xedit/Xedit-xprint.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/Xedit-xprint.ad,v retrieving revision 1.1 diff -u -2 -0 -r1.1 Xedit-xprint.ad --- xc/programs/xedit/Xedit-xprint.ad 2 Sep 2004 08:40:32 -0000 1.1 +++ xc/programs/xedit/Xedit-xprint.ad 3 Jan 2005 00:56:39 -0000 @@ -515,40 +515,42 @@ *printdialogshell*main*printtofile.label: Print to File *printdialogshell*main*printtofile.tip: Save print job in a file ! Print job options dialog *printdialogshell*setup*geometry: 600x400 *printdialogshell*setup*title: Print: Print job options *printdialogshell*setup*ok.fromVert: list *printdialogshell*setup*ok.label: OK *printdialogshell*setup*ok.tip: Commit changes *printdialogshell*setup*cancel.fromHoriz: ok *printdialogshell*setup*cancel.fromVert: list *printdialogshell*setup*cancel.label: Cancel *printdialogshell*setup*cancel.tip: Cancel and reset to defaults *printdialogshell*setup*paperlist.tip: Select paper size *printdialogshell*setup*resolutionlist.fromHoriz: paperlist *printdialogshell*setup*resolutionlist.tip: Select page resolution *printdialogshell*setup*orientationlist.fromHoriz: resolutionlist *printdialogshell*setup*orientationlist.tip: Select page orientation *printdialogshell*setup*plexlist.fromHoriz: orientationlist *printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*colorspacelist.fromHoriz: plexlist +*printdialogshell*setup*colorspacelist.tip: Select color space (color, grayscale, CYMK, etc.) *printdialogshell*setup*jobcopieslabel.fromVert: paperlist *printdialogshell*setup*jobcopieslabel.tip: Set number of job copies *printdialogshell*setup*jobcopieslabel.label: Job Copies: *printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel *printdialogshell*setup*jobcopies.fromVert: paperlist *printdialogshell*setup*jobcopies.tip: Set number of job copies ! Printer selection *printdialogshell*printerselection*geometry: 400x150 *printdialogshell*printerselection*title: Print: Select printer *printdialogshell*printerselection*ok.fromVert: list *printdialogshell*printerselection*ok.label: OK *printdialogshell*printerselection*ok.tip: Switch printer *printdialogshell*printerselection*cancel.fromHoriz: ok *printdialogshell*printerselection*cancel.fromVert: list *printdialogshell*printerselection*cancel.label: Cancel *printdialogshell*printerselection*cancel.tip: Cancel printer selection *printdialogshell*printerselection*list.tip: Select printer name from list ! Select job file Index: xc/programs/xedit/commands.c =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/commands.c,v retrieving revision 1.5 diff -u -2 -0 -r1.5 commands.c --- xc/programs/xedit/commands.c 2 Sep 2004 08:40:32 -0000 1.5 +++ xc/programs/xedit/commands.c 3 Jan 2005 00:56:40 -0000 @@ -532,41 +532,42 @@ XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; Cardinal n; Arg args[2]; Widget textsource; Log(("printOKXtProc: OK.\n")); /* Get TextSource object */ n = 0; XtSetArg(args[n], XtNtextSource, &textsource); n++; XtGetValues(textwindow, args, n); Assertion(textsource != NULL, (("printOKXtProc: textsource == NULL.\n"))); /* ||printJobNameBuffer| must live as long the print job prints * because it is used for the job title AND the page headers... */ sprintf(printJobNameBuffer, "Xedit print job"); DoPrintTextSource("Xedit", textsource, topwindow, - pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + pdcs->pdpy, pdcs->pcontext, pdcs->colorspace, + printshellDestroyXtProc, printJobNameBuffer, pdcs->printToFile?pdcs->printToFileName:NULL); XtPopdown(printdialog_shell); } static void printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { Log(("printCancelXtProc: cancel.\n")); XtPopdown(printdialog_shell); Log(("destroying print dialog shell...\n")); XtDestroyWidget(printdialog_shell); printdialog_shell = NULL; printdialog = NULL; Log(("... done\n")); } Index: xc/programs/xlogo/print.c =================================================================== RCS file: /cvs/xorg/xc/programs/xlogo/print.c,v retrieving revision 1.1 diff -u -2 -0 -r1.1 print.c --- xc/programs/xlogo/print.c 9 May 2004 00:36:41 -0000 1.1 +++ xc/programs/xlogo/print.c 3 Jan 2005 00:56:40 -0000 @@ -144,76 +144,77 @@ } static void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data) { AppPrintData *p = (AppPrintData *)client_data; Log(("--> PrintEndJobCB\n")); /* Finish printing and destroy print shell (it's legal to destroy Xt * widgets from within it's own callbacks) */ FinishPrinting(p); } void DoPrint(Widget toplevel, const char *printername, const char *toFile) { XPPrinterList plist; /* list of printers */ int plist_count; /* number of entries in |plist|-array */ Display *pdpy = NULL; XPContext pcontext = None; - long dpi = 0; + long dpi_x = 0L, + dpi_y = 0L; if (apd->isPrinting) { fprintf(stderr, "%s: Already busy with printing.\n", ProgramName); return; } plist = XpuGetPrinterList(printername, &plist_count); if (!plist) { fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n", ProgramName, NULLSTR(printername)); return; } printername = strdup(plist[0].name); XpuFreePrinterList(plist); Log(("Using printer '%s'\n", printername)); /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) { fprintf(stderr, "%s: Cannot open printer '%s'.\n", ProgramName, printername); return; } /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, "Xprint XLogo"); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) { + if (XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1) { fprintf(stderr, "%s: No default resolution for printer '%s'\n", ProgramName, printername); XpuClosePrinterDisplay(pdpy, pcontext); return; } apd->toplevel = toplevel; apd->pdpy = pdpy; apd->pcontext = pcontext; apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "Print", NULL, 0); XtAddCallback(apd->printshell, XawNpageSetupCallback, PageSetupCB, (XtPointer)apd); XtAddCallback(apd->printshell, XawNendJobCallback, PrintEndJobCB, (XtPointer)apd); apd->isPrinting = True; if (toFile) { printf("%s: Printing to file '%s'...\n", ProgramName, toFile); apd->printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); Index: xc/programs/xlsfonts/xlsfonts.c =================================================================== RCS file: /cvs/xorg/xc/programs/xlsfonts/xlsfonts.c,v retrieving revision 1.4 diff -u -2 -0 -r1.4 xlsfonts.c --- xc/programs/xlsfonts/xlsfonts.c 7 Oct 2004 03:53:20 -0000 1.4 +++ xc/programs/xlsfonts/xlsfonts.c 3 Jan 2005 00:56:41 -0000 @@ -76,40 +76,41 @@ static void get_list(char *pattern); static int compare(const void *arg1, const void *arg2); static void show_fonts(void); static void copy_number(char **pp1, char**pp2, int n1, int n2); static int IgnoreError(Display *disp, XErrorEvent *event); static void PrintProperty(XFontProp *prop); static void ComputeFontType(XFontStruct *fs); static void print_character_metrics(register XFontStruct *info); static void do_query_font (Display *dpy, char *name); void usage(void) { fprintf (stderr, "usage: %s [-options] [-fn pattern]\n", program_name); fprintf (stderr, "where options include:\n"); fprintf (stderr, " -l[l[l]] give long info about each font\n"); fprintf (stderr, " -m give character min and max bounds\n"); fprintf (stderr, " -C force columns\n"); fprintf (stderr, " -1 force single column\n"); fprintf (stderr, " -u keep output unsorted\n"); #ifdef BUILD_PRINTSUPPORT + fprintf (stderr, " -r resolution set print resolution\n"); fprintf (stderr, " -b list printer builtin fonts\n"); fprintf (stderr, " -B do not list printer builtin fonts\n"); fprintf (stderr, " -g list glyph fonts\n"); fprintf (stderr, " -G do not list glyph fonts\n"); fprintf (stderr, " -x mode enable listfont mode\n"); fprintf (stderr, " -X mode disable listfont mode\n"); #endif /* BUILD_PRINTSUPPORT */ fprintf (stderr, " -o use OpenFont/QueryFont instead of ListFonts\n"); fprintf (stderr, " -w width maximum width for multiple columns\n"); fprintf (stderr, " -n columns number of columns if multi column\n"); fprintf (stderr, " -display displayname X server to contact\n"); fprintf (stderr, " -d displayname (alias for -display displayname)\n"); #ifdef BUILD_PRINTSUPPORT fprintf (stderr, " -printer printername printer to use\n"); fprintf (stderr, " -p printername (alias for -p printername)\n"); #endif /* BUILD_PRINTSUPPORT */ fprintf (stderr, "\n"); Close_Display(); exit(EXIT_FAILURE); } @@ -156,40 +157,63 @@ argv++; get_list(argv[0]); goto next; case 'w': if (--argc <= 0) usage (); argv++; max_output_line_width = atoi(argv[0]); goto next; case 'n': if (--argc <= 0) usage (); argv++; columns = atoi(argv[0]); goto next; case 'o': open_instead_of_list = True; break; case 'u': sort_output = False; break; #ifdef BUILD_PRINTSUPPORT + case 'r': + { + const char *resname; + XpuResolutionList rlist; + int num_rlist; + XpuResolutionRec *res; + + if (--argc <= 0) usage (); + argv++; + resname = argv[0]; + + if (!printer_output) + Fatal_Error("Option '%c' only supported for printers.", argv[0][i]); + rlist = XpuGetResolutionList(dpy, pcontext, &num_rlist); + if (!rlist) + Fatal_Error("Could not get list of supported resolutions (Server configuration error ?)."); + res = XpuFindResolutionByName(rlist, num_rlist, resname); + if (!res) + Fatal_Error("Could not find resolution '%s'.", resname); + XpuSetDocResolution(dpy, pcontext, res); + XpuFreeResolutionList(rlist); + } + goto next; case 'b': mode = "xp-list-internal-printer-fonts"; if (!printer_output) Fatal_Error("Option '%c' only supported for printers.", argv[0][i]); if (!IsListfontsModesChangeSupported(mode)) Fatal_Error("Printer does not support changing '%s'.", mode); SetListfontsModes(mode, True); break; case 'B': mode = "xp-list-internal-printer-fonts"; if (!printer_output) Fatal_Error("Option '%c' only supported for printers.", argv[0][i]); if (!IsListfontsModesChangeSupported(mode)) Fatal_Error("Printer does not support changing '%s'.", mode); SetListfontsModes(mode, False); break; case 'g': mode = "xp-list-glyph-fonts"; if (!printer_output) Fatal_Error("Option '%c' only supported for printers.", argv[0][i]); Index: xc/programs/xlsfonts/xlsfonts.man =================================================================== RCS file: /cvs/xorg/xc/programs/xlsfonts/xlsfonts.man,v retrieving revision 1.4 diff -u -2 -0 -r1.4 xlsfonts.man --- xc/programs/xlsfonts/xlsfonts.man 8 Oct 2004 02:39:41 -0000 1.4 +++ xc/programs/xlsfonts/xlsfonts.man 3 Jan 2005 00:56:41 -0000 @@ -1,38 +1,38 @@ .\" -*- coding: us-ascii -*- -.TH xlsfonts __appmansuffix__ "8 October 2004" +.TH xlsfonts __appmansuffix__ "25 October 2004" .SH NAME xlsfonts \- server font list displayer for X .SH SYNOPSIS .ad l \fBxlsfonts\fR \kx .if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) 'in \n(.iu+\nxu [\fB\-display \fBhost:dpy\fR\fR] [\fB\-l\fR] [\fB\-ll\fR] [\fB\-lll\fR] [\fB\-m\fR] [\fB\-C\fR] [\fB\-1\fR] [\fB\-w \fBwidth\fR\fR] [\fB\-n \fBcolumns\fR\fR] [\fB\-u\fR] [\fB\-o\fR] [\fB\-fn \fBpattern\fR\fR] 'in \n(.iu-\nxu .ad b .PP .ad l \fBxlsfonts\fR \kx .if (\nxu > (\n(.lu / 2)) .nr x (\n(.lu / 5) 'in \n(.iu+\nxu -\fB\-printer \fBprintername\fR\fR [\fB\-l\fR] [\fB\-ll\fR] [\fB\-lll\fR] [\fB\-m\fR] [\fB\-C\fR] [\fB\-1\fR] [\fB\-w \fBwidth\fR\fR] [\fB\-n \fBcolumns\fR\fR] [\fB\-u\fR] [\fB\-o\fR] [\fB\-b\fR] [\fB\-B\fR] [\fB\-g\fR] [\fB\-G\fR] [\fB\-x \fBmode\fR\fR] [\fB\-X \fBmode\fR\fR] [\fB\-fn \fBpattern\fR\fR] +\fB\-printer \fBprintername\fR\fR [\fB\-l\fR] [\fB\-ll\fR] [\fB\-lll\fR] [\fB\-m\fR] [\fB\-C\fR] [\fB\-1\fR] [\fB\-w \fBwidth\fR\fR] [\fB\-n \fBcolumns\fR\fR] [\fB\-u\fR] [\fB\-o\fR] [\fB\-r \fBresolution\fR\fR] [\fB\-b\fR] [\fB\-B\fR] [\fB\-g\fR] [\fB\-G\fR] [\fB\-x \fBmode\fR\fR] [\fB\-X \fBmode\fR\fR] [\fB\-fn \fBpattern\fR\fR] 'in \n(.iu-\nxu .ad b .SH DESCRIPTION xlsfonts lists the fonts that match the given pattern. The wildcard character "*" may be used to match any sequence of characters (including none), and "?" to match any single character. If no pattern is given, "*" is assumed. .PP The "*" and "?" characters must be quoted to prevent them from being expanded by the shell. .SH OPTIONS .TP \fB\-display \fIhost:dpy\fB\fR This option specifies the X server to contact. .TP \fB\-printer \fIprintername\fB\fR This option specifies the Xprint printer to contact. .TP \fB\-d \fIhost:dpy\fB\fR Same as \fB\-display \fIhost:dpy\fB\fR. .TP @@ -65,40 +65,48 @@ This option specifies the width in characters that should be used in figuring out how many columns to print. The default is 79. .TP \fB\-n \fIcolumns\fB\fR This option specifies the number of columns to use in displaying the output. By default, it will attempt to fit as many columns of font names into the number of character specified by \fB\-w\fR width. .TP \fB\-u\fR This option indicates that the output should be left unsorted. .TP \fB\-o\fR This option indicates that xlsfonts should do an OpenFont (and QueryFont, if appropriate) rather than a ListFonts. This is useful if ListFonts or ListFontsWithInfo fail to list a known font (as is the case with some scaled font systems). .TP +\fB\-r \fIresolutionname\fB\fR +Set print resolution name (usually values like \fB300dpi\fR +or \fB300x600\fR, see output of xplsprinters). +This may alter the output of xlsfonts if there are printer +fonts which get enabled/disabled on per-resolution basis by the DDX. + +(printer mode only) +.TP \fB\-b\fR List printer builtin fonts. This is the same as \fB\-x xp\-list\-internal\-printer\-fonts\fR. (printer mode only) .TP \fB\-B\fR Do not list printer builtin fonts. This is the same as \fB\-X xp\-list\-internal\-printer\-fonts\fR. (printer mode only) .TP \fB\-g\fR List glyph fonts. This is the same as \fB\-x xp\-list\-glyph\-fonts\fR. (printer mode only) .TP \fB\-G\fR Do not list glyph fonts. Index: xc/programs/xlsfonts/xlsfonts.sgml =================================================================== RCS file: /cvs/xorg/xc/programs/xlsfonts/xlsfonts.sgml,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xlsfonts.sgml --- xc/programs/xlsfonts/xlsfonts.sgml 8 Oct 2004 02:39:41 -0000 1.2 +++ xc/programs/xlsfonts/xlsfonts.sgml 3 Jan 2005 00:56:41 -0000 @@ -62,40 +62,42 @@ + + DESCRIPTION @@ -250,40 +252,56 @@ This option indicates that the output should be left unsorted. This option indicates that xlsfonts should do an OpenFont (and QueryFont, if appropriate) rather than a ListFonts. This is useful if ListFonts or ListFontsWithInfo fail to list a known font (as is the case with some scaled font systems). + + + + + Set print resolution name (usually values like 300dpi + or 300x600, see output of xplsprinters). + This may alter the output of xlsfonts if there are printer + fonts which get enabled/disabled on per-resolution basis by the DDX. + + + (printer mode only) + + + + + List printer builtin fonts. This is the same as . (printer mode only) Do not list printer builtin fonts. This is the same as . Index: xc/programs/xman/Xman-xprint.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xman/Xman-xprint.ad,v retrieving revision 1.1 diff -u -2 -0 -r1.1 Xman-xprint.ad --- xc/programs/xman/Xman-xprint.ad 2 Sep 2004 08:40:33 -0000 1.1 +++ xc/programs/xman/Xman-xprint.ad 3 Jan 2005 00:56:41 -0000 @@ -248,40 +248,42 @@ *printdialogshell*main*printtofile.label: Print to File *printdialogshell*main*printtofile.tip: Save print job in a file ! Print job options dialog *printdialogshell*setup*geometry: 600x400 *printdialogshell*setup*title: Print: Print job options *printdialogshell*setup*ok.fromVert: list *printdialogshell*setup*ok.label: OK *printdialogshell*setup*ok.tip: Commit changes *printdialogshell*setup*cancel.fromHoriz: ok *printdialogshell*setup*cancel.fromVert: list *printdialogshell*setup*cancel.label: Cancel *printdialogshell*setup*cancel.tip: Cancel and reset to defaults *printdialogshell*setup*paperlist.tip: Select paper size *printdialogshell*setup*resolutionlist.fromHoriz: paperlist *printdialogshell*setup*resolutionlist.tip: Select page resolution *printdialogshell*setup*orientationlist.fromHoriz: resolutionlist *printdialogshell*setup*orientationlist.tip: Select page orientation *printdialogshell*setup*plexlist.fromHoriz: orientationlist *printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*colorspacelist.fromHoriz: plexlist +*printdialogshell*setup*colorspacelist.tip: Select color space (color, grayscale, CYMK, etc.) *printdialogshell*setup*jobcopieslabel.fromVert: paperlist *printdialogshell*setup*jobcopieslabel.tip: Set number of job copies *printdialogshell*setup*jobcopieslabel.label: Job Copies: *printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel *printdialogshell*setup*jobcopies.fromVert: paperlist *printdialogshell*setup*jobcopies.tip: Set number of job copies ! Printer selection *printdialogshell*printerselection*geometry: 400x150 *printdialogshell*printerselection*title: Print: Select printer *printdialogshell*printerselection*ok.fromVert: list *printdialogshell*printerselection*ok.label: OK *printdialogshell*printerselection*ok.tip: Switch printer *printdialogshell*printerselection*cancel.fromHoriz: ok *printdialogshell*printerselection*cancel.fromVert: list *printdialogshell*printerselection*cancel.label: Cancel *printdialogshell*printerselection*cancel.tip: Cancel printer selection *printdialogshell*printerselection*list.tip: Select printer name from list ! Select job file Index: xc/programs/xman/handler.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/handler.c,v retrieving revision 1.5 diff -u -2 -0 -r1.5 handler.c --- xc/programs/xman/handler.c 2 Sep 2004 08:40:33 -0000 1.5 +++ xc/programs/xman/handler.c 3 Jan 2005 00:56:41 -0000 @@ -614,41 +614,42 @@ static void printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) { XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; Cardinal n; Arg args[2]; ManpageGlobals *mg = GetGlobals(w); Widget topwindow = mg->This_Manpage; FILE *file; Log(("printOKXtProc: OK.\n")); /* Get file object */ n = 0; XtSetArg(args[n], XtNfile, &file); n++; XtGetValues(mg->manpagewidgets.manpage, args, n); Assertion(file != NULL, (("printOKXtProc: file == NULL.\n"))); DoPrintManpage("Xman", file, topwindow, - pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + pdcs->pdpy, pdcs->pcontext, pdcs->colorspace, + printshellDestroyXtProc, mg->manpage_title, pdcs->printToFile?pdcs->printToFileName:NULL); XtPopdown(mg->printdialog_shell); } static void printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { ManpageGlobals * mg = GetGlobals(w); Log(("printCancelXtProc: cancel.\n")); XtPopdown(mg->printdialog_shell); Log(("destroying print dialog shell...\n")); XtDestroyWidget(mg->printdialog_shell); mg->printdialog_shell = NULL; mg->printdialog = NULL; Log(("... done\n")); } Index: xc/programs/xman/print.c =================================================================== RCS file: /cvs/xorg/xc/programs/xman/print.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 print.c --- xc/programs/xman/print.c 12 Oct 2004 22:46:40 -0000 1.2 +++ xc/programs/xman/print.c 3 Jan 2005 00:56:42 -0000 @@ -24,66 +24,74 @@ in this Software without prior written authorization from The Open Group. * */ /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Error(x) { printf x ; exit(EXIT_FAILURE); } #define Assertion(expr, msg) { if (!(expr)) { Error msg } } #define Log(x) { if(True) printf x; } #include "print.h" #include "ScrollByL.h" #include #include #include #include static Widget CreatePrintShell(Widget videoshell, - Screen *pscreen, + Screen *pscreen, + Visual *pvisual, String printshell_name, ArgList args, Cardinal numargs) { String videoname, videoclass; Widget pappshell, printshell; Display *pdpy = XDisplayOfScreen(pscreen); int dummyc = 0; String dummys = ""; + Cardinal shell_n; + Arg shell_args[5]; + XtGetApplicationNameAndClass(XtDisplay(videoshell), &videoname, &videoclass); /* XXX: Why is the |dummyc|&&|dummys| stuff needed here ? */ XtDisplayInitialize(XtWidgetToApplicationContext(videoshell), pdpy, videoname, videoclass, NULL, 0, &dummyc, &dummys); - pappshell = XtVaAppCreateShell(videoname, videoclass, + shell_n = 0; + XtSetArg(shell_args[shell_n], XtNscreen, pscreen); shell_n++; + if (pvisual) { + XtSetArg(shell_args[shell_n], XtNvisual, pvisual); shell_n++; + } + pappshell = XtAppCreateShell(videoname, videoclass, applicationShellWidgetClass, pdpy, - XtNscreen, pscreen, - NULL); + shell_args, shell_n); printshell = XtCreatePopupShell(printshell_name, xawPrintShellWidgetClass, pappshell, args, numargs); /* we're mapping/unmapping at start/end page time */ XtSetMappedWhenManaged(printshell, False); /* We realise the widget when we're done with building the widget tree... */ return printshell; } typedef struct { const char *programname; Widget toplevel; Bool isPrinting; Widget printshell; struct @@ -207,126 +215,133 @@ p->toplevel = NULL; p->isPrinting = False; p->pdpy = NULL; p->pscreen = NULL; p->pcontext = None; } static void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data) { AppPrintData *p = (AppPrintData *)client_data; Log(("--> PrintEndJobCB\n")); /* Finish printing and destroy print shell (it's legal to destroy Xt * widgets from within it's own callbacks) */ FinishPrinting(p); } static -XFontStruct *GetPrintTextFont(Display *pdpy, const char *fontprefix, long dpi) +XFontStruct *GetPrintTextFont(Display *pdpy, const char *fontprefix, long dpi_x, long dpi_y) { XFontStruct *font; char fontname[1024]; - sprintf(fontname, "%s--*-120-%ld-%ld-*-*-iso8859-1", fontprefix, dpi, dpi); + sprintf(fontname, "%s--*-120-%ld-%ld-*-*-iso8859-1", fontprefix, dpi_x, dpi_y); font = XLoadQueryFont(pdpy, fontname); if (!font) { - sprintf(fontname, "-adobe-courier-medium-r-normal--*-120-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-adobe-courier-medium-r-normal--*-120-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); font = XLoadQueryFont(pdpy, fontname); } if (!font) { - sprintf(fontname, "-*-*-*-*-*-*-*-120-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-120-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); font = XLoadQueryFont(pdpy, fontname); } if (!font) Error(("XLoadQueryFont failure.\n")); return font; } void DoPrintManpage(const char *programname, FILE *manpagefile, Widget toplevel, Display *pdpy, XPContext pcontext, + XpuColorspaceRec *colorspace, XtCallbackProc pdpyDestroyCB, const char *jobtitle, const char *toFile) { - long dpi = 0; + long dpi_x = 0L, + dpi_y = 0L; int n; Arg args[20]; XFontStruct *printFontNormal; XFontStruct *printFontBold; XFontStruct *printFontItalic; XFontStruct *printFontSymbol; if (!manpagefile) { Error(("DoPrintManpage: No FILE given.")); } apd->programname = programname; apd->pdpyDestroyCallback = pdpyDestroyCB; if (apd->isPrinting) { fprintf(stderr, "%s: Already busy with printing.\n", apd->programname); return; } /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, jobtitle); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) { + if (XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1) { fprintf(stderr, "%s: No default resolution for printer.\n", apd->programname); XpuClosePrinterDisplay(pdpy, pcontext); return; } apd->toplevel = toplevel; apd->pdpy = pdpy; apd->pcontext = pcontext; apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); apd->jobtitle = jobtitle; n = 0; /* Override any geometry resource settings as XawPrintShell adjusts it's size * to the current page siue when |XawPrintLAYOUTMODE_DRAWABLEAREA| or * |XawPrintLAYOUTMODE_PAGESIZE| are used. */ XtSetArg(args[n], XtNgeometry, "+0+0"); n++; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; - apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n); + if (colorspace) { + printf("Setting visual to id=0x%lx.\n", colorspace->visualinfo.visualid); + } + apd->printshell = CreatePrintShell(toplevel, apd->pscreen, + (colorspace?(colorspace->visualinfo.visual):(NULL)), + "printshell", args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; apd->content.form = XtCreateManagedWidget("form", formWidgetClass, apd->printshell, args, n); - printFontNormal = GetPrintTextFont(pdpy, "-*-courier-medium-r-*", dpi); - printFontBold = GetPrintTextFont(pdpy, "-*-courier-bold-r-*", dpi); - printFontItalic = GetPrintTextFont(pdpy, "-*-courier-medium-o-*", dpi); - printFontSymbol = GetPrintTextFont(pdpy, "-*-symbol-*-*-*", dpi); + printFontNormal = GetPrintTextFont(pdpy, "-*-courier-medium-r-*", dpi_x, dpi_y); + printFontBold = GetPrintTextFont(pdpy, "-*-courier-bold-r-*", dpi_x, dpi_y); + printFontItalic = GetPrintTextFont(pdpy, "-*-courier-medium-o-*", dpi_x, dpi_y); + printFontSymbol = GetPrintTextFont(pdpy, "-*-symbol-*-*-*", dpi_x, dpi_y); n = 0; XtSetArg(args[n], XtNfromHoriz, NULL); n++; XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNfont, printFontNormal); n++; /* fontset would be better */ XtSetArg(args[n], XtNlabel, "Page: n/n"); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; apd->content.pageheaderlabel = XtCreateManagedWidget("pageinfo", labelWidgetClass, apd->content.form, args, n); n = 0; XtSetArg(args[n], XtNfile, manpagefile); n++; /* Usually I would expect that using |XtNfromVert, apd->content.pageheaderlabel| * would be the correct way to place the text widget with the main content below * the page header widget - but for an unknown reason this doesn not work: The * text widget squishes itself into the bottom half of the page and only occupies * 1/2 of the page's with... ;-(( */ Index: xc/programs/xman/print.h =================================================================== RCS file: /cvs/xorg/xc/programs/xman/print.h,v retrieving revision 1.1 diff -u -2 -0 -r1.1 print.h --- xc/programs/xman/print.h 8 Jun 2004 02:44:35 -0000 1.1 +++ xc/programs/xman/print.h 3 Jan 2005 00:56:42 -0000 @@ -23,25 +23,26 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ #ifndef XMAN_PRINT_H #define XMAN_PRINT_H 1 #include #include #include #include #include #include /* Prototypes */ void DoPrintManpage(const char *programname, FILE *manpage, Widget toplevel, Display *pdpy, XPContext pcontext, + XpuColorspaceRec *colorspace, XtCallbackProc printDisplayDestroyCallback, const char *jobTitle, const char *toFile); #endif /* !XMAN_PRINT_H */ Index: xc/programs/xmore/XMore.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/XMore.ad,v retrieving revision 1.3 diff -u -2 -0 -r1.3 XMore.ad --- xc/programs/xmore/XMore.ad 8 Jun 2004 02:44:35 -0000 1.3 +++ xc/programs/xmore/XMore.ad 3 Jan 2005 00:56:42 -0000 @@ -84,40 +84,42 @@ *printdialogshell*main*printtofile.label: Print to File *printdialogshell*main*printtofile.tip: Save print job in a file ! Print job options dialog *printdialogshell*setup*geometry: 600x400 *printdialogshell*setup*title: Print: Print job options *printdialogshell*setup*ok.fromVert: list *printdialogshell*setup*ok.label: OK *printdialogshell*setup*ok.tip: Commit changes *printdialogshell*setup*cancel.fromHoriz: ok *printdialogshell*setup*cancel.fromVert: list *printdialogshell*setup*cancel.label: Cancel *printdialogshell*setup*cancel.tip: Cancel and reset to defaults *printdialogshell*setup*paperlist.tip: Select paper size *printdialogshell*setup*resolutionlist.fromHoriz: paperlist *printdialogshell*setup*resolutionlist.tip: Select page resolution *printdialogshell*setup*orientationlist.fromHoriz: resolutionlist *printdialogshell*setup*orientationlist.tip: Select page orientation *printdialogshell*setup*plexlist.fromHoriz: orientationlist *printdialogshell*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialogshell*setup*colorspacelist.fromHoriz: plexlist +*printdialogshell*setup*colorspacelist.tip: Select color space (color, grayscale, CYMK, etc.) *printdialogshell*setup*jobcopieslabel.fromVert: paperlist *printdialogshell*setup*jobcopieslabel.tip: Set number of job copies *printdialogshell*setup*jobcopieslabel.label: Job Copies: *printdialogshell*setup*jobcopies.fromHoriz: jobcopieslabel *printdialogshell*setup*jobcopies.fromVert: paperlist *printdialogshell*setup*jobcopies.tip: Set number of job copies ! Printer selection *printdialogshell*printerselection*geometry: 400x150 *printdialogshell*printerselection*title: Print: Select printer *printdialogshell*printerselection*ok.fromVert: list *printdialogshell*printerselection*ok.label: OK *printdialogshell*printerselection*ok.tip: Switch printer *printdialogshell*printerselection*cancel.fromHoriz: ok *printdialogshell*printerselection*cancel.fromVert: list *printdialogshell*printerselection*cancel.label: Cancel *printdialogshell*printerselection*cancel.tip: Cancel printer selection *printdialogshell*printerselection*list.tip: Select printer name from list ! Select job file Index: xc/programs/xmore/print.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/print.c,v retrieving revision 1.5 diff -u -2 -0 -r1.5 print.c --- xc/programs/xmore/print.c 12 Oct 2004 22:46:40 -0000 1.5 +++ xc/programs/xmore/print.c 3 Jan 2005 00:56:42 -0000 @@ -24,66 +24,74 @@ in this Software without prior written authorization from The Open Group. * */ /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) #define Error(x) { printf x ; exit(EXIT_FAILURE); } #define Assertion(expr, msg) { if (!(expr)) { Error msg } } #define Log(x) { if(True) printf x; } #include "print.h" #include #include #include #include #include static Widget CreatePrintShell(Widget videoshell, - Screen *pscreen, + Screen *pscreen, + Visual *pvisual, String printshell_name, ArgList args, Cardinal numargs) { String videoname, videoclass; Widget pappshell, printshell; Display *pdpy = XDisplayOfScreen(pscreen); int dummyc = 0; String dummys = ""; + Cardinal shell_n; + Arg shell_args[5]; + XtGetApplicationNameAndClass(XtDisplay(videoshell), &videoname, &videoclass); /* XXX: Why is the |dummyc|&&|dummys| stuff needed here ? */ XtDisplayInitialize(XtWidgetToApplicationContext(videoshell), pdpy, videoname, videoclass, NULL, 0, &dummyc, &dummys); - pappshell = XtVaAppCreateShell(videoname, videoclass, + shell_n = 0; + XtSetArg(shell_args[shell_n], XtNscreen, pscreen); shell_n++; + if (pvisual) { + XtSetArg(shell_args[shell_n], XtNvisual, pvisual); shell_n++; + } + pappshell = XtAppCreateShell(videoname, videoclass, applicationShellWidgetClass, pdpy, - XtNscreen, pscreen, - NULL); + shell_args, shell_n); printshell = XtCreatePopupShell(printshell_name, xawPrintShellWidgetClass, pappshell, args, numargs); /* we're mapping/unmapping at start/end page time */ XtSetMappedWhenManaged(printshell, False); /* We realise the widget when we're done with building the widget tree... */ return printshell; } typedef struct { const char *programname; Widget toplevel; Bool isPrinting; Widget printshell; struct @@ -207,134 +215,140 @@ p->toplevel = NULL; p->isPrinting = False; p->pdpy = NULL; p->pscreen = NULL; p->pcontext = None; } static void PrintEndJobCB(Widget pshell, XtPointer client_data, XtPointer call_data) { AppPrintData *p = (AppPrintData *)client_data; Log(("--> PrintEndJobCB\n")); /* Finish printing and destroy print shell (it's legal to destroy Xt * widgets from within it's own callbacks) */ FinishPrinting(p); } static -XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi) +XFontSet GetPrintTextFontSet(const char *appname, Display *pdpy, long dpi_x, long dpi_y) { XFontSet fontset; char fontname[1024]; char **missing_charset_list_return; int missing_charset_count_return; char *def_string_return; int i; sprintf(fontname, /* Default font for CDE */ "-dt-interface user-medium-r-normal-s*-*-120-%ld-%ld-*-*," /* Default font */ "-adobe-courier-medium-r-normal--*-120-%ld-%ld-*-*," /* Default font for Linux/Japanese locales (ja_JP.SJIS) */ "-watanabe-mincho-medium-r-normal--*-120-%ld-%ld-*-*," "-wadalab-gothic-medium-r-normal--*-120-%ld-%ld-*-*," /* Fallback */ "-*-*-*-*-*--*-120-%ld-%ld-*-*", - dpi, dpi, - dpi, dpi, - dpi, dpi, - dpi, dpi, - dpi, dpi); + dpi_x, dpi_y, + dpi_x, dpi_y, + dpi_x, dpi_y, + dpi_x, dpi_y, + dpi_x, dpi_y); fontset = XCreateFontSet(pdpy, fontname, &missing_charset_list_return, &missing_charset_count_return, &def_string_return); for( i=0 ; i < missing_charset_count_return ; i++ ) { fprintf(stderr, "%s: warning: font for charset %s is lacking.\n", appname, missing_charset_list_return[i]); } if (!fontset) Error(("GetPrintTextFontSet: XCreateFontSet() failure.\n")); return fontset; } void DoPrintTextSource(const char *programname, Widget textsource, Widget toplevel, Display *pdpy, XPContext pcontext, + XpuColorspaceRec *colorspace, XtCallbackProc pdpyDestroyCB, const char *jobtitle, const char *toFile) { - long dpi = 0; + long dpi_x = 0L, + dpi_y = 0L; int n; Arg args[20]; XFontSet textfontset = NULL; XFontSetExtents *font_extents; apd->programname = programname; apd->pdpyDestroyCallback = pdpyDestroyCB; if (apd->isPrinting) { fprintf(stderr, "%s: Already busy with printing.\n", apd->programname); return; } /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, jobtitle); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) { + if (XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1) { fprintf(stderr, "%s: No default resolution for printer.\n", apd->programname); XpuClosePrinterDisplay(pdpy, pcontext); return; } apd->toplevel = toplevel; apd->pdpy = pdpy; apd->pcontext = pcontext; apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); apd->jobtitle = jobtitle; n = 0; /* Override any geometry resource settings as XawPrintShell adjusts it's size * to the current page siue when |XawPrintLAYOUTMODE_DRAWABLEAREA| or * |XawPrintLAYOUTMODE_PAGESIZE| are used. */ XtSetArg(args[n], XtNgeometry, "+0+0"); n++; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; - apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n); - + if (colorspace) { + printf("Setting visual to id=0x%lx.\n", colorspace->visualinfo.visualid); + } + apd->printshell = CreatePrintShell(toplevel, apd->pscreen, + (colorspace?(colorspace->visualinfo.visual):(NULL)), + "printshell", args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; apd->content.form = XtCreateManagedWidget("form", formWidgetClass, apd->printshell, args, n); - textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi); + textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi_x, dpi_y); n = 0; XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNfromHoriz, NULL); n++; XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNfontSet, textfontset); n++; XtSetArg(args[n], XtNlabel, "Page: n/n"); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; apd->content.pageheaderlabel = XtCreateManagedWidget("pageinfo", labelWidgetClass, apd->content.form, args, n); font_extents = XExtentsOfFontSet(textfontset); n = 0; XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNtextSource, textsource); n++; XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollNever); n++; XtSetArg(args[n], XtNscrollVertical, XawtextScrollNever); n++; Index: xc/programs/xmore/print.h =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/print.h,v retrieving revision 1.3 diff -u -2 -0 -r1.3 print.h --- xc/programs/xmore/print.h 30 May 2004 22:44:01 -0000 1.3 +++ xc/programs/xmore/print.h 3 Jan 2005 00:56:42 -0000 @@ -23,25 +23,26 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ #ifndef XMORE_PRINT_H #define XMORE_PRINT_H 1 #include #include #include #include #include #include /* Prototypes */ void DoPrintTextSource(const char *programname, Widget textsource, Widget toplevel, Display *pdpy, XPContext pcontext, + XpuColorspaceRec *colorspace, XtCallbackProc printDisplayDestroyCallback, const char *jobTitle, const char *toFile); #endif /* !XMORE_PRINT_H */ Index: xc/programs/xmore/printdialog.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/printdialog.c,v retrieving revision 1.4 diff -u -2 -0 -r1.4 printdialog.c --- xc/programs/xmore/printdialog.c 29 Jul 2004 00:40:35 -0000 1.4 +++ xc/programs/xmore/printdialog.c 3 Jan 2005 00:56:43 -0000 @@ -69,40 +69,41 @@ static void updateWidgetStates(PrintDialogWidget pdw); static void printSetupClose(PrintDialogWidget pdw); static void printSetupOKXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupCancelXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupJobCopiesXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printDialogDestXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSelectFileXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printOKXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSetupXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printFileSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData); static void buildFileDialog(PrintDialogWidget pdw); static void closePrinterConnection(PrintDialogWidget pdw, Bool closeDisplay); static Bool openPrinterConnection(PrintDialogWidget pdw); static void destroyPrintSetupDialog(PrintDialogWidget pdw); static Widget buildPrintSetupDialog(PrintDialogWidget pdw); static String *xpprinterlist_to_widget_printerlist(XPPrinterList printerlist, int num_printers); static String *xppaperlist_to_widget_paperlist(XpuMediumSourceSizeList paperlist, int num_papers); static String *xpresolutionlist_to_widget_resolutionlist(XpuResolutionList reslist, int num_resolutions); static String *xporientationlist_to_widget_orientationlist(XpuOrientationList orientationlist, int num_orientations); static String *xpplexlist_to_widget_plexlist(XpuPlexList plexlist, int num_plex); +static String *xpcolorspacelist_to_widget_colorspacelist(XpuColorspaceList colorspacelist, int num_colorspaces); static void printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printSelectPrinterXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printerSelectionClose(PrintDialogWidget pdw); static void printerSelectionOKXtProc(Widget w, XtPointer client_data, XtPointer callData); static void printerSelectionCancelXtProc(Widget w, XtPointer client_data, XtPointer callData); static Bool buildPrinterSelectionDialog(PrintDialogWidget pdw); static void destroyPrinterSelectionDialog(PrintDialogWidget pdw); static void createprintdialogchildren(Widget w); static void do_beep(PrintDialogWidget pdw) { Log(("*** Beep!\n")); #ifdef XKB XkbStdBell(XtDisplay((Widget)pdw), XtWindow((Widget)pdw), 0, XkbBI_MinorError); #else XBell(XtDisplay((Widget)pdw), 0); #endif /* XKB */ } @@ -241,40 +242,49 @@ XtFree((char *)lrs); /* Set orientation */ lrs = XawListShowCurrent(pdp->setup.orientationlist); if (lrs->list_index != XAW_LIST_NONE) { Log(("selected orientation is '%s'/'%d'\n", lrs->string, lrs->list_index)); Assertion(lrs->list_index < pdp->num_orientations, (("Error: lrs->list_index < pdp->num_orientations\n"))); XpuSetDocOrientation(pdp->pdpy, pdp->pcontext, &pdp->orientationlist[lrs->list_index]); } XtFree((char *)lrs); /* Set plex mode */ lrs = XawListShowCurrent(pdp->setup.plexlist); if (lrs->list_index != XAW_LIST_NONE) { Log(("selected plex is '%s'/'%d'\n", lrs->string, lrs->list_index)); Assertion(lrs->list_index < pdp->num_plex, (("Error: lrs->list_index < pdp->num_plex\n"))); XpuSetDocPlex(pdp->pdpy, pdp->pcontext, &pdp->plexlist[lrs->list_index]); } XtFree((char *)lrs); + /* Set colorspace */ + lrs = XawListShowCurrent(pdp->setup.colorspacelist); + if (lrs->list_index != XAW_LIST_NONE) { + Log(("selected colorspace is '%s'/'%d'\n", lrs->string, lrs->list_index)); + Assertion(lrs->list_index < pdp->num_colorspaces, (("Error: lrs->list_index < pdp->num_colorspaces\n"))); + pdp->selected_colorspace = &pdp->colorspacelist[lrs->list_index]; + } + XtFree((char *)lrs); + printSetupClose(pdw); } static void printSetupCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; Log(("## printSetupCancel: closing print setup!\n")); printSetupClose(pdw); } static void printSetupJobCopiesXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; char *string = NULL; Log(("## printSetupJobCopiesXtProc!\n")); @@ -369,40 +379,41 @@ if (!pdp->pdpy) { Log(("printOKXtProc: no printer connection, opening one....\n")); openPrinterConnection(pdw); if (!pdp->pdpy) { Log(("printOKXtProc: still no printer connection - BAD (this should never happen).\n")); do_beep(pdw); return; } } if (pdp->ok_callback) { XawPrintDialogCallbackStruct pdcs; Log(("printOKXtProc: calling callbacks...\n")); memset(&pdcs, 0, sizeof(pdcs)); pdcs.pdpy = pdp->pdpy; pdcs.pcontext = pdp->pcontext; pdcs.printToFile = pdp->printToFile; pdcs.printToFileName = (const char *)pdp->filename; + pdcs.colorspace = pdp->selected_colorspace; XtCallCallbackList((Widget)pdw, pdp->ok_callback, &pdcs); } printSetupClose(pdw); } static void printSetupXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; Log(("## setup!\n")); if (!pdp->setup.popup) { if (buildPrintSetupDialog(pdw) == NULL) { Log(("printSetupXtProc: buildPrintSetupDialog failure.\n")); return; } } @@ -483,108 +494,122 @@ if (pdp->orientationlist) { XpuFreeOrientationList(pdp->orientationlist); pdp->orientationlist = NULL; } if (pdp->widget_orientationlist) { free(pdp->widget_orientationlist); pdp->widget_orientationlist = NULL; } if (pdp->plexlist) { XpuFreePlexList(pdp->plexlist); pdp->plexlist = NULL; } if (pdp->widget_plexlist) { free(pdp->widget_plexlist); pdp->widget_plexlist = NULL; } + if (pdp->colorspacelist) { + XpuFreeColorspaceList(pdp->colorspacelist); + pdp->colorspacelist = NULL; + } + + if (pdp->widget_colorspacelist) { + free(pdp->widget_colorspacelist); + pdp->widget_colorspacelist = NULL; + } + pdp->selected_colorspace = NULL; + if (pdp->pdpy) { if (closeDisplay) { XpuClosePrinterDisplay(pdp->pdpy, pdp->pcontext); } pdp->pdpy = NULL; pdp->pcontext = None; } updateWidgetStates(pdw); } static Bool openPrinterConnection(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; Log(("# openPrinterConnection\n")); /* Close any outstanding connection first... */ closePrinterConnection(pdw, True); if (!pdp->printer_name) { Log(("# error: openPrinterConnection: No printer name.\n")); return False; } if (XpuGetPrinter(pdp->printer_name, &pdp->pdpy, &pdp->pcontext) == False) { Log(("openPrinterConnection: could not open printer.\n")); return False; } pdp->paperlist = XpuGetMediumSourceSizeList(pdp->pdpy, pdp->pcontext, &pdp->num_papers); pdp->resolutionlist = XpuGetResolutionList(pdp->pdpy, pdp->pcontext, &pdp->num_resolutions); pdp->orientationlist = XpuGetOrientationList(pdp->pdpy, pdp->pcontext, &pdp->num_orientations); pdp->plexlist = XpuGetPlexList(pdp->pdpy, pdp->pcontext, &pdp->num_plex); + pdp->colorspacelist = XpuGetColorspaceList(pdp->pdpy, pdp->pcontext, &pdp->num_colorspaces); pdp->widget_paperlist = xppaperlist_to_widget_paperlist(pdp->paperlist, pdp->num_papers); pdp->widget_resolutionlist = xpresolutionlist_to_widget_resolutionlist(pdp->resolutionlist, pdp->num_resolutions); pdp->widget_orientationlist = xporientationlist_to_widget_orientationlist(pdp->orientationlist, pdp->num_orientations); pdp->widget_plexlist = xpplexlist_to_widget_plexlist(pdp->plexlist, pdp->num_plex); + pdp->widget_colorspacelist = xpcolorspacelist_to_widget_colorspacelist(pdp->colorspacelist, pdp->num_colorspaces); updateWidgetStates(pdw); return True; } #undef DEFAULT_WIDTH #define DEFAULT_WIDTH 120 #undef DEFAULT_INFOLABEL_WIDTH #define DEFAULT_INFOLABEL_WIDTH 250 static void destroyPrintSetupDialog(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; if (pdp->setup.popup) { XtDestroyWidget(pdp->setup.popup); } /* |XtDestroyWidget(pdp->setup.popup);| above will recursively destroy * all children so we only have to reset the pointers here... */ pdp->setup.popup = NULL; pdp->setup.form = NULL; pdp->setup.paperlist = NULL; pdp->setup.resolutionlist = NULL; pdp->setup.orientationlist = NULL; pdp->setup.plexlist = NULL; + pdp->setup.colorspacelist = NULL; pdp->setup.ok = NULL; pdp->setup.cancel = NULL; } static Widget buildPrintSetupDialog(PrintDialogWidget pdw) { PrintDialogPart *pdp = &pdw->printdialog; int n; Arg args[20]; Widget listform; XpuSupportedFlags jobflags, docflags; Bool canChangeJobCopies, canChangePaperSize, canChangeResolution, canChangeOrientation, canChangePlex; if (!pdp->pdpy) { @@ -637,40 +662,49 @@ n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; XtSetArg(args[n], XtNsensitive, canChangeOrientation); n++; XtSetArg(args[n], XtNlist, pdp->widget_orientationlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.orientationlist = XtCreateManagedWidget("orientationlist", listWidgetClass, listform, args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNforceColumns, True); n++; XtSetArg(args[n], XtNdefaultColumns, 1); n++; XtSetArg(args[n], XtNsensitive, canChangePlex); n++; XtSetArg(args[n], XtNlist, pdp->widget_plexlist); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; pdp->setup.plexlist = XtCreateManagedWidget("plexlist", listWidgetClass, listform, args, n); n = 0; + XtSetArg(args[n], XtNresizable, True); n++; + XtSetArg(args[n], XtNforceColumns, True); n++; + XtSetArg(args[n], XtNdefaultColumns, 1); n++; + XtSetArg(args[n], XtNsensitive, True); n++; + XtSetArg(args[n], XtNlist, pdp->widget_colorspacelist); n++; + XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; + pdp->setup.colorspacelist = XtCreateManagedWidget("colorspacelist", listWidgetClass, listform, args, n); + + n = 0; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNresizable, False); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; XtSetArg(args[n], XtNwidth, DEFAULT_WIDTH); n++; XtSetArg(args[n], XtNsensitive, canChangeJobCopies); n++; pdp->setup.jobcopieslabel = XtCreateManagedWidget("jobcopieslabel", labelWidgetClass, listform, args, n); n = 0; XtSetArg(args[n], XtNstring, "1"); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNeditType, XawtextEdit); n++; XtSetArg(args[n], XtNsensitive, canChangeJobCopies); n++; pdp->setup.jobcopies = XtCreateManagedWidget("jobcopies", asciiTextWidgetClass, listform, args, n); XtAddCallback(pdp->setup.jobcopies, XtNpositionCallback, printSetupJobCopiesXtProc, pdw); n = 0; pdp->setup.ok = XtCreateManagedWidget("ok", commandWidgetClass, pdp->setup.form, args, n); XtAddCallback(pdp->setup.ok, XtNcallback, printSetupOKXtProc, pdw); n = 0; @@ -709,58 +743,47 @@ int i; String *names; names = malloc(sizeof(String *) * (num_papers+1)); if (!names) return NULL; for(i = 0 ; i < num_papers ; i++) names[i] = (char *)paperlist[i].medium_name; /* FixMe: tray selection missing */ names[i] = NULL; /* Terminate the list */ return names; } static String *xpresolutionlist_to_widget_resolutionlist(XpuResolutionList reslist, int num_resolutions) { int i; String *names; - char *mem; - - /* Allocate a chunk of memory... */ - mem = malloc((sizeof(String *)+32) * (num_resolutions+2)); - /* ... which has enougth space for the list pointers... */ - names = (String *)mem; + names = malloc(sizeof(String *) * (num_resolutions+1)); if (!names) - return NULL; - - /* ... and the numbers (assuming one number isn't longer than 32-1 chars) */ - mem += sizeof(String *) * (num_resolutions+2); + return NULL; - for(i = 0 ; i < num_resolutions ; i++) { - sprintf(mem, "%d", (int)reslist[i].dpi); - names[i] = mem; - mem += strlen(mem) + 1; - } + for(i = 0 ; i < num_resolutions ; i++) + names[i] = (char *)reslist[i].name; names[i] = NULL; /* Terminate the list */ return names; } static String *xporientationlist_to_widget_orientationlist(XpuOrientationList orientationlist, int num_orientations) { int i; String *names; names = malloc(sizeof(String *) * (num_orientations+1)); if (!names) return NULL; for(i = 0 ; i < num_orientations ; i++) names[i] = (char *)orientationlist[i].orientation; names[i] = NULL; /* Terminate the list */ @@ -769,40 +792,58 @@ } static String *xpplexlist_to_widget_plexlist(XpuPlexList plexlist, int num_plex) { int i; String *names; names = malloc(sizeof(String *) * (num_plex+1)); if(!names) return NULL; for(i = 0 ; i < num_plex ; i++) names[i] = (char *)plexlist[i].plex; names[i] = NULL; /* Terminate the list */ return names; } +static +String *xpcolorspacelist_to_widget_colorspacelist(XpuColorspaceList colorspacelist, int num_colorspaces) +{ + int i; + String *names; + + names = malloc(sizeof(String *) * (num_colorspaces+1)); + if(!names) + return NULL; + + for(i = 0 ; i < num_colorspaces ; i++) + names[i] = (char *)colorspacelist[i].name; + + names[i] = NULL; /* Terminate the list */ + + return names; +} + static void printerSelectionPrinterSelectedXtProc(Widget w, XtPointer client_data, XtPointer callData) { PrintDialogWidget pdw = (PrintDialogWidget)client_data; PrintDialogPart *pdp = &pdw->printdialog; XawListReturnStruct *lrs = (XawListReturnStruct *)callData; int list_index; Log(("## user selected a printer\n")); list_index = lrs->list_index; if (list_index == XAW_LIST_NONE) { Log(("printerSelectionPrinterSelectedXtProc: Nothing selected.\n")); return; } Log(("selected printer is '%d'/'%s'/'%s'\n", list_index, lrs->string, NULLSTR(pdp->printerlist[list_index].name))); /* Enable OK button */ Index: xc/programs/xmore/printdialog.h =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/printdialog.h,v retrieving revision 1.3 diff -u -2 -0 -r1.3 printdialog.h --- xc/programs/xmore/printdialog.h 29 Jul 2004 00:40:35 -0000 1.3 +++ xc/programs/xmore/printdialog.h 3 Jan 2005 00:56:43 -0000 @@ -31,39 +31,40 @@ #include #include #include #include #include #include #include /* Resources: NOT WRITTEN YET */ #define XtCIcon "Icon" #define XtNicon "icon" #define XawNOkCallback "okCallback" #define XawNCancelCallback "cancelCallback" typedef struct { - Display *pdpy; - XPContext pcontext; - const char *printToFileName; - Boolean printToFile; + Display *pdpy; + XPContext pcontext; + const char *printToFileName; + Boolean printToFile; + XpuColorspaceRec *colorspace; } XawPrintDialogCallbackStruct; typedef struct _PrintDialogClassRec *PrintDialogWidgetClass; typedef struct _PrintDialogRec *PrintDialogWidget; extern WidgetClass printDialogWidgetClass; _XFUNCPROTOBEGIN /* Prototypes */ void XawPrintDialogClosePrinterConnection(Widget w, Bool closeDisplay); _XFUNCPROTOEND #endif /* !XMORE_PRINTDIALOG_H */ Index: xc/programs/xmore/printdialogprivates.h =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/printdialogprivates.h,v retrieving revision 1.1 diff -u -2 -0 -r1.1 printdialogprivates.h --- xc/programs/xmore/printdialogprivates.h 24 May 2004 03:17:44 -0000 1.1 +++ xc/programs/xmore/printdialogprivates.h 3 Jan 2005 00:56:43 -0000 @@ -83,93 +83,99 @@ desclabel, desc, info, namelabel, name, selectprinter, filenamelabel, filename, selectfile, printtoprinter, printtofile, ok, setup, cancel; } main; Bool printToFile; char *filename; Bool canPrint, /* can we print ? */ canReallyPrint; /* is it really save to print ? */ + XpuColorspaceRec *selected_colorspace; struct { Widget popup, form, list, ok, cancel; } selectPrinter; struct { Widget popup, form, paperlist, resolutionlist, orientationlist, plexlist, + colorspacelist, jobcopieslabel, jobcopies, ok, cancel; } setup; struct { Widget dialog, shell; } selectFile; XPPrinterList printerlist; int num_printers; String *widget_printerlist; String printer_name; Display *pdpy; XPContext pcontext; XpuMediumSourceSizeList paperlist; int num_papers; String *widget_paperlist; XpuResolutionList resolutionlist; int num_resolutions; String *widget_resolutionlist; XpuOrientationList orientationlist; int num_orientations; String *widget_orientationlist; XpuPlexList plexlist; int num_plex; String *widget_plexlist; + + XpuColorspaceList colorspacelist; + int num_colorspaces; + String *widget_colorspacelist; } PrintDialogPart; typedef struct _PrintDialogRec { CorePart core; CompositePart composite; ConstraintPart constraint; FormPart form; PrintDialogPart printdialog; } PrintDialogRec; typedef struct { XtPointer extension; } PrintDialogConstraintsPart; typedef struct _PrintDialogConstraintsRec { FormConstraintsPart form; PrintDialogConstraintsPart printdialog; } PrintDialogConstraintsRec, *PrintDialogConstraints; #endif /* !_XawPrintDialogP_h */ Index: xc/programs/xmore/xmore.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/xmore.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 xmore.c --- xc/programs/xmore/xmore.c 30 May 2004 22:44:01 -0000 1.3 +++ xc/programs/xmore/xmore.c 3 Jan 2005 00:56:43 -0000 @@ -149,41 +149,42 @@ XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; Cardinal n; Arg args[2]; Widget textsource; Log(("printOKXtProc: OK.\n")); /* Get TextSource object */ n = 0; XtSetArg(args[n], XtNtextSource, &textsource); n++; XtGetValues(text, args, n); Assertion(textsource != NULL, (("printOKXtProc: textsource == NULL.\n"))); /* ||printJobNameBuffer| must live as long the print job prints * because it is used for the job title AND the page headers... */ sprintf(printJobNameBuffer, "XMore print job %s", viewFileName); DoPrintTextSource(ProgramName, textsource, toplevel, - pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + pdcs->pdpy, pdcs->pcontext, pdcs->colorspace, + printshellDestroyXtProc, printJobNameBuffer, pdcs->printToFile?pdcs->printToFileName:NULL); XtPopdown(printdialog_shell); } static void printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { Log(("printCancelXtProc: cancel.\n")); XtPopdown(printdialog_shell); Log(("destroying print dialog shell...\n")); XtDestroyWidget(printdialog_shell); printdialog_shell = NULL; printdialog = NULL; Log(("... done\n")); } static void Index: xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 xpawhelloworld.c --- xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c 12 Oct 2004 22:46:41 -0000 1.3 +++ xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c 3 Jan 2005 00:56:43 -0000 @@ -229,120 +229,121 @@ static void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) { MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; Log(("--> PrintEndJobCB\n")); /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ XtAppSetExitFlag(mpcd->appcontext); } int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) { XtAppContext app; Widget toplevel, shell, print_shell, hello; - long dpi; + long dpi_x = 0L, + dpi_y = 0L; char fontname[256]; /* BUG: is this really big enougth ? */ XFontStruct *textFont; XmFontList textFontList; Cardinal n; Arg args[10]; MyPrintCallbackData mpcd; if( doPrint ) { /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) Error(("XpuGetPrinter failure.\n")); /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XawPrintShell widget demo"); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) { fprintf(stderr, "No default resolution for printer '%s'\n", printername); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } pscreen = XpGetScreenOfContext(pdpy, pcontext); } else { pdpy = XOpenDisplay(NULL); if( !pdpy ) Error(("XOpenDisplay failure.\n")); - dpi = 0; + dpi_x = dpi_y = 0L; pscreen = XDefaultScreenOfDisplay(pdpy); } toplevel = XawOpenApplication(&app, pdpy, pscreen, "xpawprintshelldemo", "XpXawPrintShellDemo", applicationShellWidgetClass, &argc, argv); if( !toplevel ) Error(("XawOpenApplication failure.\n")); if( doPrint ) { n = 0; /* Override any geometry resource settings as XawPrintShell adjusts it's size * to the current page siue when |XawPrintLAYOUTMODE_DRAWABLEAREA| or * |XawPrintLAYOUTMODE_PAGESIZE| are used. */ XtSetArg(args[n], XtNgeometry, "+0+0"); n++; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; print_shell = XtCreatePopupShell("myprintshell", xawPrintShellWidgetClass, toplevel, args, n); /* we're mapping/unmapping at start/end page time */ XtSetMappedWhenManaged(print_shell, False); shell = print_shell; } else { shell = toplevel; } - sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); if( !textFont ) { - sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); } if( !textFont ) Error(("XLoadQueryFont failure.\n")); textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); n = 0; /* Make sure the cursor is off, current Xprt servers do not seem to like * blinking cursors that much... ;-/ */ XtSetArg(args[n], XmNcursorPositionVisible, False); n++; XtSetArg(args[n], XmNvalue, sample_string); n++; XtSetArg(args[n], XmNfontList, textFontList); n++; XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; hello = XmCreateText(shell, "mytext", args, n); if( !hello ) Error(("XmCreateText failure.\n")); XtManageChild(hello); XtRealizeWidget(toplevel); Index: xc/programs/xphelloworld/xphelloworld/xphelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xphelloworld/xphelloworld.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xphelloworld.c --- xc/programs/xphelloworld/xphelloworld/xphelloworld.c 23 Apr 2004 19:55:00 -0000 1.2 +++ xc/programs/xphelloworld/xphelloworld/xphelloworld.c 3 Jan 2005 00:56:43 -0000 @@ -148,41 +148,41 @@ XWhitePixel(context->pdpy, context->pscreennumber)); gcvalues.background = XWhitePixel(context->pdpy, context->pscreennumber); gcvalues.foreground = XBlackPixel(context->pdpy, context->pscreennumber); pgc = XCreateGC(context->pdpy, pwin, GCBackground|GCForeground, &gcvalues); Log(("start page.\n")); XpauStartPage(context, pwin); XpauWaitForPrintNotify(context, XPStartPageNotify); /* Mapping the window inside XpStartPage()/XpEndPage() * Set XCreateWindow/border_width to 0 or move XMapWindow in front of * XpStartPage() to get rid of the surrounding black border lines. * (This is usually done before XpStartPage() in real applications) */ XMapWindow(context->pdpy, pwin); /* usual rendering stuff..... */ - sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", context->document_dpi, context->document_dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", context->document_dpi_x, context->document_dpi_y); font = XLoadQueryFont(context->pdpy, fontname); XSetFont(context->pdpy, pgc, font->fid); if (!hello_world_message) hello_world_message = "hello world from X11 print system"; XDrawString(context->pdpy, pwin, pgc, 100, 100, hello_world_message, strlen(hello_world_message)); XpauEndPage(context); XpauWaitForPrintNotify(context, XPEndPageNotify); Log(("end page.\n")); Log(("end job.\n")); if( (result = XpauEndJob(context)) != XpAuError_success ) { fprintf(stderr, "%s: Error while printing: %s.\n", ProgramName, XpAuErrorValueToString(result)); XpauReleaseContext(context); return(EXIT_FAILURE); } Index: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpsimplehelloworld.c --- xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 23 Apr 2004 19:55:00 -0000 1.2 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 3 Jan 2005 00:56:44 -0000 @@ -70,41 +70,42 @@ { do { if ((sc = tolower(*s++)) == '\0') return NULL; } while (sc != c); } while (strncasecmp(s, find, len) != 0); s--; } return ((char *)s); } static int do_hello_world(const char *printername, const char *printerfile, const char *psembeddata ) { Display *pdpy; /* X connection */ XPContext pcontext; /* Xprint context */ void *printtofile_handle; /* "context" when printing to file */ int xp_event_base, /* XpExtension even base */ xp_error_base; /* XpExtension error base */ - long dpi; + long dpi_x = 0L, + dpi_y = 0L; Screen *pscreen; int pscreennumber; Window pwin; XGCValues gcvalues; XEvent ev; GC pgc; unsigned short dummy; XRectangle winrect; char fontname[256]; /* BUG: is this really big enougth ? */ XFontStruct *font; if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) { fprintf(stderr, "Cannot open printer '%s'\n", printername); return(EXIT_FAILURE); } if( XpQueryExtension(pdpy, &xp_event_base, &xp_error_base) == False ) { fprintf(stderr, "XpQueryExtension() failed.\n"); @@ -114,41 +115,41 @@ /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). * This is mantatory 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(pdpy, pcontext, XPPrintMask); /* Set job title */ XpuSetJobTitle(pdpy, pcontext, "Hello world 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(pdpy, pcontext); /* Get default printer reolution */ - if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) { fprintf(stderr, "No default resolution for printer '%s'.\n", printername); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } if( printerfile ) { Log(("starting job (to file '%s').\n", printerfile)); printtofile_handle = XpuStartJobToFile(pdpy, pcontext, printerfile); if( !printtofile_handle ) { fprintf(stderr, "%s: Error: %s while trying to print to file.\n", ProgramName, strerror(errno)); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); } @@ -182,41 +183,41 @@ XWhitePixel(pdpy, pscreennumber)); gcvalues.background = XWhitePixel(pdpy, pscreennumber); gcvalues.foreground = XBlackPixel(pdpy, pscreennumber); pgc = XCreateGC(pdpy, pwin, GCBackground|GCForeground, &gcvalues); Log(("start page.\n")); XpStartPage(pdpy, pwin); XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartPageNotify); /* Mapping the window inside XpStartPage()/XpEndPage() * Set XCreateWindow/border_width to 0 or move XMapWindow in front of * XpStartPage() to get rid of the surrounding black border lines. * (This is usually done before XpStartPage() in real applications) */ XMapWindow(pdpy, pwin); /* usual rendering stuff..... */ - sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); font = XLoadQueryFont(pdpy, fontname); XSetFont(pdpy, pgc, font->fid); XDrawString(pdpy, pwin, pgc, 100, 100, "hello world from X11 print system", 33); #define DO_EMBED_TEST 1 #ifdef DO_EMBED_TEST if( psembeddata ) { char *embedded_formats_supported; embedded_formats_supported = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-embedded-formats-supported"); Log(("psembed: xp-embedded-formats-supported='%s'\n", NULLSTR(embedded_formats_supported))); /* MAX(XExtendedMaxRequestSize(pdpy), XMaxRequestSize(pdpy)) defines the * maximum length of emebdded PostScript data which can be send in one * step using XpPutDocumentData() */ Log(("psembed: XExtendedMaxRequestSize=%ld\n", (long)XExtendedMaxRequestSize(pdpy))); Log(("psembed: XMaxRequestSize=%ld\n", (long)XMaxRequestSize(pdpy))); Index: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpxmhelloworld.c --- xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c 23 Apr 2004 19:55:02 -0000 1.2 +++ xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c 3 Jan 2005 00:56:44 -0000 @@ -252,115 +252,116 @@ static void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) { MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; Log(("--> PrintEndJobCB\n")); /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ XtAppSetExitFlag(mpcd->appcontext); } int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) { XtAppContext app; Widget toplevel, shell, print_shell, hello; - long dpi; + long dpi_x = 0L, + dpi_y = 0L; char fontname[256]; /* BUG: is this really big enougth ? */ XFontStruct *textFont; XmFontList textFontList; Cardinal n; Arg args[10]; MyPrintCallbackData mpcd; if( doPrint ) { /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) Error(("XpuGetPrinter failure.\n")); /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XmPrintShell widget demo"); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) { fprintf(stderr, "No default resolution for printer '%s'\n", printername); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } pscreen = XpGetScreenOfContext(pdpy, pcontext); } else { pdpy = XOpenDisplay(NULL); if( !pdpy ) Error(("XOpenDisplay failure.\n")); - dpi = 0; + dpi_x = dpi_y = 0L; pscreen = XDefaultScreenOfDisplay(pdpy); } toplevel = xt_xp_openapplication(&app, pdpy, pscreen, "xpxmprintshelldemo", "XpXmPrintShellDemo", applicationShellWidgetClass, &argc, argv); if( !toplevel ) Error(("xt_xp_openapplication failure.\n")); if( doPrint ) { n = 0; print_shell = XtCreatePopupShell("myprintshell", xmPrintShellWidgetClass, toplevel, args, n); /* we're mapping/unmapping at start/end page time */ XtSetMappedWhenManaged(print_shell, False); shell = print_shell; } else { shell = toplevel; } - sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); if( !textFont ) { - sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); textFont = XLoadQueryFont(pdpy, fontname); } if( !textFont ) Error(("XLoadQueryFont failure.\n")); textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); n = 0; /* Make sure the cursor is off, current Xprt servers do not seem to like * blinking cursors that much... ;-/ */ XtSetArg(args[n], XmNcursorPositionVisible, False); n++; XtSetArg(args[n], XmNvalue, sample_string); n++; XtSetArg(args[n], XmNfontList, textFontList); n++; XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; hello = XmCreateText(shell, "mytext", args, n); if( !hello ) Error(("XmCreateText failure.\n")); XtManageChild(hello); XtRealizeWidget(toplevel); Index: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xpxthelloworld.c --- xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c 23 Apr 2004 19:55:03 -0000 1.2 +++ xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c 3 Jan 2005 00:56:44 -0000 @@ -258,97 +258,98 @@ application_name, application_class, NULL, 0, argc, argv); n = 0; XtSetArg(args[n], XtNscreen, screen); n++; toplevel = XtAppCreateShell(application_name, application_class, widget_class, dpy, args, n); return toplevel; } int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile ) { XtAppContext app; Widget toplevel, hello; - long dpi; + long dpi_x = 0L, + dpi_y = 0L; char fontname[256]; /* BUG: is this really big enougth ? */ XFontStruct *labelFont; Cardinal n; Arg args[10]; if( doPrint ) { /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) Error(("XpuGetPrinter failure.\n")); if( XpQueryExtension(pdpy, &xp_eventbase, &xp_errorbase) == False ) Error(("XpQueryExtension failure.\n")); XpSelectInput(pdpy, pcontext, XPPrintMask); /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, "Simple Xprint Athena widget demo"); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ - if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + if( XpuGetResolution(pdpy, pcontext, &dpi_x, &dpi_y) != 1 ) { fprintf(stderr, "No default resolution for printer '%s'\n", printername); XpuClosePrinterDisplay(pdpy, pcontext); return(EXIT_FAILURE); } pscreen = XpGetScreenOfContext(pdpy, pcontext); } else { pdpy = XOpenDisplay(NULL); if( !pdpy ) Error(("XOpenDisplay failure.\n")); - dpi = 0; + dpi_x = dpi_y = 0L; pscreen = XDefaultScreenOfDisplay(pdpy); } toplevel = xt_xp_openapplication(&app, pdpy, pscreen, "xpxtawhenademo", "XpXtAthenaDemo", applicationShellWidgetClass, &argc, argv); if( !toplevel ) Error(("xt_xp_openapplication failure.\n")); - sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi, dpi); + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi_x, dpi_y); labelFont = XLoadQueryFont(pdpy, fontname); if( !labelFont ) Error(("XLoadQueryFont failure.\n")); n = 0; XtSetArg(args[n], XtNlabel, "Hello world\n" "(Xprint/Athena widget version)"); n++; XtSetArg(args[n], XtNfont, labelFont); n++; hello = XtCreateManagedWidget( "hello", /* arbitrary widget name */ labelWidgetClass, /* widget class from Label.h */ toplevel, /* parent widget*/ args, /* argument list */ n /* arg list size */ ); if( !hello ) Error(("XtCreateManagedWidget failure.\n")); XtRealizeWidget(toplevel); Index: xc/programs/xplsprinters/xplsprinters.c =================================================================== RCS file: /cvs/xorg/xc/programs/xplsprinters/xplsprinters.c,v retrieving revision 1.3 diff -u -2 -0 -r1.3 xplsprinters.c --- xc/programs/xplsprinters/xplsprinters.c 14 Jun 2004 06:47:31 -0000 1.3 +++ xc/programs/xplsprinters/xplsprinters.c 3 Jan 2005 00:56:44 -0000 @@ -98,61 +98,72 @@ { printf("\tmedium-source-sizes-supported=%s/%s %s %g %g %g %g\n", curr->tray_name, curr->medium_name, BOOL2STR(curr->mbool), curr->ma1, curr->ma2, curr->ma3, curr->ma4); } else { printf("\tmedium-source-sizes-supported=%s %s %g %g %g %g\n", curr->medium_name, BOOL2STR(curr->mbool), curr->ma1, curr->ma2, curr->ma3, curr->ma4); } } XpuFreeMediumSourceSizeList(list); } static void print_resolutions( Display *pdpy, XPContext pcontext ) { - long dpi; XpuResolutionList list; int list_count; int i; - - if( XpuGetResolution(pdpy, pcontext, &dpi) == 1 ) - { - printf("\tdefault-printer-resolution=%ld\n", dpi); - } + char *defresname; /* name of default resolution */ list = XpuGetResolutionList(pdpy, pcontext, &list_count); if( !list ) { fprintf(stderr, "XpuGetResolutionList returned NULL\n"); return; } + defresname = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution"); + if( defresname ) + { + XpuResolutionRec *res = XpuFindResolutionByName(list, list_count, defresname); + if( res ) + { + printf("\tdefault-printer-resolution=%s (%ldx%ld)\n", res->name, res->x_dpi, res->y_dpi); + } + else + { + fprintf(stderr, "XpuFindResolutionByName() returned no match for default resolution '%s'\n", + defresname); + } + XFree(defresname); + } + for( i = 0 ; i < list_count ; i++ ) { XpuResolutionRec *curr = &list[i]; - printf("\tresolution=%ld\n", curr->dpi); + printf("\tresolution=%s (%ldx%ld)\n", curr->name, curr->x_dpi, curr->y_dpi); } XpuFreeResolutionList(list); } static void print_orientations( Display *pdpy, XPContext pcontext ) { char *default_orientation; XpuOrientationList list; int list_count; int i; default_orientation = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "content-orientation"); if( default_orientation ) { printf("\tdefault_orientation=%s\n", default_orientation); XFree(default_orientation); } @@ -219,44 +230,40 @@ } printf("printer: %s\n", xp_rec->name); printf("\tdescription=%s\n", NULLSTR(xp_rec->desc)); printf("\tmodel-identifier=%s\n", NULLSTR(XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-model-identifier"))); print_medium_sizes(pdpy, pcontext); print_resolutions(pdpy, pcontext); print_orientations(pdpy, pcontext); print_plexes(pdpy, pcontext); if (detailLevel > 100) dumpAttributes(pdpy, pcontext); XpuClosePrinterDisplay(pdpy, pcontext); } static void print_printer_info(XPPrinterRec *xp_rec, int detailLevel) { - Display *pdpy; /* X connection */ - XPContext pcontext; /* Xprint context */ - long dpi; - printf("printer: %s\n", xp_rec->name); if( detailLevel < 1 ) return; printf("\tdescription=%s\n", NULLSTR(xp_rec->desc)); } int main (int argc, char *argv[]) { char *printername = NULL; /* printer to query */ int details = 0; Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */ int i; /* temp variable: iterator */ XPPrinterList plist; /* list of printers */ int plist_count; /* number of entries in |plist|-array */ ProgramName = argv[0];