XEmacs 21.2.20 "Yoko".
[chise/xemacs-chise.git.1] / src / redisplay-x.c
index cf1766e..d599c91 100644 (file)
@@ -54,17 +54,10 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 /* Number of pixels below each line. */
-/* #### implement me */
-int x_interline_space;
+int x_interline_space; /* #### implement me */
 
 #define EOL_CURSOR_WIDTH       5
 
-static void x_output_pixmap (struct window *w, struct display_line *dl,
-                            Lisp_Object image_instance, int xpos,
-                            int xoffset,
-                            int start_pixpos, int width, face_index findex,
-                            int cursor_start, int cursor_width,
-                            int cursor_height);
 static void x_output_vertical_divider (struct window *w, int clear);
 static void x_output_blank (struct window *w, struct display_line *dl,
                            struct rune *rb, int start_pixpos,
@@ -79,7 +72,6 @@ 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);
 
 
      /* Note: We do not use the Xmb*() functions and XFontSets.
@@ -408,10 +400,10 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
              else if (rb->object.chr.ch == '\n')
                {
                  /* 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,
-                                 rb->width, height);
+                 redisplay_clear_region (window, findex, xpos, 
+                                         DISPLAY_LINE_YPOS (dl),
+                                         rb->width, 
+                                         DISPLAY_LINE_HEIGHT (dl));
                  elt++;
                }
            }
@@ -445,6 +437,11 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
          else if (rb->type == RUNE_DGLYPH)
            {
              Lisp_Object instance;
+             struct display_box dbox;
+             struct display_glyph_area dga;
+             redisplay_calculate_display_boxes (dl, rb->xpos, rb->object.dglyph.xoffset,
+                                                start_pixpos, rb->width,
+                                                &dbox, &dga);
 
              XSETWINDOW (window, w);
              instance = glyph_image_instance (rb->object.dglyph.glyph,
@@ -475,26 +472,29 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
 
                  case IMAGE_MONO_PIXMAP:
                  case IMAGE_COLOR_PIXMAP:
-                   x_output_pixmap (w, dl, instance, xpos,
-                                    rb->object.dglyph.xoffset, start_pixpos,
-                                    rb->width, findex, cursor_start,
-                                    cursor_width, cursor_height);
+                   redisplay_output_pixmap (w, instance, &dbox, &dga, findex,
+                                            cursor_start, cursor_width,
+                                            cursor_height, 0);
                    break;
 
-                 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);
+                   redisplay_output_subwindow (w, instance, &dbox, &dga, findex,
+                                               cursor_start, cursor_width,
+                                               cursor_height);
+                   break;
+
+                 case IMAGE_LAYOUT:
+                   redisplay_output_layout (w, instance, &dbox, &dga, findex,
+                                            cursor_start, cursor_width,
+                                            cursor_height);
+                   break;
 
                  case IMAGE_NOTHING:
                    /* nothing is as nothing does */
                    break;
 
+                 case IMAGE_POINTER:
                  default:
                    abort ();
                  }
@@ -531,7 +531,7 @@ x_output_display_block (struct window *w, struct display_line *dl, int block,
 static void
 x_bevel_area (struct window *w, face_index findex,
              int x, int y, int width, int height,
-             int shadow_thickness)
+             int shadow_thickness, int edges, enum edge_style style)
 {
   struct frame *f = XFRAME (w->frame);
   struct device *d = XDEVICE (f->device);
@@ -549,6 +549,7 @@ x_bevel_area (struct window *w, face_index findex,
   int flip_gcs = 0;
   unsigned long mask;
 
+  assert (shadow_thickness >=0);
   memset (&gcv, ~0, sizeof (XGCValues));
 
   tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
@@ -618,24 +619,33 @@ 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)
+  /* possibly revert the GC's This will give a depressed look to the
+     divider */
+  if (style == EDGE_ETCHED_IN || style == EDGE_BEVEL_IN)
     {
       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;
     }
 
+  if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
+    shadow_thickness /= 2;
+
   /* Draw the shadows around the divider line */
   x_output_shadows (f, x, y, width, height,
                    top_shadow_gc, bottom_shadow_gc,
-                   background_gc, shadow_thickness);
+                   background_gc, shadow_thickness, edges);
+
+  if (style == EDGE_ETCHED_IN || style == EDGE_ETCHED_OUT)
+    {
+      /* Draw the shadows around the divider line */
+      x_output_shadows (f, x + shadow_thickness, y + shadow_thickness,
+                       width - 2*shadow_thickness, height - 2*shadow_thickness,
+                       bottom_shadow_gc, top_shadow_gc,
+                       background_gc, shadow_thickness, edges);
+    }
 }
 
 /*****************************************************************************
@@ -803,7 +813,7 @@ x_output_string (struct window *w, struct display_line *dl,
 
   if (width < 0)
     width = x_text_width (f, cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
-  height = dl->ascent + dl->descent - dl->clip;
+  height = DISPLAY_LINE_HEIGHT (dl);
 
   /* Regularize the variables passed in. */
 
@@ -816,6 +826,10 @@ x_output_string (struct window *w, struct display_line *dl,
 
   xpos -= xoffset;
 
+  /* make sure the area we are about to display is subwindow free. */
+  redisplay_unmap_subwindows_maybe (f, clip_start, DISPLAY_LINE_YPOS (dl),
+                                   clip_end - clip_start, DISPLAY_LINE_HEIGHT (dl));
+
   nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
                                 Dynarr_length (buf));
 
@@ -860,7 +874,7 @@ x_output_string (struct window *w, struct display_line *dl,
 
   if (bgc)
     XFillRectangle (dpy, x_win, bgc, clip_start,
-                   dl->ypos - dl->ascent, clip_end - clip_start,
+                   DISPLAY_LINE_YPOS (dl), clip_end - clip_start,
                    height);
 
   for (i = 0; i < nruns; i++)
@@ -881,7 +895,7 @@ x_output_string (struct window *w, struct display_line *dl,
         the given font.  It is possible that a font is being displayed
         on a line taller than it is, so this would cause us to fail to
         clear some areas. */
-      if ((int) fi->height < (int) (height + dl->clip))
+      if ((int) fi->height < (int) (height + dl->clip + dl->top_clip))
        {
          int clear_start = max (xpos, clip_start);
          int clear_end = min (xpos + this_width, clip_end);
@@ -892,8 +906,8 @@ x_output_string (struct window *w, struct display_line *dl,
 
              ypos1_string = dl->ypos - fi->ascent;
              ypos2_string = dl->ypos + fi->descent;
-             ypos1_line = dl->ypos - dl->ascent;
-             ypos2_line = dl->ypos + dl->descent - dl->clip;
+             ypos1_line = DISPLAY_LINE_YPOS (dl);
+             ypos2_line = ypos1_line + DISPLAY_LINE_HEIGHT (dl);
 
              /* Make sure we don't clear below the real bottom of the
                 line. */
@@ -919,7 +933,7 @@ x_output_string (struct window *w, struct display_line *dl,
          else
            {
              redisplay_clear_region (window, findex, clear_start,
-                             dl->ypos - dl->ascent, clear_end - clear_start,
+                             DISPLAY_LINE_YPOS (dl), clear_end - clear_start,
                              height);
            }
        }
@@ -952,7 +966,7 @@ x_output_string (struct window *w, struct display_line *dl,
          clip_box[0].width = clip_end - clip_start;
          clip_box[0].height = height;
 
-         XSetClipRectangles (dpy, gc, clip_start, dl->ypos - dl->ascent,
+         XSetClipRectangles (dpy, gc, clip_start, DISPLAY_LINE_YPOS (dl),
                              clip_box, 1, Unsorted);
        }
 
@@ -1052,7 +1066,7 @@ x_output_string (struct window *w, struct display_line *dl,
          clip_box[0].width = cursor_width;
          clip_box[0].height = height;
 
-         XSetClipRectangles (dpy, cgc, cursor_start, dl->ypos - dl->ascent,
+         XSetClipRectangles (dpy, cgc, cursor_start, DISPLAY_LINE_YPOS (dl),
                              clip_box, 1, Unsorted);
 
          if (runs[i].dimension == 1)
@@ -1112,12 +1126,12 @@ x_output_string (struct window *w, struct display_line *dl,
 
       tmp_y = dl->ypos - bogusly_obtained_ascent_value;
       tmp_height = cursor_height;
-      if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height))
+      if (tmp_y + tmp_height > (int) (DISPLAY_LINE_YPOS(dl) + height))
        {
-         tmp_y = dl->ypos - dl->ascent + height - tmp_height;
-         if (tmp_y < (int) (dl->ypos - dl->ascent))
-           tmp_y = dl->ypos - dl->ascent;
-         tmp_height = dl->ypos - dl->ascent + height - tmp_y;
+         tmp_y = DISPLAY_LINE_YPOS (dl) + height - tmp_height;
+         if (tmp_y < (int) DISPLAY_LINE_YPOS (dl))
+           tmp_y = DISPLAY_LINE_YPOS (dl);
+         tmp_height = DISPLAY_LINE_YPOS (dl) + height - tmp_y;
        }
 
       if (need_clipping)
@@ -1153,9 +1167,9 @@ x_output_string (struct window *w, struct display_line *dl,
 
 void
 x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
-                  int y, int clip_x, int clip_y, int clip_width,
-                  int clip_height, int width, int height, int pixmap_offset,
-                  unsigned long fg, unsigned long bg, GC override_gc)
+                  int y, int xoffset, int yoffset,
+                  int width, int height, unsigned long fg, unsigned long bg, 
+                  GC override_gc)
 {
   struct device *d = XDEVICE (f->device);
   Display *dpy = DEVICE_X_DISPLAY (d);
@@ -1164,7 +1178,6 @@ x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
   GC gc;
   XGCValues gcv;
   unsigned long pixmap_mask;
-  int need_clipping = (clip_x || clip_y);
 
   if (!override_gc)
     {
@@ -1178,17 +1191,16 @@ x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
        {
          gcv.function = GXcopy;
          gcv.clip_mask = IMAGE_INSTANCE_X_MASK (p);
-         gcv.clip_x_origin = x;
-         gcv.clip_y_origin = y - pixmap_offset;
+         gcv.clip_x_origin = x - xoffset;
+         gcv.clip_y_origin = y - yoffset;
          pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin |
                          GCClipYOrigin);
-         /* Can't set a clip rectangle below because we already have a mask.
-            We could conceivably create a new clipmask by zeroing out
-            everything outside the clip region.  Is it worth it?
+         /* Can't set a clip rectangle because we already have a mask.
             Is it possible to get an equivalent effect by changing the
             args to XCopyArea below rather than messing with a clip box?
-            - dkindred@cs.cmu.edu */
-         need_clipping = 0;
+            - dkindred@cs.cmu.edu
+            Yes. We don't clip at all now - andy@xemacs.org
+         */
        }
 
       gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask);
@@ -1199,19 +1211,6 @@ x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
       /* override_gc might have a mask already--we don't want to nuke it.
         Maybe we can insist that override_gc have no mask, or use
         one of the suggestions above. */
-      need_clipping = 0;
-    }
-
-  if (need_clipping)
-    {
-      XRectangle clip_box[1];
-
-      clip_box[0].x = clip_x;
-      clip_box[0].y = clip_y;
-      clip_box[0].width = clip_width;
-      clip_box[0].height = clip_height;
-
-      XSetClipRectangles (dpy, gc, x, y, clip_box, 1, Unsorted);
     }
 
   /* depth of 0 means it's a bitmap, not a pixmap, and we should use
@@ -1220,126 +1219,33 @@ x_output_x_pixmap (struct frame *f, struct Lisp_Image_Instance *p, int x,
      pixel values, instead of symbolic of fg/bg. */
   if (IMAGE_INSTANCE_PIXMAP_DEPTH (p) > 0)
     {
-      XCopyArea (dpy, IMAGE_INSTANCE_X_PIXMAP (p), x_win, gc, 0,
-                pixmap_offset, width,
+      XCopyArea (dpy, 
+                IMAGE_INSTANCE_X_PIXMAP_SLICE 
+                (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc, xoffset,
+                yoffset, width,
                 height, x, y);
     }
   else
     {
-      XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP (p), x_win, gc, 0,
-                 (pixmap_offset < 0
-                  ? 0
-                  : pixmap_offset),
-                 width, height, x,
-                 (pixmap_offset < 0
-                  ? y - pixmap_offset
-                  : y),
-                 1L);
-    }
-
-  if (need_clipping)
-    {
-      XSetClipMask (dpy, gc, None);
-      XSetClipOrigin (dpy, gc, 0, 0);
+      XCopyPlane (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE 
+                 (p, IMAGE_INSTANCE_PIXMAP_SLICE (p)), x_win, gc,
+                 xoffset, yoffset, width, height, x, y, 1L);
     }
 }
 
 static void
-x_output_pixmap (struct window *w, struct display_line *dl,
-                Lisp_Object image_instance, int xpos, int xoffset,
-                int start_pixpos, int width, face_index findex,
-                int cursor_start, int cursor_width, int cursor_height)
+x_output_pixmap (struct window *w, Lisp_Object image_instance,
+                struct display_box *db, struct display_glyph_area *dga,
+                face_index findex, int cursor_start, int cursor_width,
+                int cursor_height, int bg_pixmap)
 {
   struct frame *f = XFRAME (w->frame);
   struct device *d = XDEVICE (f->device);
   struct Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
-  Lisp_Object window;
 
   Display *dpy = DEVICE_X_DISPLAY (d);
   Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
-  int lheight = dl->ascent + dl->descent - dl->clip;
-  int pheight = ((int) IMAGE_INSTANCE_PIXMAP_HEIGHT (p) > lheight ? lheight :
-                IMAGE_INSTANCE_PIXMAP_HEIGHT (p));
-  int pwidth = min (width + xoffset, (int) IMAGE_INSTANCE_PIXMAP_WIDTH (p));
-  int clip_x, clip_y, clip_width, clip_height;
-
-  /* The pixmap_offset is used to center the pixmap on lines which are
-     shorter than it is.  This results in odd effects when scrolling
-     pixmaps off of the bottom.  Let's try not using it. */
-#if 0
-  int pixmap_offset = (int) (IMAGE_INSTANCE_PIXMAP_HEIGHT (p) - lheight) / 2;
-#else
-  int pixmap_offset = 0;
-#endif
-
-  XSETWINDOW (window, w);
-
-  if ((start_pixpos >= 0 && start_pixpos > xpos) || xoffset)
-    {
-      if (start_pixpos > xpos && start_pixpos > xpos + width)
-       return;
-
-      clip_x = xoffset;
-      clip_width = width;
-      if (start_pixpos > xpos)
-       {
-         clip_x += (start_pixpos - xpos);
-         clip_width -= (start_pixpos - xpos);
-       }
-    }
-  else
-    {
-      clip_x = 0;
-      clip_width = 0;
-    }
-
-  /* Place markers for possible future functionality (clipping the top
-     half instead of the bottom half; think pixel scrolling). */
-  clip_y = 0;
-  clip_height = pheight;
-
-  /* Clear the area the pixmap is going into.  The pixmap itself will
-     always take care of the full width.  We don't want to clear where
-     it is going to go in order to avoid flicker.  So, all we have to
-     take care of is any area above or below the pixmap. */
-  /* #### We take a shortcut for now.  We know that since we have
-     pixmap_offset hardwired to 0 that the pixmap is against the top
-     edge so all we have to worry about is below it. */
-  /* #### Unless the pixmap has a mask in which case we have to clear
-     the whole damn thing since we can't yet clear just the area not
-     included in the mask. */
-  if (((int) (dl->ypos - dl->ascent + pheight) <
-       (int) (dl->ypos + dl->descent - dl->clip))
-      || IMAGE_INSTANCE_X_MASK (p))
-    {
-      int clear_x, clear_y, clear_width, clear_height;
-
-      if (IMAGE_INSTANCE_X_MASK (p))
-       {
-         clear_y = dl->ypos - dl->ascent;
-         clear_height = lheight;
-       }
-      else
-       {
-         clear_y = dl->ypos - dl->ascent + pheight;
-         clear_height = lheight - pheight;
-       }
-
-      if (start_pixpos >= 0 && start_pixpos > xpos)
-       {
-         clear_x = start_pixpos;
-         clear_width = xpos + width - start_pixpos;
-       }
-      else
-       {
-         clear_x = xpos;
-         clear_width = width;
-       }
-
-      redisplay_clear_region (window, findex, clear_x, clear_y,
-                     clear_width, clear_height);
-    }
-
   /* Output the pixmap. */
   {
     Lisp_Object tmp_pixel;
@@ -1350,20 +1256,19 @@ x_output_pixmap (struct window *w, struct display_line *dl,
     tmp_pixel = WINDOW_FACE_CACHEL_BACKGROUND (w, findex);
     tmp_bcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
 
-    x_output_x_pixmap (f, p, xpos - xoffset, dl->ypos - dl->ascent, clip_x,
-                      clip_y, clip_width, clip_height,
-                      pwidth, pheight, pixmap_offset,
+    x_output_x_pixmap (f, p, db->xpos, db->ypos,
+                      dga->xoffset, dga->yoffset,
+                      dga->width, dga->height,
                       tmp_fcolor.pixel, tmp_bcolor.pixel, 0);
   }
 
   /* Draw a cursor over top of the pixmap. */
-  if (cursor_width && cursor_height && (cursor_start >= xpos)
+  if (cursor_width && cursor_height && (cursor_start >= db->xpos)
       && !NILP (w->text_cursor_visible_p)
-      && (cursor_start < xpos + pwidth))
+      && (cursor_start < db->xpos + dga->width))
     {
       GC gc;
       int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
-      int y = dl->ypos - dl->ascent;
       struct face_cachel *cursor_cachel =
        WINDOW_FACE_CACHEL (w,
                            get_builtin_face_cache_index
@@ -1371,17 +1276,17 @@ x_output_pixmap (struct window *w, struct display_line *dl,
 
       gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, Qnil);
 
-      if (cursor_width > xpos + pwidth - cursor_start)
-       cursor_width = xpos + pwidth - cursor_start;
+      if (cursor_width > db->xpos + dga->width - cursor_start)
+       cursor_width = db->xpos + dga->width - cursor_start;
 
       if (focus)
        {
-         XFillRectangle (dpy, x_win, gc, cursor_start, y, cursor_width,
+         XFillRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
                          cursor_height);
        }
       else
        {
-         XDrawRectangle (dpy, x_win, gc, cursor_start, y, cursor_width,
+         XDrawRectangle (dpy, x_win, gc, cursor_start, db->ypos, cursor_width,
                          cursor_height);
        }
     }
@@ -1404,6 +1309,7 @@ x_output_vertical_divider (struct window *w, int clear)
   XColor tmp_color;
   XGCValues gcv;
   GC background_gc;
+  enum edge_style style;
 
   unsigned long mask;
   int x, y1, y2, width, shadow_thickness, spacing, line_width;
@@ -1439,10 +1345,20 @@ x_output_vertical_divider (struct window *w, int clear)
                  x + spacing + shadow_thickness, y1,
                  line_width, y2 - y1);
 
+  if (shadow_thickness < 0)
+    {
+      shadow_thickness = -shadow_thickness;
+      style = EDGE_BEVEL_IN;
+    }
+  else
+    {
+      style = EDGE_BEVEL_OUT;
+    }
+
   /* Draw the shadows around the divider line */
   x_bevel_area (w, div_face, x + spacing, y1,
                width - 2 * spacing, y2 - y1,
-               shadow_thickness);
+               shadow_thickness, EDGE_ALL, style);
 }
 
 /*****************************************************************************
@@ -1471,9 +1387,12 @@ x_output_blank (struct window *w, struct display_line *dl, struct rune *rb,
                                                         buffer);
 
   int x = rb->xpos;
-  int y = dl->ypos - dl->ascent;
+  int y = DISPLAY_LINE_YPOS (dl);
   int width = rb->width;
-  int height = dl->ascent + dl->descent - dl->clip;
+  int height = DISPLAY_LINE_HEIGHT (dl);
+
+  /* Unmap all subwindows in the area we are going to blank. */
+  redisplay_unmap_subwindows_maybe (f, x, y, width, height);
 
   if (start_pixpos > x)
     {
@@ -1567,10 +1486,10 @@ x_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
 
   int x = rb->xpos;
   int width = rb->width;
-  int height = dl->ascent + dl->descent - dl->clip;
+  int height = DISPLAY_LINE_HEIGHT (dl);
   int ypos1, ypos2, ypos3, ypos4;
 
-  ypos1 = dl->ypos - dl->ascent;
+  ypos1 = DISPLAY_LINE_YPOS (dl);
   ypos2 = ypos1 + rb->object.hline.yoffset;
   ypos3 = ypos2 + rb->object.hline.thickness;
   ypos4 = dl->ypos + dl->descent - dl->clip;
@@ -1609,7 +1528,7 @@ x_output_hline (struct window *w, struct display_line *dl, struct rune *rb)
 void
 x_output_shadows (struct frame *f, int x, int y, int width, int height,
                  GC top_shadow_gc, GC bottom_shadow_gc, GC background_gc,
-                 int shadow_thickness)
+                 int shadow_thickness, int edges)
 {
   struct device *d = XDEVICE (f->device);
 
@@ -1631,28 +1550,41 @@ x_output_shadows (struct frame *f, int x, int y, int width, int height,
   for (elt = 0; elt < shadow_thickness; elt++)
     {
       int seg1 = elt;
-      int seg2 = elt + shadow_thickness;
-
-      top_shadow[seg1].x1 = x;
-      top_shadow[seg1].x2 = x + width - elt - 1;
-      top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
-
-      top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
-      top_shadow[seg2].y1 = y + shadow_thickness;
-      top_shadow[seg2].y2 = y + height - elt - 1;
+      int seg2 = (edges & EDGE_TOP) ? elt + shadow_thickness : elt;
+      int bot_seg2 = (edges & EDGE_BOTTOM) ? elt + shadow_thickness : elt;
 
-      bottom_shadow[seg1].x1 = x + elt + 1;
-      bottom_shadow[seg1].x2 = x + width - 1;
-      bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
-
-      bottom_shadow[seg2].x1 = bottom_shadow[seg2].x2 = x + width - elt - 1;
-      bottom_shadow[seg2].y1 = y + elt + 1;
-      bottom_shadow[seg2].y2 = y + height - shadow_thickness;
+      if (edges & EDGE_TOP)
+       {
+         top_shadow[seg1].x1 = x + elt;
+         top_shadow[seg1].x2 = x + width - elt - 1;
+         top_shadow[seg1].y1 = top_shadow[seg1].y2 = y + elt;
+       }
+      if (edges & EDGE_LEFT)
+       {
+         top_shadow[seg2].x1 = top_shadow[seg2].x2 = x + elt;
+         top_shadow[seg2].y1 = y + elt;
+         top_shadow[seg2].y2 = y + height - elt - 1;
+       }
+      if (edges & EDGE_BOTTOM)
+       {
+         bottom_shadow[seg1].x1 = x + elt;
+         bottom_shadow[seg1].x2 = x + width - elt - 1;
+         bottom_shadow[seg1].y1 = bottom_shadow[seg1].y2 = y + height - elt - 1;
+       }
+      if (edges & EDGE_RIGHT)
+       {
+         bottom_shadow[bot_seg2].x1 = bottom_shadow[bot_seg2].x2 = x + width - elt - 1;
+         bottom_shadow[bot_seg2].y1 = y + elt;
+         bottom_shadow[bot_seg2].y2 = y + height - elt - 1;
+       }
     }
 
-  XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow, shadow_thickness * 2);
+  XDrawSegments (dpy, x_win, top_shadow_gc, top_shadow,
+                ((edges & EDGE_TOP) ? shadow_thickness : 0)
+                + ((edges & EDGE_LEFT) ? shadow_thickness : 0));
   XDrawSegments (dpy, x_win, bottom_shadow_gc, bottom_shadow,
-                shadow_thickness * 2);
+                ((edges & EDGE_BOTTOM) ? shadow_thickness : 0)
+                + ((edges & EDGE_RIGHT) ? shadow_thickness : 0));
 }
 
 /*****************************************************************************
@@ -1923,9 +1855,9 @@ x_output_eol_cursor (struct window *w, struct display_line *dl, int xpos,
                                                         WINDOW_BUFFER (w));
 
   int x = xpos;
-  int y = dl->ypos - dl->ascent;
+  int y = DISPLAY_LINE_YPOS (dl);
   int width = EOL_CURSOR_WIDTH;
-  int height = dl->ascent + dl->descent - dl->clip;
+  int height = DISPLAY_LINE_HEIGHT (dl);
   int cursor_height, cursor_y;
   int defheight, defascent;
 
@@ -2153,4 +2085,6 @@ console_type_create_redisplay_x (void)
   CONSOLE_HAS_METHOD (x, flash);
   CONSOLE_HAS_METHOD (x, ring_bell);
   CONSOLE_HAS_METHOD (x, bevel_area);
+  CONSOLE_HAS_METHOD (x, output_string);
+  CONSOLE_HAS_METHOD (x, output_pixmap);
 }