This commit was generated by cvs2svn to compensate for changes in r5197,
[chise/xemacs-chise.git.1] / src / redisplay-x.c
index cf1766e..b6247a5 100644 (file)
@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA.  */
 #include "debug.h"
 #include "faces.h"
 #include "frame.h"
-#include "gutter.h"
 #include "redisplay.h"
 #include "sysdep.h"
 #include "window.h"
@@ -75,11 +74,13 @@ static void x_redraw_exposed_window (struct window *w, int x, int y,
                                     int width, int height);
 static void x_redraw_exposed_windows (Lisp_Object window, int x, int y,
                                      int width, int height);
+static void x_clear_region (Lisp_Object window, face_index findex, int x,
+                           int y, int width, int height);
 static void x_output_eol_cursor (struct window *w, struct display_line *dl,
                                 int xpos, face_index findex);
 static void x_clear_frame (struct frame *f);
 static void x_clear_frame_windows (Lisp_Object window);
-void bevel_modeline (struct window *w, struct display_line *dl);
+static void x_bevel_modeline (struct window *w, struct display_line *dl);
 
 
      /* Note: We do not use the Xmb*() functions and XFontSets.
@@ -196,7 +197,7 @@ separate_textual_runs (unsigned char *text_storage,
          char_converter.reg[0] = XCHARSET_ID (charset);
          char_converter.reg[1] = byte1;
          char_converter.reg[2] = byte2;
-         ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
+         ccl_driver (&char_converter, 0, 0, 0, 0);
          byte1 = char_converter.reg[1];
          byte2 = char_converter.reg[2];
        }
@@ -335,7 +336,7 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
 
   int elt = start;
   face_index findex;
-  int xpos, width = 0;
+  int xpos, width;
   Lisp_Object charset = Qunbound; /* Qnil is a valid charset when
                                     MULE is not defined */
 
@@ -343,13 +344,18 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
   rb = Dynarr_atp (rba, start);
 
   if (!rb)
-    /* Nothing to do so don't do anything. */
-    return;
-
-  findex = rb->findex;
-  xpos = rb->xpos;
-  if (rb->type == RUNE_CHAR)
-    charset = CHAR_CHARSET (rb->object.chr.ch);
+    {
+      /* Nothing to do so don't do anything. */
+      return;
+    }
+  else
+    {
+      findex = rb->findex;
+      xpos = rb->xpos;
+      width = 0;
+      if (rb->type == RUNE_CHAR)
+       charset = CHAR_CHARSET (rb->object.chr.ch);
+    }
 
   if (end < 0)
     end = Dynarr_length (rba);
@@ -410,7 +416,7 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
                  /* Clear in case a cursor was formerly here. */
                  int height = dl->ascent + dl->descent - dl->clip;
 
-                 redisplay_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
+                 x_clear_region (window, findex, xpos, dl->ypos - dl->ascent,
                                  rb->width, height);
                  elt++;
                }
@@ -484,12 +490,9 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
                  case IMAGE_POINTER:
                    abort ();
 
-                 case IMAGE_WIDGET:
                  case IMAGE_SUBWINDOW:
-                   redisplay_output_subwindow (w, dl, instance, xpos,
-                                               rb->object.dglyph.xoffset, start_pixpos,
-                                               rb->width, findex, cursor_start,
-                                               cursor_width, cursor_height);
+                   /* #### implement me */
+                   break;
 
                  case IMAGE_NOTHING:
                    /* nothing is as nothing does */
@@ -518,40 +521,38 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
       && (f->clear
          || f->windows_structure_changed
          || w->shadow_thickness_changed))
-    bevel_modeline (w, dl);
+    x_bevel_modeline (w, dl);
 
   Dynarr_free (buf);
 }
 
 /*****************************************************************************
- x_bevel_area
+ x_bevel_modeline
 
- Draw a shadows for the given area in the given face.
+ Draw a 3d border around the modeline on window W.
  ****************************************************************************/
 static void
-x_bevel_area (struct window *w, face_index findex,
-             int x, int y, int width, int height,
-             int shadow_thickness)
+x_bevel_modeline (struct window *w, struct display_line *dl)
 {
   struct frame *f = XFRAME (w->frame);
   struct device *d = XDEVICE (f->device);
-
-  EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
   Display *dpy = DEVICE_X_DISPLAY (d);
   Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
+  EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
+  GC top_shadow_gc, bottom_shadow_gc, background_gc;
   Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
-  Lisp_Object tmp_pixel;
   XColor tmp_color;
+  Lisp_Object tmp_pixel;
+  int x, y, width, height;
   XGCValues gcv;
-  GC top_shadow_gc, bottom_shadow_gc, background_gc;
-
+  unsigned long mask;
   int use_pixmap = 0;
   int flip_gcs = 0;
-  unsigned long mask;
+  int shadow_thickness;
 
   memset (&gcv, ~0, sizeof (XGCValues));
 
-  tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
+  tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
   tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
 
   /* First, get the GC's. */
@@ -562,14 +563,12 @@ x_bevel_area (struct window *w, face_index findex,
   x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
                            background_pixel, ef->core.background_pixel);
 
-  tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
+  tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, MODELINE_INDEX);
   tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
   gcv.background = tmp_color.pixel;
   gcv.graphics_exposures = False;
   mask = GCForeground | GCBackground | GCGraphicsExposures;
 
-  /* If we can't distinguish one of the shadows (the color is the same as the
-     background), it's better to use a pixmap to generate a dithered gray. */
   if (top_shadow_pixel == background_pixel ||
       bottom_shadow_pixel == background_pixel)
     use_pixmap = 1;
@@ -583,16 +582,15 @@ x_bevel_area (struct window *w, face_index findex,
                                         gray_width, gray_height, 1, 0, 1);
        }
 
-      tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
+      tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, MODELINE_INDEX);
       tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
       gcv.foreground = tmp_color.pixel;
-      /* this is needed because the GC draws with a pixmap here */
       gcv.fill_style = FillOpaqueStippled;
       gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
       top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
                                       (mask | GCStipple | GCFillStyle));
 
-      tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
+      tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, MODELINE_INDEX);
       tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
       bottom_shadow_pixel = tmp_color.pixel;
 
@@ -618,23 +616,23 @@ x_bevel_area (struct window *w, face_index findex,
   gcv.foreground = background_pixel;
   background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
 
-  /* possibly revert the GC's in case the shadow thickness is < 0.
-     This will give a depressed look to the divider */
-  if (shadow_thickness < 0)
+  if (XINT (w->modeline_shadow_thickness) < 0)
     {
       GC temp;
 
       temp = top_shadow_gc;
       top_shadow_gc = bottom_shadow_gc;
       bottom_shadow_gc = temp;
-
-      /* better avoid a Bad Address XLib error ;-) */
-      shadow_thickness = - shadow_thickness;
     }
 
-  /* Draw the shadows around the divider line */
-  x_output_shadows (f, x, y, width, height,
-                   top_shadow_gc, bottom_shadow_gc,
+  shadow_thickness = MODELINE_SHADOW_THICKNESS (w);
+
+  x = WINDOW_MODELINE_LEFT (w);
+  width = WINDOW_MODELINE_RIGHT (w) - x;
+  y = dl->ypos - dl->ascent - shadow_thickness;
+  height = dl->ascent + dl->descent + 2 * shadow_thickness;
+
+  x_output_shadows (f, x, y, width, height, top_shadow_gc, bottom_shadow_gc,
                    background_gc, shadow_thickness);
 }
 
@@ -695,18 +693,8 @@ x_get_gc (struct device *d, Lisp_Object font, Lisp_Object fg, Lisp_Object bg,
       mask |= GCBackground;
     }
 
-  /* This special case comes from a request to draw text with a face which has
-     the dim property. We'll use a stippled foreground GC. */
-  if (EQ (bg_pmap, Qdim))
-    {
-      assert (DEVICE_X_GRAY_PIXMAP (d) != None);
-
-      gcv.fill_style = FillStippled;
-      gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
-      mask |= (GCFillStyle | GCStipple);
-    }
-  else  if (IMAGE_INSTANCEP (bg_pmap)
-           && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
+  if (IMAGE_INSTANCEP (bg_pmap)
+      && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (bg_pmap)))
     {
       if (XIMAGE_INSTANCE_PIXMAP_DEPTH (bg_pmap) == 0)
        {
@@ -904,21 +892,21 @@ x_output_string (struct window *w, struct display_line *dl,
 
              if (ypos1_line < ypos1_string)
                {
-                 redisplay_clear_region (window, findex, clear_start, ypos1_line,
+                 x_clear_region (window, findex, clear_start, ypos1_line,
                                  clear_end - clear_start,
                                  ypos1_string - ypos1_line);
                }
 
              if (ypos2_line > ypos2_string)
                {
-                 redisplay_clear_region (window, findex, clear_start, ypos2_string,
+                 x_clear_region (window, findex, clear_start, ypos2_string,
                                  clear_end - clear_start,
                                  ypos2_line - ypos2_string);
                }
            }
          else
            {
-             redisplay_clear_region (window, findex, clear_start,
+             x_clear_region (window, findex, clear_start,
                              dl->ypos - dl->ascent, clear_end - clear_start,
                              height);
            }
@@ -927,18 +915,6 @@ x_output_string (struct window *w, struct display_line *dl,
       if (cursor && cursor_cachel && focus && NILP (bar_cursor_value))
        gc = x_get_gc (d, font, cursor_cachel->foreground,
                       cursor_cachel->background, Qnil, Qnil);
-      else if (cachel->dim)
-       {
-         /* Ensure the gray bitmap exists */
-         if (DEVICE_X_GRAY_PIXMAP (d) == None)
-           DEVICE_X_GRAY_PIXMAP (d) =
-             XCreateBitmapFromData (dpy, x_win, (char *)gray_bits,
-                                    gray_width, gray_height);
-
-         /* Request a GC with the gray stipple pixmap to draw dimmed text */
-         gc = x_get_gc (d, font, cachel->foreground, cachel->background,
-                        Qdim, Qnil);
-       }
       else
        gc = x_get_gc (d, font, cachel->foreground, cachel->background,
                       Qnil, Qnil);
@@ -1336,7 +1312,7 @@ x_output_pixmap (struct window *w, struct display_line *dl,
          clear_width = width;
        }
 
-      redisplay_clear_region (window, findex, clear_x, clear_y,
+      x_clear_region (window, findex, clear_x, clear_y,
                      clear_width, clear_height);
     }
 
@@ -1398,36 +1374,111 @@ x_output_vertical_divider (struct window *w, int clear)
   struct frame *f = XFRAME (w->frame);
   struct device *d = XDEVICE (f->device);
 
+  EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
   Display *dpy = DEVICE_X_DISPLAY (d);
   Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
+  Pixel top_shadow_pixel, bottom_shadow_pixel, background_pixel;
   Lisp_Object tmp_pixel;
   XColor tmp_color;
   XGCValues gcv;
-  GC background_gc;
+  GC top_shadow_gc, bottom_shadow_gc, background_gc;
 
+  int use_pixmap = 0;
+  int flip_gcs = 0;
   unsigned long mask;
   int x, y1, y2, width, shadow_thickness, spacing, line_width;
   face_index div_face = get_builtin_face_cache_index (w, Vvertical_divider_face);
-
+  
   width = window_divider_width (w);
   shadow_thickness = XINT (w->vertical_divider_shadow_thickness);
   spacing = XINT (w->vertical_divider_spacing);
   line_width = XINT (w->vertical_divider_line_width);
   x = WINDOW_RIGHT (w) - width;
-  y1 = WINDOW_TOP (w) + FRAME_TOP_GUTTER_BOUNDS (f);
-  y2 = WINDOW_BOTTOM (w) + FRAME_BOTTOM_GUTTER_BOUNDS (f);
-
+  y1 = WINDOW_TOP (w);
+  y2 = WINDOW_BOTTOM (w);
+  
   memset (&gcv, ~0, sizeof (XGCValues));
-
+  
   tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
   tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
-
+  
   /* First, get the GC's. */
+  top_shadow_pixel = tmp_color.pixel;
+  bottom_shadow_pixel = tmp_color.pixel;
+  background_pixel = tmp_color.pixel;
+  
+  x_generate_shadow_pixels (f, &top_shadow_pixel, &bottom_shadow_pixel,
+                           background_pixel, ef->core.background_pixel);
+  
+  tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face);
+  tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
   gcv.background = tmp_color.pixel;
-  gcv.foreground = tmp_color.pixel;
   gcv.graphics_exposures = False;
   mask = GCForeground | GCBackground | GCGraphicsExposures;
+
+  /* If we can't distinguish one of the shadows (the color is the same as the
+     background), it's better to use a pixmap to generate a dithrered gray. */
+  if (top_shadow_pixel == background_pixel ||
+      bottom_shadow_pixel == background_pixel)
+    use_pixmap = 1;
+  
+  if (use_pixmap)
+    {
+      if (DEVICE_X_GRAY_PIXMAP (d) == None)
+       {
+         DEVICE_X_GRAY_PIXMAP (d) =
+           XCreatePixmapFromBitmapData (dpy, x_win, (char *) gray_bits,
+                                        gray_width, gray_height, 1, 0, 1);
+       }
+      
+      tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, div_face);
+      tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
+      gcv.foreground = tmp_color.pixel;
+      /* this is needed because the GC draws with a pixmap here */
+      gcv.fill_style = FillOpaqueStippled;
+      gcv.stipple = DEVICE_X_GRAY_PIXMAP (d);
+      top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv,
+                                      (mask | GCStipple | GCFillStyle));
+      
+      tmp_pixel = WINDOW_FACE_CACHEL_FOREGROUND (w, div_face);
+      tmp_color = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
+      bottom_shadow_pixel = tmp_color.pixel;
+      
+      flip_gcs = (bottom_shadow_pixel ==
+                 WhitePixelOfScreen (DefaultScreenOfDisplay (dpy)));
+    }
+  else
+    {
+      gcv.foreground = top_shadow_pixel;
+      top_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
+    }
+  
+  gcv.foreground = bottom_shadow_pixel;
+  bottom_shadow_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
+  
+  if (use_pixmap && flip_gcs)
+    {
+      GC tmp_gc = bottom_shadow_gc;
+      bottom_shadow_gc = top_shadow_gc;
+      top_shadow_gc = tmp_gc;
+    }
+  
+  gcv.foreground = background_pixel;
   background_gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, mask);
+  
+  /* possibly revert the GC's in case the shadow thickness is < 0.
+     This will give a depressed look to the divider */
+  if (shadow_thickness < 0)
+    {
+      GC temp;
+
+      temp = top_shadow_gc;
+      top_shadow_gc = bottom_shadow_gc;
+      bottom_shadow_gc = temp;
+      
+      /* better avoid a Bad Adress XLib error ;-) */
+      shadow_thickness = - shadow_thickness;
+    }
 
   /* Clear the divider area first.  This needs to be done when a
      window split occurs. */
@@ -1435,14 +1486,15 @@ x_output_vertical_divider (struct window *w, int clear)
     XClearArea (dpy, x_win, x, y1, width, y2 - y1, False);
 
   /* Draw the divider line. */
-  XFillRectangle (dpy, x_win, background_gc,
+  XFillRectangle (dpy, x_win, background_gc, 
                  x + spacing + shadow_thickness, y1,
                  line_width, y2 - y1);
-
+  
   /* Draw the shadows around the divider line */
-  x_bevel_area (w, div_face, x + spacing, y1,
-               width - 2 * spacing, y2 - y1,
-               shadow_thickness);
+  x_output_shadows (f, x + spacing, y1, 
+                   width - 2 * spacing, y2 - y1,
+                   top_shadow_gc, bottom_shadow_gc,
+                   background_gc, shadow_thickness);
 }
 
 /*****************************************************************************
@@ -1604,7 +1656,7 @@ x_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
  x_output_shadows
 
  Draw a shadow around the given area using the given GC's.  It is the
- callers responsibility to set the GC's appropriately.
+ callers responsibility to ste the GC's appropriately.
  ****************************************************************************/
 void
 x_output_shadows (struct frame *f, int x, int y, int width, int height,
@@ -1740,6 +1792,54 @@ x_generate_shadow_pixels (struct frame *f, unsigned long *top_shadow,
 }
 
 /*****************************************************************************
+ x_clear_to_window_end
+
+ Clear the area between ypos1 and ypos2.  Each margin area and the
+ text area is handled separately since they may each have their own
+ background color.
+ ****************************************************************************/
+static void
+x_clear_to_window_end (struct window *w, int ypos1, int ypos2)
+{
+  int height = ypos2 - ypos1;
+
+  if (height)
+    {
+      struct frame *f = XFRAME (w->frame);
+      Lisp_Object window;
+      int bflag = (window_needs_vertical_divider (w) ? 0 : 1);
+      layout_bounds bounds;
+
+      bounds = calculate_display_line_boundaries (w, bflag);
+      XSETWINDOW (window, w);
+
+      if (window_is_leftmost (w))
+       x_clear_region (window, DEFAULT_INDEX, FRAME_LEFT_BORDER_START (f),
+                       ypos1, FRAME_BORDER_WIDTH (f), height);
+
+      if (bounds.left_in - bounds.left_out > 0)
+       x_clear_region (window,
+                       get_builtin_face_cache_index (w, Vleft_margin_face),
+                       bounds.left_out, ypos1,
+                       bounds.left_in - bounds.left_out, height);
+
+      if (bounds.right_in - bounds.left_in > 0)
+       x_clear_region (window, DEFAULT_INDEX, bounds.left_in, ypos1,
+                       bounds.right_in - bounds.left_in, height);
+
+      if (bounds.right_out - bounds.right_in > 0)
+       x_clear_region (window,
+                       get_builtin_face_cache_index (w, Vright_margin_face),
+                       bounds.right_in, ypos1,
+                       bounds.right_out - bounds.right_in, height);
+
+      if (window_is_rightmost (w))
+       x_clear_region (window, DEFAULT_INDEX, FRAME_RIGHT_BORDER_START (f),
+                       ypos1, FRAME_BORDER_WIDTH (f), height);
+    }
+}
+
+/*****************************************************************************
  x_redraw_exposed_window
 
  Given a bounding box for an area that needs to be redrawn, determine
@@ -1856,7 +1956,6 @@ x_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
      redraw anyhow. */
   MAYBE_FRAMEMETH (f, redraw_exposed_toolbars, (f, x, y, width, height));
 #endif
-  redraw_exposed_gutters (f, x, y, width, height);
 
   if (!f->window_face_cache_reset)
     {
@@ -1875,27 +1974,110 @@ x_redraw_exposed_area (struct frame *f, int x, int y, int width, int height)
  given face.
  ****************************************************************************/
 static void
-x_clear_region (Lisp_Object locale, struct device* d, struct frame* f, face_index findex,
-               int x, int y,
-               int width, int height, Lisp_Object fcolor, Lisp_Object bcolor,
-               Lisp_Object background_pixmap)
+x_clear_region (Lisp_Object locale, face_index findex, int x, int y,
+               int width, int height)
 {
+  struct window *w = NULL;
+  struct frame *f = NULL;
+  struct device *d;
+  Lisp_Object background_pixmap;
+
   Display *dpy;
   Window x_win;
-  GC gc = NULL;
 
+  if (WINDOWP (locale))
+    {
+      w = XWINDOW (locale);
+      f = XFRAME (w->frame);
+    }
+  else if (FRAMEP (locale))
+    {
+      w = NULL;
+      f = XFRAME (locale);
+    }
+  else
+    abort ();
+
+  d = XDEVICE (f->device);
   dpy = DEVICE_X_DISPLAY (d);
   x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
 
-    if (!UNBOUNDP (background_pixmap))
+  /* #### This function is going to have to be made cursor aware. */
+  if (width && height)
     {
-      gc = x_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
-    }
+      GC gc = NULL;
 
-  if (gc)
-    XFillRectangle (dpy, x_win, gc, x, y, width, height);
-  else
-    XClearArea (dpy, x_win, x, y, width, height, False);
+      /* #### This isn't quite right for when this function is called
+         from the toolbar code. */
+      background_pixmap = Qunbound;
+
+      /* Don't use a backing pixmap in the border area */
+      if (x >= FRAME_LEFT_BORDER_END (f)
+         && x < FRAME_RIGHT_BORDER_START (f)
+         && y >= FRAME_TOP_BORDER_END (f)
+         && y < FRAME_BOTTOM_BORDER_START (f))
+       {
+         Lisp_Object temp;
+
+         if (w)
+           {
+             temp = WINDOW_FACE_CACHEL_BACKGROUND_PIXMAP (w, findex);
+
+             if (IMAGE_INSTANCEP (temp)
+                 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
+               {
+                 /* #### maybe we could implement such that a string
+                    can be a background pixmap? */
+                 background_pixmap = temp;
+               }
+           }
+         else
+           {
+             temp = FACE_BACKGROUND_PIXMAP (Vdefault_face, locale);
+
+             if (IMAGE_INSTANCEP (temp)
+                 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (temp)))
+               {
+                 background_pixmap = temp;
+               }
+           }
+
+         if (!UNBOUNDP (background_pixmap) &&
+             XIMAGE_INSTANCE_PIXMAP_DEPTH (background_pixmap) == 0)
+           {
+             Lisp_Object fcolor, bcolor;
+
+             if (w)
+               {
+                 fcolor = WINDOW_FACE_CACHEL_FOREGROUND (w, findex);
+                 bcolor = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
+               }
+             else
+               {
+                 fcolor = FACE_FOREGROUND (Vdefault_face, locale);
+                 bcolor = FACE_BACKGROUND (Vdefault_face, locale);
+               }
+
+             gc = x_get_gc (d, Qnil, fcolor, bcolor, background_pixmap, Qnil);
+           }
+         else
+           {
+             Lisp_Object color = (w ?
+                                  WINDOW_FACE_CACHEL_BACKGROUND (w, findex) :
+                                  FACE_BACKGROUND (Vdefault_face, locale));
+
+             if (UNBOUNDP (background_pixmap))
+               background_pixmap = Qnil;
+
+             gc = x_get_gc (d, Qnil, color, Qnil, background_pixmap, Qnil);
+           }
+       }
+
+      if (gc)
+       XFillRectangle (dpy, x_win, gc, x, y, width, height);
+      else
+       XClearArea (dpy, x_win, x, y, width, height, False);
+    }
 }
 
 /*****************************************************************************
@@ -1930,7 +2112,7 @@ x_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
   int defheight, defascent;
 
   XSETWINDOW (window, w);
-  redisplay_clear_region (window, findex, x, y, width, height);
+  x_clear_region (window, findex, x, y, width, height);
 
   if (NILP (w->text_cursor_visible_p))
     return;
@@ -1988,8 +2170,7 @@ x_clear_frame_window (Lisp_Object window)
       return;
     }
 
-  redisplay_clear_to_window_end (w, WINDOW_TEXT_TOP (w), 
-                                WINDOW_TEXT_BOTTOM (w));
+  x_clear_to_window_end (w, WINDOW_TEXT_TOP (w), WINDOW_TEXT_BOTTOM (w));
 }
 
 static void
@@ -2146,11 +2327,11 @@ console_type_create_redisplay_x (void)
   CONSOLE_HAS_METHOD (x, divider_height);
   CONSOLE_HAS_METHOD (x, eol_cursor_width);
   CONSOLE_HAS_METHOD (x, output_vertical_divider);
+  CONSOLE_HAS_METHOD (x, clear_to_window_end);
   CONSOLE_HAS_METHOD (x, clear_region);
   CONSOLE_HAS_METHOD (x, clear_frame);
   CONSOLE_HAS_METHOD (x, output_begin);
   CONSOLE_HAS_METHOD (x, output_end);
   CONSOLE_HAS_METHOD (x, flash);
   CONSOLE_HAS_METHOD (x, ring_bell);
-  CONSOLE_HAS_METHOD (x, bevel_area);
 }