changeset 14615:1bbe2716bcea

(defined_color): When we find a "near" color in the map, make sure it is really available as a read-only color.
author Karl Heuer <kwzh@gnu.org>
date Wed, 21 Feb 1996 21:10:28 +0000
parents 8fda783ead43
children 051d6225ca90
files src/xfns.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Wed Feb 21 21:09:52 1996 +0000
+++ b/src/xfns.c	Wed Feb 21 21:10:28 1996 +0000
@@ -1111,8 +1111,16 @@
 			      * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
 	      if (trial_delta < nearest_delta) 
 		{
-		  nearest = x;
-		  nearest_delta = trial_delta;
+		  XColor temp;
+		  temp.red = cells[x].red;
+		  temp.green = cells[x].green;
+		  temp.blue = cells[x].blue;
+		  status = XAllocColor (display, screen_colormap, &temp);
+		  if (status)
+		    {
+		      nearest = x;
+		      nearest_delta = trial_delta;
+		    }
 		}
 	    }
 	  color_def->red = cells[nearest].red;