Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround

From: Juanma Barranquero <[email-masked]>
Date: Thu, 29 Dec 2011 17:13:25 +0100

On Thu, Dec 29, 2011 at 15:05, Daniel Colascione <[email-masked]> wrote:

> The workaround
> seems harmless: on non-palettized displays, calculating the number of
> display colors based on display bitness should produce good results.

Even so, why fix what is not broken? Why can't you just do

=== modified file 'src/w32fns.c'
--- src/w32fns.c	2011-12-04 08:02:42 +0000
+++ src/w32fns.c	2011-12-29 16:10:33 +0000
@@ -4511,5 +4511,12 @@
     cap = GetDeviceCaps (hdc, SIZEPALETTE);
   else
-    cap = GetDeviceCaps (hdc, NUMCOLORS);
+    {
+      cap = GetDeviceCaps (hdc, NUMCOLORS);
+      /* GetDeviceCaps (NUMCOLORS) is buggy under remote desktop and
+         sometimes returns the number of system reserved colors (20)
+         instead of the actual number of available colors.  */
+      if (cap == 20)
+        cap = -1;
+    }

   /* We force 24+ bit depths to 24-bit, both to prevent an overflow

> +    // GetDeviceCaps (NUMCOLORS) is buggy under remote desktop and sometimes
> +    // returns the number of system reserved colors (20) instead of
> +    // the actual number of available colors.

Please, don't use "C++ / modern C" style comments; use /* */ instead.

    Juanma