cups/0001-Don-t-override-color-s...

86 lines
3.0 KiB
Diff

From b0f1a00a02e9f92f8a3c42ec90806ba4e4e532ec Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Mon, 20 Jun 2022 18:17:58 +0200
Subject: [PATCH] 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.
---
cups/ppd-cache.c | 39 +++++++++++++++++++++++++++++++++++----
scheduler/ipp.c | 3 +++
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c
index 886181319..f72d834f5 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 56bd8b304..3a849bdb5 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);
--
2.39.2