]> git.eshelyaron.com Git - emacs.git/commitdiff
(x_alloc_nearest_color): If allocation succeeds, and
authorGerd Moellmann <gerd@gnu.org>
Mon, 30 Oct 2000 15:13:58 +0000 (15:13 +0000)
committerGerd Moellmann <gerd@gnu.org>
Mon, 30 Oct 2000 15:13:58 +0000 (15:13 +0000)
we have a color cache, check that the cached color equals the
allocated color.  If not, clear the color cache.

src/ChangeLog
src/xterm.c

index 484f1c50d5620f700a9c91a1104fb476f6ca145d..0e880dbc0b6d4e1b4e7402e64d10b130f1333ba2 100644 (file)
@@ -1,5 +1,9 @@
 2000-10-30  Gerd Moellmann  <gerd@gnu.org>
 
+       * xterm.c (x_alloc_nearest_color): If allocation succeeds, and
+       we have a color cache, check that the cached color equals the
+       allocated color.  If not, clear the color cache.
+
        * window.c (displayed_window_lines): Change buffers if necessary.
        Fix computation of displayed lines.
 
index a55117ba8dc0427d4cba1bb960b8f7a38499de86..556611286bc2fc2a2c6fcf2ea39c1332512a4839 100644 (file)
@@ -3412,6 +3412,23 @@ x_alloc_nearest_color (f, cmap, color)
       color->blue  = cells[nearest].blue;
       rc = XAllocColor (display, cmap, color);
     }
+  else
+    {
+      /* If allocation succeeded, and the allocated pixel color is not
+         equal to a cached pixel color recorded earlier, there was a
+         change in the colormap, so clear the color cache.  */
+      struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+      XColor *cached_color;
+      
+      if (dpyinfo->color_cells
+         && (cached_color = &dpyinfo->color_cells[color->pixel],
+             cached_color->pixel != color->pixel))
+       {
+         xfree (dpyinfo->color_cells);
+         dpyinfo->color_cells = NULL;
+         dpyinfo->ncolor_cells = 0;
+       }
+    }
 
 #ifdef DEBUG_X_COLORS
   if (rc)