Index: gtk+/ChangeLog
===================================================================
RCS file: /export/cvs/gnome-2.0/gtk+/ChangeLog,v
retrieving revision 1.53
diff -p -u -5 -r1.53 ChangeLog
--- gtk+/ChangeLog	2002/05/13 10:22:20	1.53
+++ gtk+/ChangeLog	2002/05/16 10:22:37
@@ -1,5 +1,11 @@
+Thu May 16 16:19:47  Shivram U  <shivaram.upadhyayula@wipro.com>
+
+	* gdk/x11/gdkcolor-x11.c (gdk_colormap_sync): Fill up the colors array
+	for DirectColor visual class too. (gdk_screen_get_system_colormap): 
+	Calling gdk_colormap_sync() for DirectColor Visual class also.
+
 2002-05-10  Daniel Elstner  <daniel.elstner@gmx.net>
 
 	[ merge from stable ]
 
 	* gtk/gtktreemodel.c: #define INITIALIZE_TREE_ITER(),
Index: gtk+/gdk/x11/gdkcolor-x11.c
===================================================================
RCS file: /export/cvs/gnome-2.0/gtk+/gdk/x11/gdkcolor-x11.c,v
retrieving revision 1.2
diff -p -u -5 -r1.2 gdkcolor-x11.c
--- gtk+/gdk/x11/gdkcolor-x11.c	2002/04/26 21:23:54	1.2
+++ gtk+/gdk/x11/gdkcolor-x11.c	2002/05/16 10:14:49
@@ -255,19 +255,23 @@ gdk_colormap_new (GdkVisual *visual,
   return colormap;
 }
 
 #define MIN_SYNC_TIME 2
 
+#define LOWBIT(x) ((x) & (~(x) + 1))
+
 static void
 gdk_colormap_sync (GdkColormap *colormap,
 		   gboolean     force)
 {
   time_t current_time;
   GdkColormapPrivateX11 *private = GDK_COLORMAP_PRIVATE_DATA (colormap);
   XColor *xpalette;
   gint nlookup;
   gint i;
+  unsigned short red, green, blue, red1, green1, blue1;
+  Visual *xvisual;
   
   g_return_if_fail (GDK_IS_COLORMAP (colormap));
 
   current_time = time (NULL);
   if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
@@ -275,34 +279,75 @@ gdk_colormap_sync (GdkColormap *colormap
 
   private->last_sync_time = current_time;
 
   nlookup = 0;
   xpalette = g_new (XColor, colormap->size);
-  
-  for (i = 0; i < colormap->size; i++)
-    {
-      if (!private->info || private->info[i].ref_count == 0)
-	{
-	  xpalette[nlookup].pixel = i;
-	  xpalette[nlookup].red = 0;
-	  xpalette[nlookup].green = 0;
-	  xpalette[nlookup].blue = 0;
-	  nlookup++;
-	}
+
+  switch (colormap->visual->type ) {
+    case GDK_VISUAL_GRAYSCALE:
+    case GDK_VISUAL_PSEUDO_COLOR:
+    case GDK_VISUAL_STATIC_GRAY:
+    case GDK_VISUAL_STATIC_COLOR:
+      for (i = 0; i < colormap->size; i++)
+      {
+        if (!private->info || private->info[i].ref_count == 0)
+        {
+          xpalette[nlookup].pixel = i;
+          xpalette[nlookup].red = 0;
+          xpalette[nlookup].green = 0;
+          xpalette[nlookup].blue = 0;
+          nlookup++;
+        }
+      }
+      break;
+    case GDK_VISUAL_DIRECT_COLOR:
+    case GDK_VISUAL_TRUE_COLOR:
+      xvisual = ((GdkVisualPrivate*) colormap->visual)->xvisual;
+      nlookup = xvisual->map_entries;
+
+      red = green = blue = 0;
+      red1 = LOWBIT (xvisual->red_mask);
+      green1 = LOWBIT (xvisual->green_mask);
+      blue1 = LOWBIT (xvisual->blue_mask);
+
+      for (i=0; i<nlookup; i++)
+      {
+        xpalette[i].pixel = red|green|blue;
+        xpalette[i].pad = 0;
+        red += red1;
+        if (red > xvisual->red_mask)
+          red = 0;
+          green += green1;
+        if (green > xvisual->green_mask)
+          green = 0;
+          blue += blue1;
+        if (blue > xvisual->blue_mask)
+          blue = 0;
+      }
     }
-  
+
   XQueryColors (GDK_SCREEN_XDISPLAY (colormap->screen),
 		private->xcolormap, xpalette, nlookup);
   
   for (i = 0; i < nlookup; i++)
+  {
+    gulong pixel = xpalette[i].pixel;
+    if ((colormap->visual->type != GDK_VISUAL_DIRECT_COLOR) && (colormap->visual->type != GDK_VISUAL_TRUE_COLOR))
     {
-      gulong pixel = xpalette[i].pixel;
       colormap->colors[pixel].pixel = pixel;
       colormap->colors[pixel].red = xpalette[i].red;
       colormap->colors[pixel].green = xpalette[i].green;
       colormap->colors[pixel].blue = xpalette[i].blue;
     }
+    else
+    {
+      colormap->colors[i].pixel = 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);
 }
 		   
 /**
@@ -350,14 +395,14 @@ gdk_screen_get_system_colormap (GdkScree
       private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
 					(GEqualFunc) gdk_color_equal);
       /* 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;
     }
   
   gdk_colormap_add (colormap);
