Index: gdk/win32/gdkdrawable-win32.c
===================================================================
--- gdk/win32/gdkdrawable-win32.c	(revision 19984)
+++ gdk/win32/gdkdrawable-win32.c	(working copy)
@@ -1578,7 +1578,6 @@
 		  gint         	      	height)
 {
   HDC srcdc;
-  HPALETTE holdpal = NULL;
   GdkColormap *cmap = gdk_colormap_get_system ();
 
   GDK_NOTE (DRAW, g_print ("blit_from_window\n"));
@@ -1589,26 +1588,9 @@
       return;
     }
 
-  if (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
-      cmap->visual->type == GDK_VISUAL_STATIC_COLOR)
-    {
-      gint k;
-      
-      if (!(holdpal = SelectPalette (srcdc, GDK_WIN32_COLORMAP_DATA (cmap)->hpal, FALSE)))
-	WIN32_GDI_FAILED ("SelectPalette");
-      else if ((k = RealizePalette (srcdc)) == GDI_ERROR)
-	WIN32_GDI_FAILED ("RealizePalette");
-      else if (k > 0)
-	GDK_NOTE (MISC_OR_COLORMAP,
-		  g_print ("blit_from_window: realized %d\n", k));
-    }
-  
   GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
 		     srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
   
-  if (holdpal != NULL)
-    GDI_CALL (SelectPalette, (srcdc, holdpal, FALSE));
-  
   GDI_CALL (ReleaseDC, (src->handle, srcdc));
 }
 
Index: gdk/win32/gdkvisual-win32.c
===================================================================
--- gdk/win32/gdkvisual-win32.c	(revision 19984)
+++ gdk/win32/gdkvisual-win32.c	(working copy)
@@ -106,82 +106,9 @@
   GDK_NOTE (COLORMAP, g_print ("BITSPIXEL=%d NUMCOLORS=%d\n",
 			       bitspixel, numcolors));
 
-  if (rastercaps & RC_PALETTE)
+  if (bitspixel == 16)
     {
-      const int sizepalette = GetDeviceCaps (_gdk_display_hdc, SIZEPALETTE);
-      gchar *max_colors = getenv ("GDK_WIN32_MAX_COLORS");
-      system_visual->type = GDK_VISUAL_PSEUDO_COLOR;
-
-      GDK_NOTE (COLORMAP, g_print ("SIZEPALETTE=%d\n", sizepalette));
-      g_assert (sizepalette == 256);
-
-      if (max_colors != NULL)
-	_gdk_max_colors = atoi (max_colors);
-      
-      map_entries = _gdk_max_colors;
-
-      if (map_entries >= 16 && map_entries < sizepalette)
-	{
-	  /* The calls to gdk_rgb_set_min_colors() here have knowledge
-	   * of what color cubes gdk_rgb_do_colormaps() will try, and
-	   * of the static system palette colors... XXX
-	   */
-	  if (map_entries < 32)
-	    {
-	      map_entries = 16;
-	      system_visual->type = GDK_VISUAL_STATIC_COLOR;
-	      bitspixel = 4;
-	      gdk_rgb_set_min_colors (2*2*2);
-	    }
-	  else if (map_entries < 64)
-	    {
-	      map_entries = 32;
-	      bitspixel = 5;
-	      gdk_rgb_set_min_colors (3*3*3);
-	    }
-	  else if (map_entries < 128)
-	    {
-	      map_entries = 64;
-	      bitspixel = 6;
-	      gdk_rgb_set_min_colors (3*3*3);
-	    }
-	  else if (map_entries < 256)
-	    {
-	      map_entries = 128;
-	      bitspixel = 7;
-	      gdk_rgb_set_min_colors (5*5*4);
-	    }
-	  else
-	    g_assert_not_reached ();
-	}
-      else
-	map_entries = sizepalette;
-    }
-  else if (bitspixel == 1 && numcolors == 16)
-    {
-      bitspixel = 4;
-      system_visual->type = GDK_VISUAL_STATIC_COLOR;
-      map_entries = 16;
-    }
-  else if (bitspixel == 1)
-    {
-      system_visual->type = GDK_VISUAL_STATIC_GRAY;
-      map_entries = 2;
-    }
-  else if (bitspixel == 4)
-    {
-      system_visual->type = GDK_VISUAL_STATIC_COLOR;
-      map_entries = 16;
-    }
-  else if (bitspixel == 8)
-    {
-      system_visual->type = GDK_VISUAL_STATIC_COLOR;
-      map_entries = 256;
-    }
-  else if (bitspixel == 16)
-    {
       system_visual->type = GDK_VISUAL_TRUE_COLOR;
-#if 1
       /* This code by Mike Enright,
        * see http://www.users.cts.com/sd/m/menright/display.html
        */
@@ -231,36 +158,22 @@
 	  system_visual->green_mask = bmi.u.fields[1];
 	  system_visual->blue_mask  = bmi.u.fields[2];
 	}
-#else
-      /* Old, incorrect (but still working) code. */
-#if 0
-      system_visual->red_mask   = 0x0000F800;
-      system_visual->green_mask = 0x000007E0;
-      system_visual->blue_mask  = 0x0000001F;
-#else
-      system_visual->red_mask   = 0x00007C00;
-      system_visual->green_mask = 0x000003E0;
-      system_visual->blue_mask  = 0x0000001F;
-#endif
-#endif
     }
-  else if (bitspixel == 24 || bitspixel == 32)
+  else
     {
+      /* Pretend other modes are 24-bit TrueColor */
       bitspixel = 24;
       system_visual->type = GDK_VISUAL_TRUE_COLOR;
       system_visual->red_mask   = 0x00FF0000;
       system_visual->green_mask = 0x0000FF00;
       system_visual->blue_mask  = 0x000000FF;
     }
-  else
-    g_error ("_gdk_visual_init: unsupported BITSPIXEL: %d\n", bitspixel);
 
   system_visual->depth = bitspixel;
   system_visual->byte_order = GDK_LSB_FIRST;
   system_visual->bits_per_rgb = 42; /* Not used? */
 
-  if ((system_visual->type == GDK_VISUAL_TRUE_COLOR) ||
-      (system_visual->type == GDK_VISUAL_DIRECT_COLOR))
+  if (system_visual->type == GDK_VISUAL_TRUE_COLOR)
     {
       gdk_visual_decompose_mask (system_visual->red_mask,
 				 &system_visual->red_shift,
Index: gdk/win32/gdkevents-win32.c
===================================================================
--- gdk/win32/gdkevents-win32.c	(revision 19984)
+++ gdk/win32/gdkevents-win32.c	(working copy)
@@ -1595,58 +1595,6 @@
 }
 
 static void
-update_colors (GdkWindow *window,
-	       gboolean   top)
-{
-  HDC hdc;
-  GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
-  GList *list = gdk_window_get_children (window);
-  GList *head = list;
-
-  GDK_NOTE (COLORMAP, (top ? g_print ("update_colors:") : (void) 0));
-
-  while (list)
-    {
-      update_colors ((GdkWindow *) list->data, FALSE);
-      list = list->next;
-    }
-  g_list_free (head);
-
-  if (((GdkWindowObject *) window)->input_only ||
-      impl->colormap == NULL)
-    return;
-
-  if (!(hdc = GetDC (impl->handle)))
-    WIN32_GDI_FAILED ("GetDC");
-  else
-    {
-      GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (impl->colormap);
-      HPALETTE holdpal;
-      gint k;
-      
-      if ((holdpal = SelectPalette (hdc, cmapp->hpal, TRUE)) == NULL)
-	WIN32_GDI_FAILED ("SelectPalette");
-      else if ((k = RealizePalette (hdc)) == GDI_ERROR)
-	WIN32_GDI_FAILED ("RealizePalette");
-      else
-	{
-	  GDK_NOTE (COLORMAP,
-		    (k > 0 ?
-		     g_print (" %p pal=%p: realized %d colors\n"
-			      "update_colors:",
-			      impl->handle, cmapp->hpal, k) :
-		     (void) 0,
-		     g_print (" %p", impl->handle)));
-	  GDI_CALL (UpdateColors, (hdc));
-	  SelectPalette (hdc, holdpal, TRUE);
-	  RealizePalette (hdc);
-	}
-      GDI_CALL (ReleaseDC, (impl->handle, hdc));
-    }
-  GDK_NOTE (COLORMAP, (top ? g_print ("\n") : (void) 0));
-}
-
-static void
 translate_mouse_coords (GdkWindow *window1,
 			GdkWindow *window2,
 			MSG       *msg)
@@ -2685,7 +2633,7 @@
       break;
 
     case WM_MOUSEWHEEL:
-      GDK_NOTE (EVENTS, g_print (" %d", HIWORD (msg->wParam)));
+      GDK_NOTE (EVENTS, g_print (" %d", (gint16) HIWORD (msg->wParam)));
 
       /* WM_MOUSEWHEEL is delivered to the focus window. Work around
        * that. Also, the position is in screen coordinates, not client
@@ -2735,35 +2683,6 @@
       return_val = TRUE;
       break;
 
-    case WM_QUERYNEWPALETTE:
-      if (gdk_visual_get_system ()->type == GDK_VISUAL_PSEUDO_COLOR)
-	{
-	  synthesize_expose_events (window);
-	  update_colors_counter = 0;
-	}
-      return_val = TRUE;
-      break;
-
-    case WM_PALETTECHANGED:
-      GDK_NOTE (EVENTS_OR_COLORMAP, g_print (" %p", (HWND) msg->wParam));
-      if (gdk_visual_get_system ()->type != GDK_VISUAL_PSEUDO_COLOR)
-	break;
-
-      return_val = TRUE;
-
-      if (msg->hwnd == (HWND) msg->wParam)
-	break;
-
-      if (++update_colors_counter == 5)
-	{
-	  synthesize_expose_events (window);
-	  update_colors_counter = 0;
-	  break;
-	}
-      
-      update_colors (window, TRUE);
-      break;
-
      case WM_MOUSEACTIVATE:
        {
 	 GdkWindow *tmp;
Index: gdk/win32/gdkwindow-win32.c
===================================================================
--- gdk/win32/gdkwindow-win32.c	(revision 19984)
+++ gdk/win32/gdkwindow-win32.c	(working copy)
@@ -1460,8 +1460,6 @@
   HPALETTE holdpal = NULL;
   RECT rect;
   COLORREF bg;
-  GdkColormap *colormap;
-  GdkColormapPrivateWin32 *colormap_private;
   int x, y;
   int x_offset, y_offset;
   
@@ -1472,25 +1470,6 @@
       return;
     }
 
-  colormap = gdk_drawable_get_colormap (window);
-
-  if (colormap &&
-      (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
-       colormap->visual->type == GDK_VISUAL_STATIC_COLOR))
-    {
-      int k;
-	  
-      colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-      if (!(holdpal = SelectPalette (hdc,  colormap_private->hpal, FALSE)))
-        WIN32_GDI_FAILED ("SelectPalette");
-      else if ((k = RealizePalette (hdc)) == GDI_ERROR)
-	WIN32_GDI_FAILED ("RealizePalette");
-      else if (k > 0)
-	GDK_NOTE (COLORMAP, g_print ("erase_background: realized %p: %d colors\n",
-				     colormap_private->hpal, k));
-    }
-  
   x_offset = y_offset = 0;
   while (window && ((GdkWindowObject *) window)->bg_pixmap == GDK_PARENT_RELATIVE_BG)
     {
Index: gdk/win32/gdkcolor-win32.c
===================================================================
--- gdk/win32/gdkcolor-win32.c	(revision 19984)
+++ gdk/win32/gdkcolor-win32.c	(working copy)
@@ -35,9 +35,6 @@
 #include "gdkinternals.h"
 #include "gdkprivate-win32.h"
 
-static gint     gdk_colormap_match_color (GdkColormap      *cmap,
-					  GdkColor         *color,
-					  const gchar      *available);
 static void     gdk_colormap_init        (GdkColormap      *colormap);
 static void     gdk_colormap_class_init  (GdkColormapClass *klass);
 static void     gdk_colormap_finalize    (GObject          *object);
@@ -119,67 +116,6 @@
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
-/* Mimics XAllocColorCells. Allocate read/write color cells. */
-
-static gboolean
-alloc_color_cells (GdkColormap    *cmap,
-		   gboolean        contig,
-		   unsigned long   plane_masks_return[],
-		   unsigned int    nplanes,
-		   unsigned long   pixels_return[],
-		   unsigned int	   npixels)
-{
-  GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
-  gint i, nfree, iret, start = 0;
-
-  GDK_NOTE (COLORMAP, g_print ("alloc_color_cells: cmap=%p contig=%s npl=%d npix=%d",
-			       cmapp, contig ? "TRUE" : "FALSE",
-			       nplanes, npixels));
-
-  switch (cmap->visual->type)
-    {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      nfree = 0;
-      for (i = 0; i < cmap->size && nfree < npixels; i++)
-	if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE &&
-	    (!contig ||
-	     (nfree == 0 || cmapp->use[i-1] == GDK_WIN32_PE_AVAILABLE)))
-	  {
-	    if (nfree == 0)
-	      start = i;
-	    nfree++;
-	  }
-	else if (contig)
-	  nfree = 0;
-
-      if (npixels > nfree)
-	{
-	  GDK_NOTE (COLORMAP, g_print ("... nope (%d > %d)\n",
-				       npixels, nfree));
-	  return FALSE;
-	}
-      else
-	GDK_NOTE (COLORMAP, g_print ("... ok\n"));
-
-      iret = 0;
-      for (i = start; i < cmap->size && iret < npixels; i++)
-	if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
-	  {
-	    cmapp->use[i] = GDK_WIN32_PE_INUSE;
-	    pixels_return[iret] = i;
-	    iret++;
-	  }
-      g_assert (iret == npixels);
-      break;
-
-    default:
-      g_assert_not_reached ();
-    }
-
-  return TRUE;
-}
-
 /* The following functions are originally from Tk8.0, but heavily
    modified.  Here are tk's licensing terms. I hope these terms don't
    conflict with the GNU Lesser General Public License? They
@@ -227,318 +163,6 @@
 terms specified in this license.
 */
 
-/* Mimics XAllocColor. Allocate a read-only colormap entry. */
-
-static int
-alloc_color (GdkColormap  *cmap,
-	     PALETTEENTRY *color,
-	     guint        *pixelp)
-{
-  PALETTEENTRY entry, close_entry;
-  COLORREF new_pixel;
-  UINT index;
-  GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
-  gint i;
-    
-  entry = *color;
-  entry.peFlags = 0;
-
-  new_pixel = RGB (entry.peRed, entry.peGreen, entry.peBlue);
-
-  switch (cmap->visual->type)
-    {
-    case GDK_VISUAL_PSEUDO_COLOR:
-      /* Find the nearest existing palette entry. */
-      index = GetNearestPaletteIndex (cmapp->hpal, new_pixel);
-      GetPaletteEntries (cmapp->hpal, index, 1, &close_entry);
-
-      GDK_NOTE (COLORMAP,
-		g_print ("alloc_color: new_pixel=%06lx index=%d=%02x close=%06lx\n",
-			 new_pixel, index, index,
-			 RGB (close_entry.peRed, close_entry.peGreen, close_entry.peBlue)));
-
-      if (new_pixel != RGB (close_entry.peRed, close_entry.peGreen,
-			    close_entry.peBlue))
-	{
-	  /* Not a perfect match. */
-	  if (cmapp->use[index] == GDK_WIN32_PE_AVAILABLE)
-	    {
-	      /* It was a nonused entry anyway, so we can use it, and
-	       * set it to the correct color.
-	       */
-	      GDK_NOTE (COLORMAP, g_print ("... was free\n"));
-	      GDI_CALL (SetPaletteEntries, (cmapp->hpal, index, 1, &entry));
-	    }
-	  else
-	    {
-	      /* The close entry found is in use, so search for a
-	       * available slot.
-	       */
-	      gboolean done = FALSE;
-	      for (i = 0; i < cmap->size; i++)
-		if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
-		  {
-		    /* An available slot, use it. */
-		    GDK_NOTE (COLORMAP,
-			      g_print ("... use free slot %d%s\n",
-				       i, (i >= cmapp->current_size) ?
-				       ", will resize palette" : ""));
-		    if (i >= cmapp->current_size)
-		      {
-			if (!ResizePalette (cmapp->hpal, i + 1))
-			  {
-			    WIN32_GDI_FAILED ("ResizePalette");
-			    break;
-			  }
-			cmapp->current_size = i + 1;
-		      }
-		    if (!SetPaletteEntries (cmapp->hpal, i, 1, &entry))
-		      {
-			WIN32_GDI_FAILED ("SetPaletteEntries");
-			i = cmap->size;
-		      }
-		    else
-		      {
-			done = TRUE;
-			index = i;
-		      }
-		    break;
-		  }
-	      if (!done)
-		{
-		  /* No free slots available, or failed to resize
-		   * palette or set palette entry.
-		   */
-		  GDK_NOTE (COLORMAP, g_print ("... failure\n"));
-		  return FALSE;
-		}
-	    }
-	}
-      else
-	{
-	  /* We got a match, so use it. */
-	}
-
-      *pixelp = index;
-      cmapp->use[index] = GDK_WIN32_PE_INUSE;
-      GDK_NOTE (COLORMAP, g_print ("alloc_color: %p: "
-				   "index=%3d=%02x for %02x %02x %02x: "
-				   "%02x %02x %02x\n",
-				   cmapp->hpal, index, index,
-				   entry.peRed, entry.peGreen, entry.peBlue,
-				   color->peRed, color->peGreen, color->peBlue));
-      return TRUE;
-
-    case GDK_VISUAL_STATIC_COLOR:
-      /* Find the nearest existing palette entry. */
-      index = GetNearestPaletteIndex (cmapp->hpal, new_pixel);
-      GetPaletteEntries (cmapp->hpal, index, 1, &close_entry);
-      *color = close_entry;
-      *pixelp = index;
-      GDK_NOTE (COLORMAP, g_print ("alloc_color %p: "
-				   "index=%3d=%02x for %02x %02x %02x: "
-				   "%02x %02x %02x\n",
-				   cmapp->hpal, index, index,
-				   entry.peRed, entry.peGreen, entry.peBlue,
-				   color->peRed, color->peGreen, color->peBlue));
-      return TRUE;
-
-    case GDK_VISUAL_TRUE_COLOR:
-      /* Determine what color will actually be used on non-colormap systems. */
-
-      *pixelp = GetNearestColor (_gdk_display_hdc, new_pixel);
-      color->peRed = GetRValue (*pixelp);
-      color->peGreen = GetGValue (*pixelp);
-      color->peBlue = GetBValue (*pixelp);
-      return TRUE;
-
-    default:
-      g_assert_not_reached ();
-      return FALSE;
-    }
-}
-
-/* Mimics XFreeColors. */
-
-static void
-free_colors (GdkColormap *cmap,
-	     gulong  	 *pixels,
-	     gint    	  npixels,
-	     gulong  	  planes)
-{
-  PALETTEENTRY pe;
-  GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
-  gint i;
-#ifdef G_ENABLE_DEBUG
-  gint set_black_count = 0;
-#endif
-  gboolean *cleared_entries;
-
-  cleared_entries = g_new0 (gboolean, cmap->size);
-
-  /* We don't have to do anything for non-palette devices. */
-  
-  switch (cmap->visual->type)
-    {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      for (i = 0; i < npixels; i++)
-	{
-	  if (pixels[i] >= cmap->size)
-	    ; /* Nothing */
-	  else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC)
-	    ; /* Nothing either*/
-	  else
-	    {
-	      cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE;
-	      cleared_entries[pixels[i]] = TRUE;
-	    }
-	}
-      for (i = cmapp->current_size - 1; i >= 0; i--)
-	if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE)
-	  break;
-      if (i < cmapp->current_size - 1)
-	{
-	  GDK_NOTE (COLORMAP, g_print ("free_colors: hpal=%p resize=%d\n",
-				       cmapp->hpal, i + 1));
-	  if (!ResizePalette (cmapp->hpal, i + 1))
-	    WIN32_GDI_FAILED ("ResizePalette");
-	  else
-	    cmapp->current_size = i + 1;
-	}
-      pe.peRed = pe.peGreen = pe.peBlue = pe.peFlags = 0;
-      for (i = 0; i < cmapp->current_size; i++)
-	{
-	  if (cleared_entries[i])
-	    {
-	      GDI_CALL (SetPaletteEntries, (cmapp->hpal, i, 1, &pe));
-	      GDK_NOTE (COLORMAP, set_black_count++);
-	    }
-	}
-#if 0
-      GDK_NOTE (COLORMAP, _gdk_win32_print_hpalette (cmapp->hpal));
-#else
-      GDK_NOTE (COLORMAP, (set_black_count > 0 ?
-			   g_print ("free_colors: %d (%d) set to black\n",
-				    set_black_count, cmapp->current_size)
-			   : (void) 0));
-#endif
-      g_free (cleared_entries);
-
-      break;
-
-    default:
-      g_assert_not_reached ();
-    }
-}
-
-/* Mimics XCreateColormap. */
-
-static void
-create_colormap (GdkColormap *cmap,
-		 gboolean     writeable)
-{
-  struct {
-    LOGPALETTE pal;
-    PALETTEENTRY pe[256-1];
-  } lp;
-  HPALETTE hpal;
-  GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
-  gint i;
-
-  /* Allocate a starting palette with all the static colors. */
-  hpal = GetStockObject (DEFAULT_PALETTE);
-  lp.pal.palVersion = 0x300;
-  lp.pal.palNumEntries = GetPaletteEntries (hpal, 0, 256, lp.pal.palPalEntry);
-
-  if (cmap->visual->type == GDK_VISUAL_STATIC_COLOR &&
-      cmap->visual->depth == 4)
-    {
-      /* Use only 16 colors */
-      for (i = 8; i < 16; i++)
-	lp.pal.palPalEntry[i] = lp.pal.palPalEntry[i+4];
-      lp.pal.palNumEntries = 16;
-    }
-
-  for (i = 0; i < lp.pal.palNumEntries; i++)
-    lp.pal.palPalEntry[i].peFlags = 0;
-  GDK_NOTE (COLORMAP, (g_print ("Default palette %p: %d entries\n",
-				hpal, lp.pal.palNumEntries),
-		       _gdk_win32_print_paletteentries (lp.pal.palPalEntry,
-						       lp.pal.palNumEntries)));
-  DeleteObject (hpal);
-  
-  /* For writeable colormaps, allow all 256 entries to be set. They won't
-   * set all 256 system palette entries anyhow, of course, but we shouldn't
-   * let the app see that, I think.
-   */
-  if (writeable)
-    cmapp->current_size = 0;
-  else
-    cmapp->current_size = lp.pal.palNumEntries;
-
-  cmapp->private_val = writeable;
-
-  if (!(cmapp->hpal = CreatePalette (&lp.pal)))
-    WIN32_GDI_FAILED ("CreatePalette");
-  else
-    GDK_NOTE (COLORMAP, g_print ("Created palette %p\n", cmapp->hpal));
-
-  switch (cmap->visual->type)
-    {
-    case GDK_VISUAL_PSEUDO_COLOR:
-      cmapp->use = g_new (GdkWin32PalEntryState, cmap->size);
-
-      /* Mark static colors in use. */
-      for (i = 0; i < cmapp->current_size; i++)
-	{
-	  cmapp->use[i] = GDK_WIN32_PE_STATIC;
-	  cmapp->info[i].ref_count = G_MAXUINT/2;
-	}
-      /* Mark rest not in use */
-      for (; i < cmap->size; i++)
-	cmapp->use[i] = GDK_WIN32_PE_AVAILABLE;
-      break;
-
-    default:
-      break;
-    }
-}
-
-static void
-sync_colors (GdkColormap *colormap)
-{
-  PALETTEENTRY *pe;
-  GdkColormapPrivateWin32 *private = GDK_WIN32_COLORMAP_DATA (colormap);
-  gint nlookup;
-  gint i;
-  
-  pe = g_new (PALETTEENTRY, colormap->size);
-  nlookup = GetPaletteEntries (private->hpal, 0, colormap->size, pe);
-	  
-  GDK_NOTE (COLORMAP, (g_print ("sync_colors: %p hpal=%p: %d entries\n",
-				private, private->hpal, nlookup),
-		       _gdk_win32_print_paletteentries (pe, nlookup)));
-	  
-  for (i = 0; i < nlookup; i++)
-    {
-      colormap->colors[i].pixel = i;
-      colormap->colors[i].red = (pe[i].peRed * 65535) / 255;
-      colormap->colors[i].green = (pe[i].peGreen * 65535) / 255;
-      colormap->colors[i].blue = (pe[i].peBlue * 65535) / 255;
-    }
-  
-  for ( ; i < colormap->size; i++)
-    {
-      colormap->colors[i].pixel = i;
-      colormap->colors[i].red = 0;
-      colormap->colors[i].green = 0;
-      colormap->colors[i].blue = 0;
-    }
-  
-  g_free (pe);
-}
-
 GdkColormap*
 gdk_colormap_new (GdkVisual *visual,
 		  gboolean   private_cmap)
@@ -557,32 +181,6 @@
 
   switch (visual->type)
     {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      private->info = g_new0 (GdkColorInfo, colormap->size);
-      colormap->colors = g_new (GdkColor, colormap->size);
-      
-      private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
-					(GEqualFunc) gdk_color_equal);
-      
-      create_colormap (colormap, private_cmap);
-
-      if (private_cmap)
-	{
-	  sync_colors (colormap);
-#if 0 /* XXX is this needed or not? Seems redundant */
-	  gdk_colormap_change (colormap, colormap->size);
-#endif
-	}
-      break;
-
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_STATIC_COLOR:
-      create_colormap (colormap, FALSE);
-      colormap->colors = g_new (GdkColor, colormap->size);
-      sync_colors (colormap);
-      break;
-
     case GDK_VISUAL_TRUE_COLOR:
       break;
 
@@ -610,25 +208,8 @@
 
       colormap->size = colormap->visual->colormap_size;
 
-      private->private_val = FALSE;
-
       switch (colormap->visual->type)
 	{
-	case GDK_VISUAL_GRAYSCALE:
-	case GDK_VISUAL_PSEUDO_COLOR:
-	  private->info = g_new0 (GdkColorInfo, colormap->size);
-	  private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
-					    (GEqualFunc) gdk_color_equal);
-	  /* Fallthrough */
-
-	case GDK_VISUAL_STATIC_GRAY:
-	case GDK_VISUAL_STATIC_COLOR:
-	  create_colormap (colormap, FALSE);
-
-	  colormap->colors = g_new (GdkColor, colormap->size);
-	  sync_colors (colormap);
-	  break;
-
 	case GDK_VISUAL_TRUE_COLOR:
 	  break;
 
@@ -650,38 +231,8 @@
 gdk_colormap_change (GdkColormap *colormap,
 		     gint         ncolors)
 {
-  GdkColormapPrivateWin32 *cmapp;
-  PALETTEENTRY *pe;
-  int i;
-
   g_return_if_fail (GDK_IS_COLORMAP (colormap));
 
-  cmapp = GDK_WIN32_COLORMAP_DATA (colormap);
-
-  GDK_NOTE (COLORMAP, g_print ("gdk_colormap_change: hpal=%p ncolors=%d\n",
-			       cmapp->hpal, ncolors));
-
-  switch (colormap->visual->type)
-    {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      pe = g_new (PALETTEENTRY, ncolors);
-
-      for (i = 0; i < ncolors; i++)
-	{
-	  pe[i].peRed = (colormap->colors[i].red >> 8);
-	  pe[i].peGreen = (colormap->colors[i].green >> 8);
-	  pe[i].peBlue = (colormap->colors[i].blue >> 8);
-	  pe[i].peFlags = 0;
-	}
-
-      GDI_CALL (SetPaletteEntries, (cmapp->hpal, 0, ncolors, pe));
-      g_free (pe);
-      break;
-
-    default:
-      break;
-    }
 }
 
 gboolean
@@ -692,27 +243,11 @@
 		  gulong        *pixels,
 		  gint           npixels)
 {
-  GdkColormapPrivateWin32 *private;
-  gint return_val;
-  gint i;
-
   g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
 
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
+  g_assert_not_reached ();
 
-  return_val = alloc_color_cells (colormap, contiguous,
-				  planes, nplanes, pixels, npixels);
-
-  if (return_val)
-    {
-      for (i = 0; i < npixels; i++)
-	{
-	  private->info[pixels[i]].ref_count++;
-	  private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
-	}
-    }
-
-  return return_val != 0;
+  return FALSE;
 }
 
 void
@@ -721,47 +256,8 @@
 		 gint         in_npixels,
 		 gulong       planes)
 {
-  GdkColormapPrivateWin32 *private;
-  gulong *pixels;
-  gint npixels = 0;
-  gint i;
-
   g_return_if_fail (GDK_IS_COLORMAP (colormap));
   g_return_if_fail (in_pixels != NULL);
-
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-  if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
-    return;
-  
-  pixels = g_new (gulong, in_npixels);
-
-  for (i = 0; i < in_npixels; i++)
-    {
-      gulong pixel = in_pixels[i];
-      
-      if (private->use[pixel] == GDK_WIN32_PE_STATIC)
-	continue;
-
-      if (private->info[pixel].ref_count)
-	{
-	  private->info[pixel].ref_count--;
-
-	  if (private->info[pixel].ref_count == 0)
-	    {
-	      pixels[npixels++] = pixel;
-	      if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
-		g_hash_table_remove (private->hash, &colormap->colors[pixel]);
-	      private->info[pixel].flags = 0;
-	    }
-	}
-    }
-
-  if (npixels)
-    free_colors (colormap, pixels, npixels, planes);
-
-  g_free (pixels);
 }
 
 void
@@ -769,366 +265,10 @@
 			  const GdkColor *colors,
 			  gint            ncolors)
 {
-  gulong *pixels;
-  gint i;
-
   g_return_if_fail (GDK_IS_COLORMAP (colormap));
   g_return_if_fail (colors != NULL);
-
-  if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
-      (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
-    return;
-
-  pixels = g_new (gulong, ncolors);
-
-  for (i = 0; i < ncolors; i++)
-    pixels[i] =  colors[i].pixel;
-
-  gdk_colors_free (colormap, pixels, ncolors, 0);
-
-  g_free (pixels);
 }
 
-/********************
- * Color allocation *
- ********************/
-
-/* Try to allocate a single color using alloc_color. If it succeeds,
- * cache the result in our colormap, and store in ret.
- */
-static gboolean 
-gdk_colormap_alloc1 (GdkColormap *colormap,
-		     GdkColor    *color,
-		     GdkColor    *ret)
-{
-  GdkColormapPrivateWin32 *private;
-  PALETTEENTRY pe;
-
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-  pe.peRed = color->red >> 8;
-  pe.peGreen = color->green >> 8;
-  pe.peBlue = color->blue >> 8;
-
-  if (alloc_color (colormap, &pe, &ret->pixel))
-    {
-      ret->red = (pe.peRed * 65535) / 255;
-      ret->green = (pe.peGreen * 65535) / 255;
-      ret->blue = (pe.peBlue * 65535) / 255;
-      
-      if ((guint) ret->pixel < colormap->size)
-	{
-	  if (private->info[ret->pixel].ref_count) /* got a duplicate */
-	    {
-	    }
-	  else
-	    {
-	      colormap->colors[ret->pixel] = *color;
-	      colormap->colors[ret->pixel].pixel = ret->pixel;
-	      private->info[ret->pixel].ref_count = 1;
-
-	      g_hash_table_insert (private->hash,
-				   &colormap->colors[ret->pixel],
-				   &colormap->colors[ret->pixel]);
-	    }
-	}
-      return TRUE;
-    }
-  return FALSE;
-}
-
-static gint
-gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
-				     GdkColor    *colors,
-				     gint         ncolors,
-				     gboolean     writeable,
-				     gboolean     best_match,
-				     gboolean    *success)
-{
-  GdkColormapPrivateWin32 *private;
-  gulong *pixels;
-  gboolean status;
-  gint i, index;
-
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-  if (private->private_val)
-    {
-      index = 0;
-      for (i=0; i<ncolors; i++)
-	{
-	  while ((index < colormap->size) &&
-		 (private->info[index].ref_count != 0))
-	    index++;
-	  
-	  if (index < colormap->size)
-	    {
-	      colors[i].pixel = index;
-	      success[i] = TRUE;
-	      private->info[index].ref_count++;
-	      private->info[i].flags |= GDK_COLOR_WRITEABLE;
-	    }
-	  else
-	    break;
-	}
-      return i;
-    }
-  else
-    {
-      pixels = g_new (gulong, ncolors);
-
-      /* Allocation of a writeable color cells */
-      status =  alloc_color_cells (colormap, FALSE, NULL, 0, pixels, ncolors);
-      if (status)
-	{
-	  for (i = 0; i < ncolors; i++)
-	    {
-	      colors[i].pixel = pixels[i];
-	      private->info[pixels[i]].ref_count++;
-	      private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
-	    }
-	}
-      
-      g_free (pixels);
-
-      return status ? ncolors : 0; 
-    }
-}
-
-static gint
-gdk_colormap_alloc_colors_private (GdkColormap *colormap,
-				   GdkColor    *colors,
-				   gint         ncolors,
-				   gboolean     writeable,
-				   gboolean     best_match,
-				   gboolean    *success)
-{
-  GdkColormapPrivateWin32 *cmapp;
-  gint i, index;
-  PALETTEENTRY pe;
-  gint nremaining = 0;
-  
-  cmapp = GDK_WIN32_COLORMAP_DATA (colormap);
-  index = -1;
-
-  /* First, store the colors we have room for */
-
-  index = 0;
-  for (i = 0; i < ncolors; i++)
-    {
-      if (!success[i])
-	{
-	  while ((index < colormap->size) &&
-		 (cmapp->info[index].ref_count != 0))
-	    index++;
-
-	  if (index < colormap->size)
-	    {
-	      if (index >= cmapp->current_size)
-		{
-		  if (!ResizePalette (cmapp->hpal, index + 1))
-		    {
-		      WIN32_GDI_FAILED ("ResizePalette");
-		      nremaining++;
-		    }
-		  else
-		    cmapp->current_size = index + 1;
-		}
-	      if (index < cmapp->current_size)
-		{
-		  pe.peRed = colors[i].red >> 8;
-		  pe.peBlue = colors[i].blue >> 8;
-		  pe.peGreen = colors[i].green >> 8;
-		  pe.peFlags = 0;
-		  
-		  if (!SetPaletteEntries (cmapp->hpal, index, 1, &pe))
-		    {
-		      WIN32_GDI_FAILED ("SetPaletteEntries");
-		      nremaining++;
-		    }
-		  else
-		    {
-		      success[i] = TRUE;
-
-		      colors[i].pixel = index;
-		      colormap->colors[index] = colors[i];
-		      cmapp->info[index].ref_count++;
-		    }
-		}
-	    }
-	  else
-	    nremaining++;
-	}
-    }
-  
-  if (nremaining > 0 && best_match)
-    {
-      /* Get best matches for remaining colors */
-
-      gchar *available = g_new (gchar, colormap->size);
-      for (i = 0; i < colormap->size; i++)
-	available[i] = TRUE;
-
-      for (i=0; i<ncolors; i++)
-	{
-	  if (!success[i])
-	    {
-	      index = gdk_colormap_match_color (colormap, 
-						&colors[i], 
-						available);
-	      if (index != -1)
-		{
-		  colors[i] = colormap->colors[index];
-		  cmapp->info[index].ref_count++;
-
-		  success[i] = TRUE;
-		  nremaining--;
-		}
-	    }
-	}
-      g_free (available);
-    }
-
-  return (ncolors - nremaining);
-}
-
-static gint
-gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
-				  GdkColor    *colors,
-				  gint         ncolors,
-				  gboolean     writeable,
-				  gboolean     best_match,
-				  gboolean    *success)
-{
-  GdkColormapPrivateWin32 *private;
-  gint i, index;
-  gint nremaining = 0;
-  gint nfailed = 0;
-
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
-  index = -1;
-
-  for (i = 0; i < ncolors; i++)
-    {
-      if (!success[i])
-	{
-	  if (gdk_colormap_alloc1 (colormap, &colors[i], &colors[i]))
-	    success[i] = TRUE;
-	  else
-	    nremaining++;
-	}
-    }
-
-
-  if (nremaining > 0 && best_match)
-    {
-      gchar *available = g_new (gchar, colormap->size);
-      for (i = 0; i < colormap->size; i++)
-	available[i] = ((private->info[i].ref_count == 0) ||
-			!(private->info[i].flags & GDK_COLOR_WRITEABLE));
-      while (nremaining > 0)
-	{
-	  for (i = 0; i < ncolors; i++)
-	    {
-	      if (!success[i])
-		{
-		  index = gdk_colormap_match_color (colormap, &colors[i], available);
-		  if (index != -1)
-		    {
-		      if (private->info[index].ref_count)
-			{
-			  private->info[index].ref_count++;
-			  colors[i] = colormap->colors[index];
-			  success[i] = TRUE;
-			  nremaining--;
-			}
-		      else
-			{
-			  if (gdk_colormap_alloc1 (colormap, 
-						   &colormap->colors[index],
-						   &colors[i]))
-			    {
-			      success[i] = TRUE;
-			      nremaining--;
-			      break;
-			    }
-			  else
-			    {
-			      available[index] = FALSE;
-			    }
-			}
-		    }
-		  else
-		    {
-		      nfailed++;
-		      nremaining--;
-		      success[i] = 2; /* flag as permanent failure */
-		    }
-		}
-	    }
-	}
-      g_free (available);
-    }
-
-  /* Change back the values we flagged as permanent failures */
-  if (nfailed > 0)
-    {
-      for (i = 0; i < ncolors; i++)
-	if (success[i] == 2)
-	  success[i] = FALSE;
-      nremaining = nfailed;
-    }
-  
-  return (ncolors - nremaining);
-}
-
-static gint
-gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
-				       GdkColor    *colors,
-				       gint         ncolors,
-				       gboolean     writeable,
-				       gboolean     best_match,
-				       gboolean    *success)
-{
-  GdkColormapPrivateWin32 *private;
-  GdkColor *lookup_color;
-  gint i;
-  gint nremaining = 0;
-
-  private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-  /* Check for an exact match among previously allocated colors */
-
-  for (i = 0; i < ncolors; i++)
-    {
-      if (!success[i])
-	{
-	  lookup_color = g_hash_table_lookup (private->hash, &colors[i]);
-	  if (lookup_color)
-	    {
-	      private->info[lookup_color->pixel].ref_count++;
-	      colors[i].pixel = lookup_color->pixel;
-	      success[i] = TRUE;
-	    }
-	  else
-	    nremaining++;
-	}
-    }
-
-  /* If that failed, we try to allocate a new color, or approxmiate
-   * with what we can get if best_match is TRUE.
-   */
-  if (nremaining > 0)
-    {
-      if (private->private_val)
-	return gdk_colormap_alloc_colors_private (colormap, colors, ncolors, writeable, best_match, success);
-      else
-	return gdk_colormap_alloc_colors_shared (colormap, colors, ncolors, writeable, best_match, success);
-    }
-  else
-    return 0;
-}
-
 gint
 gdk_colormap_alloc_colors (GdkColormap *colormap,
 			   GdkColor    *colors,
@@ -1141,7 +281,6 @@
   GdkVisual *visual;
   gint i;
   gint nremaining = 0;
-  PALETTEENTRY pe;
 
   g_return_val_if_fail (GDK_IS_COLORMAP (colormap), FALSE);
   g_return_val_if_fail (colors != NULL, FALSE);
@@ -1154,16 +293,6 @@
 
   switch (colormap->visual->type)
     {
-    case GDK_VISUAL_PSEUDO_COLOR:
-    case GDK_VISUAL_GRAYSCALE:
-      if (writeable)
-	return gdk_colormap_alloc_colors_writeable (colormap, colors, ncolors,
-						    writeable, best_match, success);
-      else
-	return gdk_colormap_alloc_colors_pseudocolor (colormap, colors, ncolors,
-						    writeable, best_match, success);
-      break;
-
     case GDK_VISUAL_TRUE_COLOR:
       visual = colormap->visual;
 
@@ -1177,21 +306,7 @@
 	}
       break;
 
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_STATIC_COLOR:
-      for (i = 0; i < ncolors; i++)
-	{
-	  pe.peRed = colors[i].red >> 8;
-	  pe.peGreen = colors[i].green >> 8;
-	  pe.peBlue = colors[i].blue >> 8;
-	  if (alloc_color (colormap, &pe, &colors[i].pixel))
-	    success[i] = TRUE;
-	  else
-	    nremaining++;
-	}
-      break;
-
-    case GDK_VISUAL_DIRECT_COLOR:
+    default:
       g_assert_not_reached ();
     }
 
@@ -1211,25 +326,12 @@
 
   switch (visual->type)
     {
-    case GDK_VISUAL_DIRECT_COLOR:
     case GDK_VISUAL_TRUE_COLOR:
       result->red = 65535. * (double)((pixel & visual->red_mask) >> visual->red_shift) / ((1 << visual->red_prec) - 1);
       result->green = 65535. * (double)((pixel & visual->green_mask) >> visual->green_shift) / ((1 << visual->green_prec) - 1);
       result->blue = 65535. * (double)((pixel & visual->blue_mask) >> visual->blue_shift) / ((1 << visual->blue_prec) - 1);
       break;
 
-    case GDK_VISUAL_STATIC_GRAY:
-    case GDK_VISUAL_GRAYSCALE:
-      result->red = result->green = result->blue = 65535. * (double)pixel/((1<<visual->depth) - 1);
-      break;
-
-    case GDK_VISUAL_STATIC_COLOR:
-    case GDK_VISUAL_PSEUDO_COLOR:
-      result->red = colormap->colors[pixel].red;
-      result->green = colormap->colors[pixel].green;
-      result->blue = colormap->colors[pixel].blue;
-      break;
-
     default:
       g_assert_not_reached ();
       break;
@@ -1263,44 +365,6 @@
   return TRUE;
 }
 
-static gint
-gdk_colormap_match_color (GdkColormap *cmap,
-			  GdkColor    *color,
-			  const gchar *available)
-{
-  GdkColor *colors;
-  guint sum, min;
-  gint rdiff, gdiff, bdiff;
-  gint i, index;
-
-  g_return_val_if_fail (cmap != NULL, 0);
-  g_return_val_if_fail (color != NULL, 0);
-
-  colors = cmap->colors;
-  min = 3 * (65536);
-  index = -1;
-
-  for (i = 0; i < cmap->size; i++)
-    {
-      if ((!available) || (available && available[i]))
-	{
-	  rdiff = (color->red - colors[i].red);
-	  gdiff = (color->green - colors[i].green);
-	  bdiff = (color->blue - colors[i].blue);
-
-	  sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
-
-	  if (sum < min)
-	    {
-	      index = i;
-	      min = sum;
-	    }
-	}
-    }
-
-  return index;
-}
-
 GdkScreen*
 gdk_colormap_get_screen (GdkColormap *cmap)
 {
Index: gdk/win32/gdkgc-win32.c
===================================================================
--- gdk/win32/gdkgc-win32.c	(revision 19984)
+++ gdk/win32/gdkgc-win32.c	(working copy)
@@ -686,11 +686,6 @@
   visual = colormap->visual;
   switch (visual->type)
     {
-    case GDK_VISUAL_GRAYSCALE:
-    case GDK_VISUAL_PSEUDO_COLOR:
-    case GDK_VISUAL_STATIC_COLOR:
-      return PALETTEINDEX (pixel);
-
     case GDK_VISUAL_TRUE_COLOR:
       r = (pixel & visual->red_mask) >> visual->red_shift;
       r = (r * 255) / bitmask[visual->red_prec];
@@ -706,35 +701,6 @@
     }
 }
 
-gboolean
-predraw (GdkGC       *gc,
-	 GdkColormap *colormap)
-{
-  GdkGCWin32 *win32_gc = (GdkGCWin32 *) gc;
-  GdkColormapPrivateWin32 *colormap_private;
-  gint k;
-  gboolean ok = TRUE;
-
-  if (colormap &&
-      (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
-       colormap->visual->type == GDK_VISUAL_STATIC_COLOR))
-    {
-      colormap_private = GDK_WIN32_COLORMAP_DATA (colormap);
-
-      g_assert (colormap_private != NULL);
-
-      if (!(win32_gc->holdpal = SelectPalette (win32_gc->hdc, colormap_private->hpal, FALSE)))
-	WIN32_GDI_FAILED ("SelectPalette"), ok = FALSE;
-      else if ((k = RealizePalette (win32_gc->hdc)) == GDI_ERROR)
-	WIN32_GDI_FAILED ("RealizePalette"), ok = FALSE;
-      else if (k > 0)
-	GDK_NOTE (COLORMAP, g_print ("predraw: realized %p: %d colors\n",
-				     colormap_private->hpal, k));
-    }
-
-  return ok;
-}
-
 static GdkDrawableImplWin32 *
 get_impl_drawable (GdkDrawable *drawable)
 {
@@ -822,9 +788,6 @@
   if (ok && (win32_gc->saved_dc = SaveDC (win32_gc->hdc)) == 0)
     WIN32_GDI_FAILED ("SaveDC"), ok = FALSE;
       
-  if (ok && (usage & (GDK_GC_FOREGROUND | GDK_GC_BACKGROUND)))
-      ok = predraw (gc, impl->colormap);
-
   if (ok && (usage & GDK_GC_FOREGROUND))
     {
       fg = _gdk_win32_colormap_color (impl->colormap, _gdk_gc_get_fg_pixel (gc));
