? gdk/gdkdisplay.c
? gdk/gdkdisplay.h
? gdk/gdkdisplaymgr.c
? gdk/gdkdisplaymgr.h
? gdk/gdkscreen.c
? gdk/gdkscreen.h
? gdk/x11/gdkdisplay-x11.c
? gdk/x11/gdkdisplay-x11.h
? gdk/x11/gdkdisplaymgr-x11.c
? gdk/x11/gdkdisplaymgr-x11.h
? gdk/x11/gdkscreen-x11.c
? gdk/x11/gdkscreen-x11.h
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.3338.2.108
diff -u -p -r1.3338.2.108 ChangeLog
--- ChangeLog	13 Jun 2002 22:06:14 -0000	1.3338.2.108
+++ ChangeLog	13 Jun 2002 22:47:02 -0000
@@ -1,3 +1,11 @@
+Thu Jun 13 18:48:14 2002  Owen Taylor  <otaylor@redhat.com>
+
+ 	* gdk/x11/gdkcolor-x11.c: Make work
+	gdk_colormap_sync() work for DirectColor visuals 
+	as well. Fill in the ->colors array in
+	gdk_screen_get_system_colormap () for DirectColor visuals.
+	(#81954, Based on a patch from shivaram.upadhyayula@wipro.com)
+ 
 Thu Jun 13 17:50:36 2002  Owen Taylor  <otaylor@redhat.com>
 
 	* gtk/gtktextview.c gtk/gtkentry.c: Add the obsolete
Index: gdk/x11/gdkcolor-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkcolor-x11.c,v
retrieving revision 1.35
diff -u -p -r1.35 gdkcolor-x11.c
--- gdk/x11/gdkcolor-x11.c	5 Nov 2001 00:23:45 -0000	1.35
+++ gdk/x11/gdkcolor-x11.c	13 Jun 2002 22:47:02 -0000
@@ -248,25 +248,13 @@ gdk_colormap_new (GdkVisual *visual,
   return colormap;
 }
 
-#define MIN_SYNC_TIME 2
-
 static void
-gdk_colormap_sync (GdkColormap *colormap,
-		   gboolean     force)
+gdk_colormap_sync_palette (GdkColormap *colormap)
 {
-  time_t current_time;
   GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
   XColor *xpalette;
   gint nlookup;
   gint i;
-  
-  g_return_if_fail (GDK_IS_COLORMAP (colormap));
-
-  current_time = time (NULL);
-  if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
-    return;
-
-  private->last_sync_time = current_time;
 
   nlookup = 0;
   xpalette = g_new (XColor, colormap->size);
@@ -296,6 +284,60 @@ gdk_colormap_sync (GdkColormap *colormap
   
   g_free (xpalette);
 }
+
+static void
+gdk_colormap_sync_direct_color (GdkColormap *colormap)
+{
+  GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+  GdkVisual *visual = colormap->visual;
+  XColor *xpalette;
+  gint i;
+
+  xpalette = g_new (XColor, colormap->size);
+  
+  for (i = 0; i < colormap->size; i++)
+    {
+      xpalette[i].pixel =
+	(((i << visual->red_shift)   & visual->red_mask)   |
+	 ((i << visual->green_shift) & visual->green_mask) |
+	 ((i << visual->blue_shift)  & visual->blue_mask));
+    }
+
+  XQueryColors (gdk_display, private->xcolormap, xpalette, colormap->size);
+  
+  for (i = 0; i < colormap->size; i++)
+    {
+      colormap->colors[i].pixel = xpalette[i].pixel;
+      colormap->colors[i].red = xpalette[i].red;
+      colormap->colors[i].green = xpalette[i].green;
+      colormap->colors[i].blue = xpalette[i].blue;
+    }
+  
+  g_free (xpalette);
+}
+
+#define MIN_SYNC_TIME 2
+
+static void
+gdk_colormap_sync (GdkColormap *colormap,
+		   gboolean     force)
+{
+  time_t current_time;
+  GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
+  
+  g_return_if_fail (GDK_IS_COLORMAP (colormap));
+
+  current_time = time (NULL);
+  if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
+    return;
+
+  private->last_sync_time = current_time;
+
+  if (colormap->visual->type == GDK_VISUAL_DIRECT_COLOR)
+    gdk_colormap_sync_direct_color (colormap);
+  else
+    gdk_colormap_sync_palette (colormap);
+}
 		   
 
 GdkColormap*
@@ -331,10 +373,10 @@ gdk_colormap_get_system (void)
 	  /* Fall through */
 	case GDK_VISUAL_STATIC_GRAY:
 	case GDK_VISUAL_STATIC_COLOR:
+	case GDK_VISUAL_DIRECT_COLOR:
 	  colormap->colors = g_new (GdkColor, colormap->size);
 	  gdk_colormap_sync (colormap, TRUE);
 	  
-	case GDK_VISUAL_DIRECT_COLOR:
 	case GDK_VISUAL_TRUE_COLOR:
 	  break;
 	}
