From: Zdenek Dohnal Date: Mon, 20 Jun 2022 16:17:58 +0000 (+0200) Subject: Don't override color settings from print dialog X-Git-Tag: v2.4.3~168^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F417%2Fhead;p=thirdparty%2Fcups.git Don't override color settings from print dialog When we put print-color-mode as a default attribute, it always overrides settings from print dialog. We need to respect those settings and transform the known PPD options into print-color-mode options. --- diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index 886181319f..f72d834f5d 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -259,15 +259,46 @@ _cupsConvertOptions( color_attr_name = print_color_mode_sup ? "print-color-mode" : "output-mode"; - if ((keyword = cupsGetOption("print-color-mode", num_options, options)) == NULL) + /* + * If we use PPD with standardized PPD option for color support - ColorModel, + * prefer it to don't break color/grayscale support for PPDs, either classic + * or the ones generated from IPP Get-Printer-Attributes response. + */ + + if ((keyword = cupsGetOption("ColorModel", num_options, options)) == NULL) { + /* + * No ColorModel in options... + */ + if ((choice = ppdFindMarkedChoice(ppd, "ColorModel")) != NULL) { - if (!_cups_strcasecmp(choice->choice, "Gray")) - keyword = "monochrome"; + /* + * ColorModel is taken from PPD as its default option. + */ + + if (!strcmp(choice->choice, "Gray") || !strcmp(choice->choice, "FastGray") || !strcmp(choice->choice, "DeviceGray")) + keyword = "monochrome"; else - keyword = "color"; + keyword = "color"; } + else + /* + * print-color-mode is a default option since 2.4.1, use it as a fallback if there is no + * ColorModel in options or PPD... + */ + keyword = cupsGetOption("print-color-mode", num_options, options); + } + else + { + /* + * ColorModel found in options... + */ + + if (!strcmp(keyword, "Gray") || !strcmp(keyword, "FastGray") || !strcmp(keyword, "DeviceGray")) + keyword = "monochrome"; + else + keyword = "color"; } if (keyword && !strcmp(keyword, "monochrome")) diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 56bd8b3049..3a849bdb51 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2937,6 +2937,9 @@ apply_printer_defaults( if (!strcmp(option->name, "print-quality") && ippFindAttribute(job->attrs, "cupsPrintQuality", IPP_TAG_NAME)) continue; /* Don't override cupsPrintQuality */ + if (!strcmp(option->name, "print-color-mode") && ippFindAttribute(job->attrs, "ColorModel", IPP_TAG_NAME)) + continue; /* Don't override ColorModel */ + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Adding default %s=%s", option->name, option->value); num_options = cupsAddOption(option->name, option->value, num_options, &options);