]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Don't override color settings from print dialog 417/head
authorZdenek Dohnal <zdohnal@redhat.com>
Mon, 20 Jun 2022 16:17:58 +0000 (18:17 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Mon, 20 Jun 2022 16:17:58 +0000 (18:17 +0200)
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
scheduler/ipp.c

index 886181319f192a4417aadd0067493b140104a7dd..f72d834f5d5213d1df2c57b558a687b7d82a0197 100644 (file)
@@ -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"))
index 56bd8b30498fedfc70895736fbc8f008b3f3e205..3a849bdb513a43600127ae8e87360b92d1241404 100644 (file)
@@ -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);