don't override color settings from print dialog

This commit is contained in:
Zdenek Dohnal 2023-03-02 17:18:45 +01:00
parent 787f4a35bc
commit 28783553c6
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,85 @@
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

View File

@ -73,6 +73,7 @@ Patch100: cups-lspp.patch
Patch1001: 0001-scheduler-ipp.c-Allocate-device_uri-via-cupsdSetStri.patch Patch1001: 0001-scheduler-ipp.c-Allocate-device_uri-via-cupsdSetStri.patch
Patch1002: cups-resolve-local.patch Patch1002: cups-resolve-local.patch
Patch1003: cups-ippeveprinter-typo.patch Patch1003: cups-ippeveprinter-typo.patch
Patch1004: 0001-Don-t-override-color-settings-from-print-dialog.patch
##### Patches removed because IMHO they aren't no longer needed ##### Patches removed because IMHO they aren't no longer needed
##### but still I'll leave them in git in case their removal ##### but still I'll leave them in git in case their removal
@ -289,6 +290,7 @@ to CUPS daemon. This solution will substitute printer drivers and raw queues in
%patch1002 -p1 -b .localhost %patch1002 -p1 -b .localhost
# https://github.com/OpenPrinting/cups/pull/629 # https://github.com/OpenPrinting/cups/pull/629
%patch1003 -p1 -b .ippeveprinter-typo %patch1003 -p1 -b .ippeveprinter-typo
%patch1004 -p1 -b .no_color_override
%if %{lspp} %if %{lspp}
@ -697,6 +699,7 @@ rm -f %{cups_serverbin}/backend/smb
%changelog %changelog
* Thu Mar 02 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.2-10 * Thu Mar 02 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.2-10
- fix loading ippeveps in ippeveprinter if only the command name is provided - fix loading ippeveps in ippeveprinter if only the command name is provided
- don't override color settings from print dialog
* Mon Feb 20 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.2-9 * Mon Feb 20 2023 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.4.2-9
- move /etc/cups into cups-filesystem, since cups-browsed needs it - move /etc/cups into cups-filesystem, since cups-browsed needs it