emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xterm.c


From: Juanma Barranquero
Subject: [Emacs-diffs] Changes to emacs/src/xterm.c
Date: Fri, 18 Oct 2002 06:10:09 -0400

Index: emacs/src/xterm.c
diff -c emacs/src/xterm.c:1.755 emacs/src/xterm.c:1.756
*** emacs/src/xterm.c:1.755     Sat Oct  5 19:36:29 2002
--- emacs/src/xterm.c   Fri Oct 18 06:09:43 2002
***************
*** 238,244 ****
  
  /* If a string, XTread_socket generates an event to display that string.
     (The display is done in read_char.)  */
!    
  static Lisp_Object help_echo;
  static Lisp_Object help_echo_window;
  static Lisp_Object help_echo_object;
--- 238,244 ----
  
  /* If a string, XTread_socket generates an event to display that string.
     (The display is done in read_char.)  */
! 
  static Lisp_Object help_echo;
  static Lisp_Object help_echo_window;
  static Lisp_Object help_echo_object;
***************
*** 299,305 ****
  static String Xt_default_resources[] = {0};
  #endif /* USE_X_TOOLKIT */
  
! /* Nominal cursor position -- where to draw output.  
     HPOS and VPOS are window relative glyph matrix coordinates.
     X and Y are window relative pixel coordinates.  */
  
--- 299,305 ----
  static String Xt_default_resources[] = {0};
  #endif /* USE_X_TOOLKIT */
  
! /* Nominal cursor position -- where to draw output.
     HPOS and VPOS are window relative glyph matrix coordinates.
     X and Y are window relative pixel coordinates.  */
  
***************
*** 496,502 ****
  static void x_update_window_cursor P_ ((struct window *, int));
  static void x_erase_phys_cursor P_ ((struct window *));
  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
! static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *, 
                                      enum fringe_bitmap_type, int left_p));
  
  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
--- 496,502 ----
  static void x_update_window_cursor P_ ((struct window *, int));
  static void x_erase_phys_cursor P_ ((struct window *));
  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
! static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *,
                                      enum fringe_bitmap_type, int left_p));
  
  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
***************
*** 546,552 ****
     XTread_socket calls XPending.  Removing XFlush improves
     performance.  */
  
! #define XFlush(DISPLAY)       (void) 0 
  
  
  /***********************************************************************
--- 546,552 ----
     XTread_socket calls XPending.  Removing XFlush improves
     performance.  */
  
! #define XFlush(DISPLAY)       (void) 0
  
  
  /***********************************************************************
***************
*** 558,564 ****
  /* This is a function useful for recording debugging information about
     the sequence of occurrences in this file.  */
  
! struct record 
  {
    char *locus;
    int type;
--- 558,564 ----
  /* This is a function useful for recording debugging information about
     the sequence of occurrences in this file.  */
  
! struct record
  {
    char *locus;
    int type;
***************
*** 604,610 ****
  /***********************************************************************
                    Starting and ending an update
   ***********************************************************************/
!                                                                       
  /* Start an update of frame F.  This function is installed as a hook
     for update_begin, i.e. it is called when update_begin is called.
     This function is called prior to calls to x_update_window_begin for
--- 604,610 ----
  /***********************************************************************
                    Starting and ending an update
   ***********************************************************************/
! 
  /* Start an update of frame F.  This function is installed as a hook
     for update_begin, i.e. it is called when update_begin is called.
     This function is called prior to calls to x_update_window_begin for
***************
*** 629,635 ****
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
!   
    updated_window = w;
    set_output_cursor (&w->cursor);
  
--- 629,635 ----
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
! 
    updated_window = w;
    set_output_cursor (&w->cursor);
  
***************
*** 651,657 ****
         flag set.  So, rows containing mouse-face glyphs are never
         scrolled, and we don't have to switch the mouse highlight off
         here to prevent it from being scrolled.  */
!       
        /* Can we tell that this update does not affect the window
         where the mouse highlight is?  If so, no need to turn off.
         Likewise, don't do anything if the frame is garbaged;
--- 651,657 ----
         flag set.  So, rows containing mouse-face glyphs are never
         scrolled, and we don't have to switch the mouse highlight off
         here to prevent it from being scrolled.  */
! 
        /* Can we tell that this update does not affect the window
         where the mouse highlight is?  If so, no need to turn off.
         Likewise, don't do anything if the frame is garbaged;
***************
*** 684,690 ****
       struct window *w;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
!   
    /* Redraw borders between horizontally adjacent windows.  Don't
       do it for frames with vertical scroll bars because either the
       right scroll bar of a window, or the left scroll bar of its
--- 684,690 ----
       struct window *w;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
! 
    /* Redraw borders between horizontally adjacent windows.  Don't
       do it for frames with vertical scroll bars because either the
       right scroll bar of a window, or the left scroll bar of its
***************
*** 697,709 ****
        window_box_edges (w, -1, &x0, &y0, &x1, &y1);
        x1 += FRAME_X_RIGHT_FRINGE_WIDTH (f);
        y1 -= 1;
!       
!       XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 
                 f->output_data.x->normal_gc, x1, y0, x1, y1);
      }
  }
!    
!    
  /* End update of window W (which is equal to updated_window).
  
     Draw vertical borders between horizontally adjacent windows, and
--- 697,709 ----
        window_box_edges (w, -1, &x0, &y0, &x1, &y1);
        x1 += FRAME_X_RIGHT_FRINGE_WIDTH (f);
        y1 -= 1;
! 
!       XDrawLine (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                 f->output_data.x->normal_gc, x1, y0, x1, y1);
      }
  }
! 
! 
  /* End update of window W (which is equal to updated_window).
  
     Draw vertical borders between horizontally adjacent windows, and
***************
*** 723,729 ****
       int cursor_on_p, mouse_face_overwritten_p;
  {
    struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
!       
    if (!w->pseudo_window_p)
      {
        BLOCK_INPUT;
--- 723,729 ----
       int cursor_on_p, mouse_face_overwritten_p;
  {
    struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
! 
    if (!w->pseudo_window_p)
      {
        BLOCK_INPUT;
***************
*** 732,742 ****
        x_display_and_set_cursor (w, 1, output_cursor.hpos,
                                  output_cursor.vpos,
                                  output_cursor.x, output_cursor.y);
!       
        x_draw_vertical_border (w);
        UNBLOCK_INPUT;
      }
!   
    /* If a row with mouse-face was overwritten, arrange for
       XTframe_up_to_date to redisplay the mouse highlight.  */
    if (mouse_face_overwritten_p)
--- 732,742 ----
        x_display_and_set_cursor (w, 1, output_cursor.hpos,
                                  output_cursor.vpos,
                                  output_cursor.x, output_cursor.y);
! 
        x_draw_vertical_border (w);
        UNBLOCK_INPUT;
      }
! 
    /* If a row with mouse-face was overwritten, arrange for
       XTframe_up_to_date to redisplay the mouse highlight.  */
    if (mouse_face_overwritten_p)
***************
*** 745,751 ****
        dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
        dpyinfo->mouse_face_window = Qnil;
      }
!       
    updated_window = NULL;
  }
  
--- 745,751 ----
        dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
        dpyinfo->mouse_face_window = Qnil;
      }
! 
    updated_window = NULL;
  }
  
***************
*** 807,822 ****
    struct window *w = updated_window;
    struct frame *f;
    int width, height;
!   
    xassert (w);
!   
    if (!desired_row->mode_line_p && !w->pseudo_window_p)
      {
        BLOCK_INPUT;
        x_draw_row_fringe_bitmaps (w, desired_row);
        UNBLOCK_INPUT;
      }
!       
    /* When a window has disappeared, make sure that no rest of
       full-width rows stays visible in the internal border.  Could
       check here if updated_window is the leftmost/rightmost window,
--- 807,822 ----
    struct window *w = updated_window;
    struct frame *f;
    int width, height;
! 
    xassert (w);
! 
    if (!desired_row->mode_line_p && !w->pseudo_window_p)
      {
        BLOCK_INPUT;
        x_draw_row_fringe_bitmaps (w, desired_row);
        UNBLOCK_INPUT;
      }
! 
    /* When a window has disappeared, make sure that no rest of
       full-width rows stays visible in the internal border.  Could
       check here if updated_window is the leftmost/rightmost window,
***************
*** 837,843 ****
        if (WINDOWP (f->tool_bar_window)
          && w == XWINDOW (f->tool_bar_window))
        y -= width;
!       
        BLOCK_INPUT;
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
--- 837,843 ----
        if (WINDOWP (f->tool_bar_window)
          && w == XWINDOW (f->tool_bar_window))
        y -= width;
! 
        BLOCK_INPUT;
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    0, y, width, height, False);
***************
*** 890,902 ****
        h = left_height;
        bits = left_bits;
        break;
!       
      case OVERLAY_ARROW_BITMAP:
        wd = ov_width;
        h = ov_height;
        bits = ov_bits;
        break;
!       
      case RIGHT_TRUNCATION_BITMAP:
        wd = right_width;
        h = right_height;
--- 890,902 ----
        h = left_height;
        bits = left_bits;
        break;
! 
      case OVERLAY_ARROW_BITMAP:
        wd = ov_width;
        h = ov_height;
        bits = ov_bits;
        break;
! 
      case RIGHT_TRUNCATION_BITMAP:
        wd = right_width;
        h = right_height;
***************
*** 908,914 ****
        h = continued_height;
        bits = continued_bits;
        break;
!       
      case CONTINUATION_LINE_BITMAP:
        wd = continuation_width;
        h = continuation_height;
--- 908,914 ----
        h = continued_height;
        bits = continued_bits;
        break;
! 
      case CONTINUATION_LINE_BITMAP:
        wd = continuation_width;
        h = continuation_height;
***************
*** 975,981 ****
    if (b1 >= 0)
      {
        int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
!       
        /* In case the same realized face is used for fringes and
         for something displayed in the text (e.g. face `region' on
         mono-displays, the fill style may have been changed to
--- 975,981 ----
    if (b1 >= 0)
      {
        int header_line_height = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
! 
        /* In case the same realized face is used for fringes and
         for something displayed in the text (e.g. face `region' on
         mono-displays, the fill style may have been changed to
***************
*** 984,990 ****
        XSetFillStyle (display, face->gc, FillOpaqueStippled);
        else
        XSetForeground (display, face->gc, face->background);
!       
        XFillRectangle (display, window, face->gc,
                      b1,
                      WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
--- 984,990 ----
        XSetFillStyle (display, face->gc, FillOpaqueStippled);
        else
        XSetForeground (display, face->gc, face->background);
! 
        XFillRectangle (display, window, face->gc,
                      b1,
                      WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
***************
*** 1005,1011 ****
        XCopyArea (display, pixmap, window, gc, 0, 0, wd, h, x, y + dy);
        XFreePixmap (display, pixmap);
      }
!   
    XSetClipMask (display, gc, None);
  }
  
--- 1005,1011 ----
        XCopyArea (display, pixmap, window, gc, 0, 0, wd, h, x, y + dy);
        XFreePixmap (display, pixmap);
      }
! 
    XSetClipMask (display, gc, None);
  }
  
***************
*** 1105,1111 ****
  
     HPOS and VPOS are column/row positions in a window glyph matrix.  X
     and Y are window text area relative pixel positions.
!    
     If this is done during an update, updated_window will contain the
     window that is being updated and the position is the future output
     cursor position for that window.  If updated_window is null, use
--- 1105,1111 ----
  
     HPOS and VPOS are column/row positions in a window glyph matrix.  X
     and Y are window text area relative pixel positions.
! 
     If this is done during an update, updated_window will contain the
     window that is being updated and the position is the future output
     cursor position for that window.  If updated_window is null, use
***************
*** 1268,1276 ****
          ccl->reg[1] = char2b->byte1;
          ccl->reg[2] = char2b->byte2;
        }
!       
        ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
!       
        /* We assume that MSBs are appropriately set/reset by CCL
         program.  */
        if (font->max_byte1 == 0)       /* 1-byte font */
--- 1268,1276 ----
          ccl->reg[1] = char2b->byte1;
          ccl->reg[2] = char2b->byte2;
        }
! 
        ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
! 
        /* We assume that MSBs are appropriately set/reset by CCL
         program.  */
        if (font->max_byte1 == 0)       /* 1-byte font */
***************
*** 1283,1293 ****
        /* Fixed encoding scheme.  See fontset.h for the meaning of the
         encoding numbers.  */
        int enc = font_info->encoding[charset];
!       
        if ((enc == 1 || enc == 2)
          && CHARSET_DIMENSION (charset) == 2)
        char2b->byte1 |= 0x80;
!       
        if (enc == 1 || enc == 3)
        char2b->byte2 |= 0x80;
      }
--- 1283,1293 ----
        /* Fixed encoding scheme.  See fontset.h for the meaning of the
         encoding numbers.  */
        int enc = font_info->encoding[charset];
! 
        if ((enc == 1 || enc == 2)
          && CHARSET_DIMENSION (charset) == 2)
        char2b->byte1 |= 0x80;
! 
        if (enc == 1 || enc == 3)
        char2b->byte2 |= 0x80;
      }
***************
*** 1328,1334 ****
    else
      {
        int c1, c2, charset;
!       
        /* Split characters into bytes.  If c2 is -1 afterwards, C is
         really a one-byte character so that byte1 is zero.  */
        SPLIT_CHAR (c, charset, c1, c2);
--- 1328,1334 ----
    else
      {
        int c1, c2, charset;
! 
        /* Split characters into bytes.  If c2 is -1 afterwards, C is
         really a one-byte character so that byte1 is zero.  */
        SPLIT_CHAR (c, charset, c1, c2);
***************
*** 1353,1359 ****
        xassert (face != NULL);
        PREPARE_FACE_FOR_DISPLAY (f, face);
      }
!   
    return face;
  }
  
--- 1353,1359 ----
        xassert (face != NULL);
        PREPARE_FACE_FOR_DISPLAY (f, face);
      }
! 
    return face;
  }
  
***************
*** 1394,1400 ****
    else
      {
        int c1, c2, charset;
!       
        /* Split characters into bytes.  If c2 is -1 afterwards, C is
         really a one-byte character so that byte1 is zero.  */
        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
--- 1394,1400 ----
    else
      {
        int c1, c2, charset;
! 
        /* Split characters into bytes.  If c2 is -1 afterwards, C is
         really a one-byte character so that byte1 is zero.  */
        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
***************
*** 1425,1431 ****
  }
  
  
! /* Store one glyph for IT->char_to_display in IT->glyph_row.  
     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
  
  static INLINE void
--- 1425,1431 ----
  }
  
  
! /* Store one glyph for IT->char_to_display in IT->glyph_row.
     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
  
  static INLINE void
***************
*** 1434,1443 ****
  {
    struct glyph *glyph;
    enum glyph_row_area area = it->area;
!   
    xassert (it->glyph_row);
    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');
!   
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
--- 1434,1443 ----
  {
    struct glyph *glyph;
    enum glyph_row_area area = it->area;
! 
    xassert (it->glyph_row);
    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');
! 
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
***************
*** 1459,1465 ****
      }
  }
  
! /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.  
     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
  
  static INLINE void
--- 1459,1465 ----
      }
  }
  
! /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
  
  static INLINE void
***************
*** 1468,1476 ****
  {
    struct glyph *glyph;
    enum glyph_row_area area = it->area;
!   
    xassert (it->glyph_row);
!   
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
--- 1468,1476 ----
  {
    struct glyph *glyph;
    enum glyph_row_area area = it->area;
! 
    xassert (it->glyph_row);
! 
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
***************
*** 1540,1546 ****
    it->pixel_width = img->width + 2 * img->hmargin;
  
    it->nglyphs = 1;
!   
    if (face->box != FACE_NO_BOX)
      {
        if (face->box_line_width > 0)
--- 1540,1546 ----
    it->pixel_width = img->width + 2 * img->hmargin;
  
    it->nglyphs = 1;
! 
    if (face->box != FACE_NO_BOX)
      {
        if (face->box_line_width > 0)
***************
*** 1548,1554 ****
          it->ascent += face->box_line_width;
          it->descent += face->box_line_width;
        }
!       
        if (it->start_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
        if (it->end_of_box_run_p)
--- 1548,1554 ----
          it->ascent += face->box_line_width;
          it->descent += face->box_line_width;
        }
! 
        if (it->start_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
        if (it->end_of_box_run_p)
***************
*** 1556,1567 ****
      }
  
    take_vertical_position_into_account (it);
!   
    if (it->glyph_row)
      {
        struct glyph *glyph;
        enum glyph_row_area area = it->area;
!       
        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
        if (glyph < it->glyph_row->glyphs[area + 1])
        {
--- 1556,1567 ----
      }
  
    take_vertical_position_into_account (it);
! 
    if (it->glyph_row)
      {
        struct glyph *glyph;
        enum glyph_row_area area = it->area;
! 
        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
        if (glyph < it->glyph_row->glyphs[area + 1])
        {
***************
*** 1585,1594 ****
  
  
  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
!    of the glyph, WIDTH and HEIGHT are the width and height of the 
!    stretch.  ASCENT is the percentage/100 of HEIGHT to use for the 
     ascent of the glyph (0 <= ASCENT <= 1).  */
!   
  static void
  x_append_stretch_glyph (it, object, width, height, ascent)
       struct it *it;
--- 1585,1594 ----
  
  
  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
!    of the glyph, WIDTH and HEIGHT are the width and height of the
!    stretch.  ASCENT is the percentage/100 of HEIGHT to use for the
     ascent of the glyph (0 <= ASCENT <= 1).  */
! 
  static void
  x_append_stretch_glyph (it, object, width, height, ascent)
       struct it *it;
***************
*** 1600,1606 ****
    enum glyph_row_area area = it->area;
  
    xassert (ascent >= 0 && ascent <= 1);
!   
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
--- 1600,1606 ----
    enum glyph_row_area area = it->area;
  
    xassert (ascent >= 0 && ascent <= 1);
! 
    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
    if (glyph < it->glyph_row->glyphs[area + 1])
      {
***************
*** 1629,1635 ****
     being recognized:
  
     1. `:width WIDTH' specifies that the space should be WIDTH *
!    canonical char width wide.  WIDTH may be an integer or floating 
     point number.
  
     2. `:relative-width FACTOR' specifies that the width of the stretch
--- 1629,1635 ----
     being recognized:
  
     1. `:width WIDTH' specifies that the space should be WIDTH *
!    canonical char width wide.  WIDTH may be an integer or floating
     point number.
  
     2. `:relative-width FACTOR' specifies that the width of the stretch
***************
*** 1639,1645 ****
     3. `:align-to HPOS' specifies that the space should be wide enough
     to reach HPOS, a value in canonical character units.
  
!    Exactly one of the above pairs must be present.  
  
     4. `:height HEIGHT' specifies that the height of the stretch produced
     should be HEIGHT, measured in canonical character units.
--- 1639,1645 ----
     3. `:align-to HPOS' specifies that the space should be wide enough
     to reach HPOS, a value in canonical character units.
  
!    Exactly one of the above pairs must be present.
  
     4. `:height HEIGHT' specifies that the height of the stretch produced
     should be HEIGHT, measured in canonical character units.
***************
*** 1677,1683 ****
    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);
  
    PREPARE_FACE_FOR_DISPLAY (it->f, face);
!   
    /* List should start with `space'.  */
    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
    plist = XCDR (it->object);
--- 1677,1683 ----
    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);
  
    PREPARE_FACE_FOR_DISPLAY (it->f, face);
! 
    /* List should start with `space'.  */
    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
    plist = XCDR (it->object);
***************
*** 1695,1701 ****
         property.  */
        struct it it2;
        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));
!       
        it2 = *it;
        if (it->multibyte_p)
        {
--- 1695,1701 ----
         property.  */
        struct it it2;
        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));
! 
        it2 = *it;
        if (it->multibyte_p)
        {
***************
*** 1717,1723 ****
    else
      /* Nothing specified -> width defaults to canonical char width.  */
      width = CANON_X_UNIT (it->f);
!   
    /* Compute height.  */
    if (prop = Fplist_get (plist, QCheight),
        NUMVAL (prop) > 0)
--- 1717,1723 ----
    else
      /* Nothing specified -> width defaults to canonical char width.  */
      width = CANON_X_UNIT (it->f);
! 
    /* Compute height.  */
    if (prop = Fplist_get (plist, QCheight),
        NUMVAL (prop) > 0)
***************
*** 1728,1734 ****
    else
      height = FONT_HEIGHT (font);
  
!   /* Compute percentage of height used for ascent.  If 
       `:ascent ASCENT' is present and valid, use that.  Otherwise,
       derive the ascent from the font in use.  */
    if (prop = Fplist_get (plist, QCascent),
--- 1728,1734 ----
    else
      height = FONT_HEIGHT (font);
  
!   /* Compute percentage of height used for ascent.  If
       `:ascent ASCENT' is present and valid, use that.  Otherwise,
       derive the ascent from the font in use.  */
    if (prop = Fplist_get (plist, QCascent),
***************
*** 1762,1774 ****
          it->ascent += face->box_line_width;
          it->descent += face->box_line_width;
        }
!       
        if (it->start_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
        if (it->end_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
      }
!   
    take_vertical_position_into_account (it);
  }
  
--- 1762,1774 ----
          it->ascent += face->box_line_width;
          it->descent += face->box_line_width;
        }
! 
        if (it->start_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
        if (it->end_of_box_run_p)
        it->pixel_width += abs (face->box_line_width);
      }
! 
    take_vertical_position_into_account (it);
  }
  
***************
*** 1859,1865 ****
              face = FACE_FROM_ID (it->f, it->face_id);
            }
        }
!       
        /* Get font to use.  Encode IT->char_to_display.  */
        x_get_char_face_and_encoding (it->f, it->char_to_display,
                                    it->face_id, &char2b,
--- 1859,1865 ----
              face = FACE_FROM_ID (it->f, it->face_id);
            }
        }
! 
        /* Get font to use.  Encode IT->char_to_display.  */
        x_get_char_face_and_encoding (it->f, it->char_to_display,
                                    it->face_id, &char2b,
***************
*** 1920,1926 ****
          if (face->box != FACE_NO_BOX)
            {
              int thick = face->box_line_width;
!             
              if (thick > 0)
                {
                  it->ascent += thick;
--- 1920,1926 ----
          if (face->box != FACE_NO_BOX)
            {
              int thick = face->box_line_width;
! 
              if (thick > 0)
                {
                  it->ascent += thick;
***************
*** 1941,1947 ****
            it->ascent += 2;
  
          take_vertical_position_into_account (it);
!   
          /* If we have to actually produce glyphs, do it.  */
          if (it->glyph_row)
            {
--- 1941,1947 ----
            it->ascent += 2;
  
          take_vertical_position_into_account (it);
! 
          /* If we have to actually produce glyphs, do it.  */
          if (it->glyph_row)
            {
***************
*** 1950,1956 ****
                  /* Translate a space with a `space-width' property
                     into a stretch glyph.  */
                  double ascent = (double) font->ascent / FONT_HEIGHT (font);
!                 x_append_stretch_glyph (it, it->object, it->pixel_width, 
                                          it->ascent + it->descent, ascent);
                }
              else
--- 1950,1956 ----
                  /* Translate a space with a `space-width' property
                     into a stretch glyph.  */
                  double ascent = (double) font->ascent / FONT_HEIGHT (font);
!                 x_append_stretch_glyph (it, it->object, it->pixel_width,
                                          it->ascent + it->descent, ascent);
                }
              else
***************
*** 1970,1976 ****
          it->nglyphs = 0;
          it->ascent = it->phys_ascent = font->ascent + boff;
          it->descent = it->phys_descent = font->descent - boff;
!       
          if (face->box != FACE_NO_BOX
              && face->box_line_width > 0)
            {
--- 1970,1976 ----
          it->nglyphs = 0;
          it->ascent = it->phys_ascent = font->ascent + boff;
          it->descent = it->phys_descent = font->descent - boff;
! 
          if (face->box != FACE_NO_BOX
              && face->box_line_width > 0)
            {
***************
*** 1989,2008 ****
             tab stop after that.  */
          if (next_tab_x - x < CANON_X_UNIT (it->f))
            next_tab_x += tab_width;
!       
          it->pixel_width = next_tab_x - x;
          it->nglyphs = 1;
          it->ascent = it->phys_ascent = font->ascent + boff;
          it->descent = it->phys_descent = font->descent - boff;
!         
          if (it->glyph_row)
            {
              double ascent = (double) it->ascent / (it->ascent + it->descent);
!             x_append_stretch_glyph (it, it->object, it->pixel_width, 
                                      it->ascent + it->descent, ascent);
            }
        }
!       else 
        {
          /* A multi-byte character.  Assume that the display width of the
             character is the width of the character multiplied by the
--- 1989,2008 ----
             tab stop after that.  */
          if (next_tab_x - x < CANON_X_UNIT (it->f))
            next_tab_x += tab_width;
! 
          it->pixel_width = next_tab_x - x;
          it->nglyphs = 1;
          it->ascent = it->phys_ascent = font->ascent + boff;
          it->descent = it->phys_descent = font->descent - boff;
! 
          if (it->glyph_row)
            {
              double ascent = (double) it->ascent / (it->ascent + it->descent);
!             x_append_stretch_glyph (it, it->object, it->pixel_width,
                                      it->ascent + it->descent, ascent);
            }
        }
!       else
        {
          /* A multi-byte character.  Assume that the display width of the
             character is the width of the character multiplied by the
***************
*** 2048,2067 ****
                }
              else
                thick = - thick;
!         
              if (it->start_of_box_run_p)
                it->pixel_width += thick;
              if (it->end_of_box_run_p)
                it->pixel_width += thick;
            }
!   
          /* If face has an overline, add the height of the overline
             (1 pixel) and a 1 pixel margin to the character height.  */
          if (face->overline_p)
            it->ascent += 2;
  
          take_vertical_position_into_account (it);
!   
          if (it->glyph_row)
            x_append_glyph (it);
        }
--- 2048,2067 ----
                }
              else
                thick = - thick;
! 
              if (it->start_of_box_run_p)
                it->pixel_width += thick;
              if (it->end_of_box_run_p)
                it->pixel_width += thick;
            }
! 
          /* If face has an overline, add the height of the overline
             (1 pixel) and a 1 pixel margin to the character height.  */
          if (face->overline_p)
            it->ascent += 2;
  
          take_vertical_position_into_account (it);
! 
          if (it->glyph_row)
            x_append_glyph (it);
        }
***************
*** 2090,2096 ****
        {
          it->char_to_display = unibyte_char_to_multibyte (it->c);
        }
!       
        /* Get face and font to use.  Encode IT->char_to_display.  */
        it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
        face = FACE_FROM_ID (it->f, it->face_id);
--- 2090,2096 ----
        {
          it->char_to_display = unibyte_char_to_multibyte (it->c);
        }
! 
        /* Get face and font to use.  Encode IT->char_to_display.  */
        it->face_id = FACE_FOR_CHAR (it->f, face, it->char_to_display);
        face = FACE_FROM_ID (it->f, it->face_id);
***************
*** 2155,2166 ****
              ascent = font->ascent;
              descent = font->descent;
            }
!         
          rightmost = width;
          lowest = - descent + boff;
          highest = ascent + boff;
          leftmost = 0;
!         
          if (font_info
              && font_info->default_ascent
              && CHAR_TABLE_P (Vuse_default_ascent)
--- 2155,2166 ----
              ascent = font->ascent;
              descent = font->descent;
            }
! 
          rightmost = width;
          lowest = - descent + boff;
          highest = ascent + boff;
          leftmost = 0;
! 
          if (font_info
              && font_info->default_ascent
              && CHAR_TABLE_P (Vuse_default_ascent)
***************
*** 2180,2186 ****
              int left, right, btm, top;
              int ch = COMPOSITION_GLYPH (cmp, i);
              int face_id = FACE_FOR_CHAR (it->f, face, ch);
!             
              face = FACE_FROM_ID (it->f, face_id);
              x_get_char_face_and_encoding (it->f, ch, face->id, &char2b,
                                            it->multibyte_p, 0);
--- 2180,2186 ----
              int left, right, btm, top;
              int ch = COMPOSITION_GLYPH (cmp, i);
              int face_id = FACE_FOR_CHAR (it->f, face, ch);
! 
              face = FACE_FROM_ID (it->f, face_id);
              x_get_char_face_and_encoding (it->f, ch, face->id, &char2b,
                                            it->multibyte_p, 0);
***************
*** 2321,2340 ****
            }
          else
            thick = - thick;
!         
          if (it->start_of_box_run_p)
            it->pixel_width += thick;
          if (it->end_of_box_run_p)
            it->pixel_width += thick;
        }
!   
        /* If face has an overline, add the height of the overline
         (1 pixel) and a 1 pixel margin to the character height.  */
        if (face->overline_p)
        it->ascent += 2;
  
        take_vertical_position_into_account (it);
!   
        if (it->glyph_row)
        x_append_composite_glyph (it);
      }
--- 2321,2340 ----
            }
          else
            thick = - thick;
! 
          if (it->start_of_box_run_p)
            it->pixel_width += thick;
          if (it->end_of_box_run_p)
            it->pixel_width += thick;
        }
! 
        /* If face has an overline, add the height of the overline
         (1 pixel) and a 1 pixel margin to the character height.  */
        if (face->overline_p)
        it->ascent += 2;
  
        take_vertical_position_into_account (it);
! 
        if (it->glyph_row)
        x_append_composite_glyph (it);
      }
***************
*** 2348,2356 ****
    xassert (it->ascent >= 0 && it->descent >= 0);
    if (it->area == TEXT_AREA)
      it->current_x += it->pixel_width;
!   
    it->descent += it->extra_line_spacing;
!   
    it->max_ascent = max (it->max_ascent, it->ascent);
    it->max_descent = max (it->max_descent, it->descent);
    it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
--- 2348,2356 ----
    xassert (it->ascent >= 0 && it->descent >= 0);
    if (it->area == TEXT_AREA)
      it->current_x += it->pixel_width;
! 
    it->descent += it->extra_line_spacing;
! 
    it->max_ascent = max (it->max_ascent, it->ascent);
    it->max_descent = max (it->max_descent, it->descent);
    it->max_phys_ascent = max (it->max_phys_ascent, it->phys_ascent);
***************
*** 2381,2387 ****
              height += 2 * face->box_line_width;
          }
        }
!   
    return height;
  }
  
--- 2381,2387 ----
              height += 2 * face->box_line_width;
          }
        }
! 
    return height;
  }
  
***************
*** 2551,2557 ****
  static void x_init_glyph_string P_ ((struct glyph_string *,
                                        XChar2b *, struct window *,
                                        struct glyph_row *,
!                                       enum glyph_row_area, int, 
                                        enum draw_glyphs_face));
  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
                              enum glyph_row_area, int, int,
--- 2551,2557 ----
  static void x_init_glyph_string P_ ((struct glyph_string *,
                                        XChar2b *, struct window *,
                                        struct glyph_row *,
!                                       enum glyph_row_area, int,
                                        enum draw_glyphs_face));
  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
                              enum glyph_row_area, int, int,
***************
*** 2707,2717 ****
  
  
  /* Set up S->gc of glyph string S for drawing text in mouse face.  */
!    
  static void
  x_set_mouse_face_gc (s)
       struct glyph_string *s;
! {     
    int face_id;
    struct face *face;
  
--- 2707,2717 ----
  
  
  /* Set up S->gc of glyph string S for drawing text in mouse face.  */
! 
  static void
  x_set_mouse_face_gc (s)
       struct glyph_string *s;
! {
    int face_id;
    struct face *face;
  
***************
*** 2720,2726 ****
    face = FACE_FROM_ID (s->f, face_id);
    if (face == NULL)
      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
!   
    if (s->first_glyph->type == CHAR_GLYPH)
      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
    else
--- 2720,2726 ----
    face = FACE_FROM_ID (s->f, face_id);
    if (face == NULL)
      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
! 
    if (s->first_glyph->type == CHAR_GLYPH)
      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
    else
***************
*** 2737,2757 ****
         but font FONT.  */
        XGCValues xgcv;
        unsigned long mask;
!       
        xgcv.background = s->face->background;
        xgcv.foreground = s->face->foreground;
        IF_DEBUG (x_check_font (s->f, s->font));
        xgcv.font = s->font->fid;
        xgcv.graphics_exposures = False;
        mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
!       
        if (FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc)
        XChangeGC (s->display, FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc,
                   mask, &xgcv);
        else
        FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc
          = XCreateGC (s->display, s->window, mask, &xgcv);
!       
        s->gc = FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc;
      }
  
--- 2737,2757 ----
         but font FONT.  */
        XGCValues xgcv;
        unsigned long mask;
! 
        xgcv.background = s->face->background;
        xgcv.foreground = s->face->foreground;
        IF_DEBUG (x_check_font (s->f, s->font));
        xgcv.font = s->font->fid;
        xgcv.graphics_exposures = False;
        mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
! 
        if (FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc)
        XChangeGC (s->display, FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc,
                   mask, &xgcv);
        else
        FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc
          = XCreateGC (s->display, s->window, mask, &xgcv);
! 
        s->gc = FRAME_X_DISPLAY_INFO (s->f)->scratch_cursor_gc;
      }
  
***************
*** 2766,2772 ****
  static INLINE void
  x_set_mode_line_face_gc (s)
       struct glyph_string *s;
! {     
    s->gc = s->face->gc;
  }
  
--- 2766,2772 ----
  static INLINE void
  x_set_mode_line_face_gc (s)
       struct glyph_string *s;
! {
    s->gc = s->face->gc;
  }
  
***************
*** 2780,2786 ****
       struct glyph_string *s;
  {
    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
!   
    if (s->hl == DRAW_NORMAL_TEXT)
      {
        s->gc = s->face->gc;
--- 2780,2786 ----
       struct glyph_string *s;
  {
    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
! 
    if (s->hl == DRAW_NORMAL_TEXT)
      {
        s->gc = s->face->gc;
***************
*** 2829,2835 ****
      {
        /* Draw full-width.  X coordinates are relative to S->w->left.  */
        int canon_x = CANON_X_UNIT (s->f);
!       
        r->x = WINDOW_LEFT_MARGIN (s->w) * canon_x;
        r->width = XFASTINT (s->w->width) * canon_x;
  
--- 2829,2835 ----
      {
        /* Draw full-width.  X coordinates are relative to S->w->left.  */
        int canon_x = CANON_X_UNIT (s->f);
! 
        r->x = WINDOW_LEFT_MARGIN (s->w) * canon_x;
        r->width = XFASTINT (s->w->width) * canon_x;
  
***************
*** 2839,2847 ****
          if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))
            r->x -= width;
        }
!       
        r->x += FRAME_INTERNAL_BORDER_WIDTH (s->f);
!       
        /* Unless displaying a mode or menu bar line, which are always
         fully visible, clip to the visible part of the row.  */
        if (s->w->pseudo_window_p)
--- 2839,2847 ----
          if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))
            r->x -= width;
        }
! 
        r->x += FRAME_INTERNAL_BORDER_WIDTH (s->f);
! 
        /* Unless displaying a mode or menu bar line, which are always
         fully visible, clip to the visible part of the row.  */
        if (s->w->pseudo_window_p)
***************
*** 2922,2928 ****
  /* Compute overhangs and x-positions for glyph string S and its
     predecessors, or successors.  X is the starting x-position for S.
     BACKWARD_P non-zero means process predecessors.  */
!    
  static void
  x_compute_overhangs_and_x (s, x, backward_p)
       struct glyph_string *s;
--- 2922,2928 ----
  /* Compute overhangs and x-positions for glyph string S and its
     predecessors, or successors.  X is the starting x-position for S.
     BACKWARD_P non-zero means process predecessors.  */
! 
  static void
  x_compute_overhangs_and_x (s, x, backward_p)
       struct glyph_string *s;
***************
*** 2963,2969 ****
       int *left, *right;
  {
    *left = *right = 0;
!   
    if (glyph->type == CHAR_GLYPH)
      {
        XFontStruct *font;
--- 2963,2969 ----
       int *left, *right;
  {
    *left = *right = 0;
! 
    if (glyph->type == CHAR_GLYPH)
      {
        XFontStruct *font;
***************
*** 2996,3002 ****
       struct glyph_string *s;
  {
    int k;
!     
    if (s->left_overhang)
      {
        int x = 0, i;
--- 2996,3002 ----
       struct glyph_string *s;
  {
    int k;
! 
    if (s->left_overhang)
      {
        int x = 0, i;
***************
*** 3058,3064 ****
        struct glyph *glyphs = s->row->glyphs[s->area];
        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);
        int end = s->row->used[s->area];
!       
        for (i = first; i < end && s->right_overhang > x; ++i)
        x += glyphs[i].pixel_width;
  
--- 3058,3064 ----
        struct glyph *glyphs = s->row->glyphs[s->area];
        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);
        int end = s->row->used[s->area];
! 
        for (i = first; i < end && s->right_overhang > x; ++i)
        x += glyphs[i].pixel_width;
  
***************
*** 3283,3291 ****
    struct x_display_info *dpyinfo;
    Lisp_Object tail;
    struct frame *f;
!   
    dpyinfo = x_display_info_for_display (XtDisplay (widget));
!   
    /* Find the top-level shell of the widget.  Note that this function
       can be called when the widget is not yet realized, so XtWindow
       (widget) == 0.  That's the reason we can't simply use
--- 3283,3291 ----
    struct x_display_info *dpyinfo;
    Lisp_Object tail;
    struct frame *f;
! 
    dpyinfo = x_display_info_for_display (XtDisplay (widget));
! 
    /* Find the top-level shell of the widget.  Note that this function
       can be called when the widget is not yet realized, so XtWindow
       (widget) == 0.  That's the reason we can't simply use
***************
*** 3426,3432 ****
      {
        String params[1];
        Cardinal nparams = 1;
!       
        params[0] = color_name;
        XtAppWarningMsg (XtDisplayToApplicationContext (dpy),
                       "badValue", "cvt_string_to_pixel",
--- 3426,3432 ----
      {
        String params[1];
        Cardinal nparams = 1;
! 
        params[0] = color_name;
        XtAppWarningMsg (XtDisplayToApplicationContext (dpy),
                       "badValue", "cvt_string_to_pixel",
***************
*** 3442,3448 ****
          to->size = sizeof (Pixel);
          return False;
        }
!       
        *(Pixel *) to->addr = pixel;
      }
    else
--- 3442,3448 ----
          to->size = sizeof (Pixel);
          return False;
        }
! 
        *(Pixel *) to->addr = pixel;
      }
    else
***************
*** 3450,3456 ****
        cvt_string_to_pixel_value = pixel;
        to->addr = (XtPointer) &cvt_string_to_pixel_value;
      }
!   
    to->size = sizeof (Pixel);
    return True;
  }
--- 3450,3456 ----
        cvt_string_to_pixel_value = pixel;
        to->addr = (XtPointer) &cvt_string_to_pixel_value;
      }
! 
    to->size = sizeof (Pixel);
    return True;
  }
***************
*** 3513,3528 ****
      {
        Screen *screen = dpyinfo->screen;
        int i;
!       
        dpyinfo->ncolor_cells
        = XDisplayCells (dpy, XScreenNumberOfScreen (screen));
        dpyinfo->color_cells
        = (XColor *) xmalloc (dpyinfo->ncolor_cells
                              * sizeof *dpyinfo->color_cells);
!       
        for (i = 0; i < dpyinfo->ncolor_cells; ++i)
        dpyinfo->color_cells[i].pixel = i;
!       
        XQueryColors (dpy, dpyinfo->cmap,
                    dpyinfo->color_cells, dpyinfo->ncolor_cells);
      }
--- 3513,3528 ----
      {
        Screen *screen = dpyinfo->screen;
        int i;
! 
        dpyinfo->ncolor_cells
        = XDisplayCells (dpy, XScreenNumberOfScreen (screen));
        dpyinfo->color_cells
        = (XColor *) xmalloc (dpyinfo->ncolor_cells
                              * sizeof *dpyinfo->color_cells);
! 
        for (i = 0; i < dpyinfo->ncolor_cells; ++i)
        dpyinfo->color_cells[i].pixel = i;
! 
        XQueryColors (dpy, dpyinfo->cmap,
                    dpyinfo->color_cells, dpyinfo->ncolor_cells);
      }
***************
*** 3569,3575 ****
  {
    x_query_colors (f, color, 1);
  }
!      
  
  /* Allocate the color COLOR->pixel on DISPLAY, colormap CMAP.  If an
     exact match can't be allocated, try the nearest color available.
--- 3569,3575 ----
  {
    x_query_colors (f, color, 1);
  }
! 
  
  /* Allocate the color COLOR->pixel on DISPLAY, colormap CMAP.  If an
     exact match can't be allocated, try the nearest color available.
***************
*** 3609,3615 ****
              nearest_delta = delta;
            }
        }
!       
        color->red   = cells[nearest].red;
        color->green = cells[nearest].green;
        color->blue  = cells[nearest].blue;
--- 3609,3615 ----
              nearest_delta = delta;
            }
        }
! 
        color->red   = cells[nearest].red;
        color->green = cells[nearest].green;
        color->blue  = cells[nearest].blue;
***************
*** 3622,3628 ****
           change in the colormap, so clear the color cache.  */
        struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
        XColor *cached_color;
!       
        if (dpyinfo->color_cells
          && (cached_color = &dpyinfo->color_cells[color->pixel],
              (cached_color->red != color->red
--- 3622,3628 ----
           change in the colormap, so clear the color cache.  */
        struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
        XColor *cached_color;
! 
        if (dpyinfo->color_cells
          && (cached_color = &dpyinfo->color_cells[color->pixel],
              (cached_color->red != color->red
***************
*** 3639,3645 ****
    if (rc)
      register_color (color->pixel);
  #endif /* DEBUG_X_COLORS */
!   
    return rc;
  }
  
--- 3639,3645 ----
    if (rc)
      register_color (color->pixel);
  #endif /* DEBUG_X_COLORS */
! 
    return rc;
  }
  
***************
*** 3788,3794 ****
          /* If we end up with the same color as before, try adding
             delta to the RGB values.  */
          x_free_colors (f, &new.pixel, 1);
!         
          new.red = min (0xffff, delta + color.red);
          new.green = min (0xffff, delta + color.green);
          new.blue = min (0xffff, delta + color.blue);
--- 3788,3794 ----
          /* If we end up with the same color as before, try adding
             delta to the RGB values.  */
          x_free_colors (f, &new.pixel, 1);
! 
          new.red = min (0xffff, delta + color.red);
          new.green = min (0xffff, delta + color.green);
          new.blue = min (0xffff, delta + color.blue);
***************
*** 3798,3804 ****
        success_p = 1;
        *pixel = new.pixel;
      }
!   
    return success_p;
  }
  
--- 3798,3804 ----
        success_p = 1;
        *pixel = new.pixel;
      }
! 
    return success_p;
  }
  
***************
*** 3809,3815 ****
     DELTA lighter or darker than the relief's background which is found
     in S->f->output_data.x->relief_background.  If such a color cannot
     be allocated, use DEFAULT_PIXEL, instead.  */
!    
  static void
  x_setup_relief_color (f, relief, factor, delta, default_pixel)
       struct frame *f;
--- 3809,3815 ----
     DELTA lighter or darker than the relief's background which is found
     in S->f->output_data.x->relief_background.  If such a color cannot
     be allocated, use DEFAULT_PIXEL, instead.  */
! 
  static void
  x_setup_relief_color (f, relief, factor, delta, default_pixel)
       struct frame *f;
***************
*** 3849,3855 ****
        relief->allocated_p = 1;
        xgcv.foreground = relief->pixel = pixel;
      }
!   
    if (relief->gc == 0)
      {
        xgcv.stipple = dpyinfo->gray;
--- 3849,3855 ----
        relief->allocated_p = 1;
        xgcv.foreground = relief->pixel = pixel;
      }
! 
    if (relief->gc == 0)
      {
        xgcv.stipple = dpyinfo->gray;
***************
*** 3879,3885 ****
    else
      {
        XGCValues xgcv;
!       
        /* Get the background color of the face.  */
        XGetGCValues (s->display, s->gc, GCBackground, &xgcv);
        color = xgcv.background;
--- 3879,3885 ----
    else
      {
        XGCValues xgcv;
! 
        /* Get the background color of the face.  */
        XGetGCValues (s->display, s->gc, GCBackground, &xgcv);
        color = xgcv.background;
***************
*** 3916,3922 ****
    Window window = FRAME_X_WINDOW (f);
    int i;
    GC gc;
!   
    if (raised_p)
      gc = f->output_data.x->white_relief.gc;
    else
--- 3916,3922 ----
    Window window = FRAME_X_WINDOW (f);
    int i;
    GC gc;
! 
    if (raised_p)
      gc = f->output_data.x->white_relief.gc;
    else
***************
*** 3941,3953 ****
    else
      gc = f->output_data.x->white_relief.gc;
    XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
!   
    /* Bottom.  */
    for (i = 0; i < width; ++i)
      XDrawLine (dpy, window, gc,
               left_x + i * left_p, bottom_y - i,
               right_x + 1 - i * right_p, bottom_y - i);
!   
    /* Right.  */
    if (right_p)
      for (i = 0; i < width; ++i)
--- 3941,3953 ----
    else
      gc = f->output_data.x->white_relief.gc;
    XSetClipRectangles (dpy, gc, 0, 0, clip_rect, 1, Unsorted);
! 
    /* Bottom.  */
    for (i = 0; i < width; ++i)
      XDrawLine (dpy, window, gc,
               left_x + i * left_p, bottom_y - i,
               right_x + 1 - i * right_p, bottom_y - i);
! 
    /* Right.  */
    if (right_p)
      for (i = 0; i < width; ++i)
***************
*** 3973,3983 ****
       XRectangle *clip_rect;
  {
    XGCValues xgcv;
!   
    XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
    XSetForeground (s->display, s->gc, s->face->box_color);
    XSetClipRectangles (s->display, s->gc, 0, 0, clip_rect, 1, Unsorted);
!   
    /* Top.  */
    XFillRectangle (s->display, s->window, s->gc,
                  left_x, top_y, right_x - left_x + 1, width);
--- 3973,3983 ----
       XRectangle *clip_rect;
  {
    XGCValues xgcv;
! 
    XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
    XSetForeground (s->display, s->gc, s->face->box_color);
    XSetClipRectangles (s->display, s->gc, 0, 0, clip_rect, 1, Unsorted);
! 
    /* Top.  */
    XFillRectangle (s->display, s->window, s->gc,
                  left_x, top_y, right_x - left_x + 1, width);
***************
*** 3990,3996 ****
    /* Bottom.  */
    XFillRectangle (s->display, s->window, s->gc,
                  left_x, bottom_y - width + 1, right_x - left_x + 1, width);
!   
    /* Right.  */
    if (right_p)
      XFillRectangle (s->display, s->window, s->gc,
--- 3990,3996 ----
    /* Bottom.  */
    XFillRectangle (s->display, s->window, s->gc,
                  left_x, bottom_y - width + 1, right_x - left_x + 1, width);
! 
    /* Right.  */
    if (right_p)
      XFillRectangle (s->display, s->window, s->gc,
***************
*** 4020,4026 ****
        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
        last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
!   
    /* The glyph that may have a right box line.  */
    last_glyph = (s->cmp || s->img
                ? s->first_glyph
--- 4020,4026 ----
        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
        last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
      }
! 
    /* The glyph that may have a right box line.  */
    last_glyph = (s->cmp || s->img
                ? s->first_glyph
***************
*** 4099,4105 ****
          xgcv.clip_y_origin = y;
          xgcv.function = GXcopy;
          XChangeGC (s->display, s->gc, mask, &xgcv);
!         
          x_get_glyph_string_clip_rect (s, &clip_rect);
          image_rect.x = x;
          image_rect.y = y;
--- 4099,4105 ----
          xgcv.clip_y_origin = y;
          xgcv.function = GXcopy;
          XChangeGC (s->display, s->gc, mask, &xgcv);
! 
          x_get_glyph_string_clip_rect (s, &clip_rect);
          image_rect.x = x;
          image_rect.y = y;
***************
*** 4121,4127 ****
          if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
            XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
                       r.x - x, r.y - y, r.width, r.height, r.x, r.y);
!         
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
             be visible.  If the image doesn't have a mask, make
--- 4121,4127 ----
          if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
            XCopyArea (s->display, s->img->pixmap, s->window, s->gc,
                       r.x - x, r.y - y, r.width, r.height, r.x, r.y);
! 
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
             be visible.  If the image doesn't have a mask, make
***************
*** 4154,4160 ****
    XRectangle r;
    int x;
    int y = s->ybase - image_ascent (s->img, s->face);
!   
    /* If first glyph of S has a left box line, start drawing it to the
       right of that line.  */
    if (s->face->box != FACE_NO_BOX
--- 4154,4160 ----
    XRectangle r;
    int x;
    int y = s->ybase - image_ascent (s->img, s->face);
! 
    /* If first glyph of S has a left box line, start drawing it to the
       right of that line.  */
    if (s->face->box != FACE_NO_BOX
***************
*** 4162,4173 ****
      x = s->x + abs (s->face->box_line_width);
    else
      x = s->x;
!   
    /* If there is a margin around the image, adjust x- and y-position
       by that margin.  */
    x += s->img->hmargin;
    y += s->img->vmargin;
!   
    if (s->hl == DRAW_IMAGE_SUNKEN
        || s->hl == DRAW_IMAGE_RAISED)
      {
--- 4162,4173 ----
      x = s->x + abs (s->face->box_line_width);
    else
      x = s->x;
! 
    /* If there is a margin around the image, adjust x- and y-position
       by that margin.  */
    x += s->img->hmargin;
    y += s->img->vmargin;
! 
    if (s->hl == DRAW_IMAGE_SUNKEN
        || s->hl == DRAW_IMAGE_RAISED)
      {
***************
*** 4179,4190 ****
        thick = abs (s->img->relief);
        raised_p = s->img->relief > 0;
      }
!   
    x0 = x - thick;
    y0 = y - thick;
    x1 = x + s->img->width + thick - 1;
    y1 = y + s->img->height + thick - 1;
!   
    x_setup_relief_colors (s);
    x_get_glyph_string_clip_rect (s, &r);
    x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
--- 4179,4190 ----
        thick = abs (s->img->relief);
        raised_p = s->img->relief > 0;
      }
! 
    x0 = x - thick;
    y0 = y - thick;
    x1 = x + s->img->width + thick - 1;
    y1 = y + s->img->height + thick - 1;
! 
    x_setup_relief_colors (s);
    x_get_glyph_string_clip_rect (s, &r);
    x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
***************
*** 4241,4247 ****
        {
          XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
                     0, 0, s->img->width, s->img->height, x, y);
!         
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
             be visible.  If the image doesn't have a mask, make
--- 4241,4247 ----
        {
          XCopyArea (s->display, s->img->pixmap, pixmap, s->gc,
                     0, 0, s->img->width, s->img->height, x, y);
! 
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
             be visible.  If the image doesn't have a mask, make
***************
*** 4284,4290 ****
  }
  
  
! /* Draw image glyph string S.  
  
              s->y
     s->x      +-------------------------
--- 4284,4290 ----
  }
  
  
! /* Draw image glyph string S.
  
              s->y
     s->x      +-------------------------
***************
*** 4325,4333 ****
        x = s->x + box_line_hwidth;
        else
        x = s->x;
!       
        y = s->y + box_line_vwidth;
!       
        if (s->img->mask)
        {
          /* Create a pixmap as large as the glyph string.  Fill it
--- 4325,4333 ----
        x = s->x + box_line_hwidth;
        else
        x = s->x;
! 
        y = s->y + box_line_vwidth;
! 
        if (s->img->mask)
        {
          /* Create a pixmap as large as the glyph string.  Fill it
***************
*** 4340,4346 ****
          pixmap = XCreatePixmap (s->display, s->window,
                                  s->background_width,
                                  s->height, depth);
!         
          /* Don't clip in the following because we're working on the
             pixmap.  */
          XSetClipMask (s->display, s->gc, None);
--- 4340,4346 ----
          pixmap = XCreatePixmap (s->display, s->window,
                                  s->background_width,
                                  s->height, depth);
! 
          /* Don't clip in the following because we're working on the
             pixmap.  */
          XSetClipMask (s->display, s->gc, None);
***************
*** 4367,4373 ****
        }
        else
        x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
!       
        s->background_filled_p = 1;
      }
  
--- 4367,4373 ----
        }
        else
        x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
! 
        s->background_filled_p = 1;
      }
  
***************
*** 4426,4435 ****
            }
          else
            gc = s->face->gc;
!   
          x_get_glyph_string_clip_rect (s, &r);
          XSetClipRectangles (s->display, gc, 0, 0, &r, 1, Unsorted);
!         
          if (s->face->stipple)
            {
              /* Fill background with a stipple pattern.  */
--- 4426,4435 ----
            }
          else
            gc = s->face->gc;
! 
          x_get_glyph_string_clip_rect (s, &r);
          XSetClipRectangles (s->display, gc, 0, 0, &r, 1, Unsorted);
! 
          if (s->face->stipple)
            {
              /* Fill background with a stipple pattern.  */
***************
*** 4450,4456 ****
    else if (!s->background_filled_p)
      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,
                                 s->height);
!   
    s->background_filled_p = 1;
  }
  
--- 4450,4456 ----
    else if (!s->background_filled_p)
      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,
                                 s->height);
! 
    s->background_filled_p = 1;
  }
  
***************
*** 4543,4549 ****
  
             ROUND ((maximum descent) / 2), with
             ROUND(x) = floor (x + 0.5)  */
!         
          if (x_use_underline_position_properties
              && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
            y = s->ybase + (long) tem;
--- 4543,4549 ----
  
             ROUND ((maximum descent) / 2), with
             ROUND(x) = floor (x + 0.5)  */
! 
          if (x_use_underline_position_properties
              && XGetFontProperty (s->font, XA_UNDERLINE_POSITION, &tem))
            y = s->ybase + (long) tem;
***************
*** 4551,4557 ****
            y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
          else
            y = s->y + s->height - h;
!       
          if (s->face->underline_defaulted_p)
            XFillRectangle (s->display, s->window, s->gc,
                            s->x, y, s->width, h);
--- 4551,4557 ----
            y = s->ybase + (s->face->font->max_bounds.descent + 1) / 2;
          else
            y = s->y + s->height - h;
! 
          if (s->face->underline_defaulted_p)
            XFillRectangle (s->display, s->window, s->gc,
                            s->x, y, s->width, h);
***************
*** 4584,4590 ****
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
!   
        /* Draw strike-through.  */
        if (s->face->strike_through_p)
        {
--- 4584,4590 ----
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
! 
        /* Draw strike-through.  */
        if (s->face->strike_through_p)
        {
***************
*** 4604,4615 ****
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
!   
        /* Draw relief if not yet drawn.  */
        if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
        x_draw_glyph_string_box (s);
      }
!   
    /* Reset clipping.  */
    XSetClipMask (s->display, s->gc, None);
  }
--- 4604,4615 ----
              XSetForeground (s->display, s->gc, xgcv.foreground);
            }
        }
! 
        /* Draw relief if not yet drawn.  */
        if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
        x_draw_glyph_string_box (s);
      }
! 
    /* Reset clipping.  */
    XSetClipMask (s->display, s->gc, None);
  }
***************
*** 4620,4626 ****
  
  
  /* Fill glyph string S with composition components specified by S->cmp.
!    
     FACES is an array of faces for all components of this composition.
     S->gidx is the index of the first component for S.
     OVERLAPS_P non-zero means S should draw the foreground only, and
--- 4620,4626 ----
  
  
  /* Fill glyph string S with composition components specified by S->cmp.
! 
     FACES is an array of faces for all components of this composition.
     S->gidx is the index of the first component for S.
     OVERLAPS_P non-zero means S should draw the foreground only, and
***************
*** 4639,4645 ****
    xassert (s);
  
    s->for_overlaps_p = overlaps_p;
!   
    s->face = faces[s->gidx];
    s->font = s->face->font;
    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
--- 4639,4645 ----
    xassert (s);
  
    s->for_overlaps_p = overlaps_p;
! 
    s->face = faces[s->gidx];
    s->font = s->face->font;
    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
***************
*** 4668,4674 ****
  
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += s->first_glyph->voffset;
!   
    xassert (s->face && s->face->gc);
  
    /* This glyph string must always be drawn with 16-bit functions.  */
--- 4668,4674 ----
  
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += s->first_glyph->voffset;
! 
    xassert (s->face && s->face->gc);
  
    /* This glyph string must always be drawn with 16-bit functions.  */
***************
*** 4679,4685 ****
  
  
  /* Fill glyph string S from a sequence of character glyphs.
!    
     FACE_ID is the face id of the string.  START is the index of the
     first glyph to consider, END is the index of the last + 1.
     OVERLAPS_P non-zero means S should draw the foreground only, and
--- 4679,4685 ----
  
  
  /* Fill glyph string S from a sequence of character glyphs.
! 
     FACE_ID is the face id of the string.  START is the index of the
     first glyph to consider, END is the index of the last + 1.
     OVERLAPS_P non-zero means S should draw the foreground only, and
***************
*** 4696,4702 ****
    struct glyph *glyph, *last;
    int voffset;
    int glyph_not_available_p;
!   
    xassert (s->f == XFRAME (s->w->frame));
    xassert (s->nchars == 0);
    xassert (start >= 0 && end > start);
--- 4696,4702 ----
    struct glyph *glyph, *last;
    int voffset;
    int glyph_not_available_p;
! 
    xassert (s->f == XFRAME (s->w->frame));
    xassert (s->nchars == 0);
    xassert (start >= 0 && end > start);
***************
*** 4705,4711 ****
    glyph = s->row->glyphs[s->area] + start;
    last = s->row->glyphs[s->area] + end;
    voffset = glyph->voffset;
!   
    glyph_not_available_p = glyph->glyph_not_available_p;
  
    while (glyph < last
--- 4705,4711 ----
    glyph = s->row->glyphs[s->area] + start;
    last = s->row->glyphs[s->area] + end;
    voffset = glyph->voffset;
! 
    glyph_not_available_p = glyph->glyph_not_available_p;
  
    while (glyph < last
***************
*** 4729,4735 ****
  
    s->font = s->face->font;
    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
!   
    /* If the specified font could not be loaded, use the frame's font,
       but record the fact that we couldn't load it in
       S->font_not_found_p so that we can draw rectangles for the
--- 4729,4735 ----
  
    s->font = s->face->font;
    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
! 
    /* If the specified font could not be loaded, use the frame's font,
       but record the fact that we couldn't load it in
       S->font_not_found_p so that we can draw rectangles for the
***************
*** 4760,4766 ****
    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
    s->font = s->face->font;
    s->width = s->first_glyph->pixel_width;
!   
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += s->first_glyph->voffset;
  }
--- 4760,4766 ----
    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
    s->font = s->face->font;
    s->width = s->first_glyph->pixel_width;
! 
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += s->first_glyph->voffset;
  }
***************
*** 4783,4791 ****
  {
    struct glyph *glyph, *last;
    int voffset, face_id;
!   
    xassert (s->first_glyph->type == STRETCH_GLYPH);
!   
    glyph = s->row->glyphs[s->area] + start;
    last = s->row->glyphs[s->area] + end;
    face_id = glyph->face_id;
--- 4783,4791 ----
  {
    struct glyph *glyph, *last;
    int voffset, face_id;
! 
    xassert (s->first_glyph->type == STRETCH_GLYPH);
! 
    glyph = s->row->glyphs[s->area] + start;
    last = s->row->glyphs[s->area] + end;
    face_id = glyph->face_id;
***************
*** 4802,4808 ****
        && glyph->face_id == face_id);
         ++glyph)
      s->width += glyph->pixel_width;
!   
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += voffset;
  
--- 4802,4808 ----
        && glyph->face_id == face_id);
         ++glyph)
      s->width += glyph->pixel_width;
! 
    /* Adjust base line for subscript/superscript text.  */
    s->ybase += voffset;
  
***************
*** 4820,4826 ****
     and area within the row from which S is constructed.  START is the
     index of the first glyph structure covered by S.  HL is a
     face-override for drawing S.  */
!    
  static void
  x_init_glyph_string (s, char2b, w, row, area, start, hl)
       struct glyph_string *s;
--- 4820,4826 ----
     and area within the row from which S is constructed.  START is the
     index of the first glyph structure covered by S.  HL is a
     face-override for drawing S.  */
! 
  static void
  x_init_glyph_string (s, char2b, w, row, area, start, hl)
       struct glyph_string *s;
***************
*** 4847,4853 ****
    /* Display the internal border below the tool-bar window.  */
    if (s->w == XWINDOW (s->f->tool_bar_window))
      s->y -= s->f->output_data.x->internal_border_width;
!   
    s->ybase = s->y + row->ascent;
  }
  
--- 4847,4853 ----
    /* Display the internal border below the tool-bar window.  */
    if (s->w == XWINDOW (s->f->tool_bar_window))
      s->y -= s->f->output_data.x->internal_border_width;
! 
    s->ybase = s->y + row->ascent;
  }
  
***************
*** 4865,4871 ****
    /* If the face of this glyph string has to be drawn to the end of
       the drawing area, set S->extends_to_end_of_line_p.  */
    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);
!   
    if (start == s->row->used[s->area]
        && s->area == TEXT_AREA
        && ((s->hl == DRAW_NORMAL_TEXT
--- 4865,4871 ----
    /* If the face of this glyph string has to be drawn to the end of
       the drawing area, set S->extends_to_end_of_line_p.  */
    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);
! 
    if (start == s->row->used[s->area]
        && s->area == TEXT_AREA
        && ((s->hl == DRAW_NORMAL_TEXT
***************
*** 4877,4883 ****
          || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
              && s->row->fill_line_p)))
        s->extends_to_end_of_line_p = 1;
!   
    /* If S extends its face to the end of the line, set its
       background_width to the distance to the right edge of the drawing
       area.  */
--- 4877,4883 ----
          || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
              && s->row->fill_line_p)))
        s->extends_to_end_of_line_p = 1;
! 
    /* If S extends its face to the end of the line, set its
       background_width to the distance to the right edge of the drawing
       area.  */
***************
*** 4958,4964 ****
                                            OVERLAPS_P);                        
   \
         }                                                                 \
       while (0)
!      
  
  /* Add a glyph string for a composite sequence to the list of strings
     between HEAD and TAIL.  START is the index of the first glyph in
--- 4958,4964 ----
                                            OVERLAPS_P);                        
   \
         }                                                                 \
       while (0)
! 
  
  /* Add a glyph string for a composite sequence to the list of strings
     between HEAD and TAIL.  START is the index of the first glyph in
***************
*** 5014,5020 ****
      ++START;                                                            \
      s = first_s;                                                        \
    } while (0)
!     
  
  /* Build a list of glyph strings between HEAD and TAIL for the glyphs
     of AREA of glyph row ROW on window W between indices START and END.
--- 5014,5020 ----
      ++START;                                                            \
      s = first_s;                                                        \
    } while (0)
! 
  
  /* Build a list of glyph strings between HEAD and TAIL for the glyphs
     of AREA of glyph row ROW on window W between indices START and END.
***************
*** 5083,5089 ****
     and clip to the physical height of ROW.
  
     Value is the x-position reached, relative to AREA of W.  */
!      
  static int
  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
       struct window *w;
--- 5083,5089 ----
     and clip to the physical height of ROW.
  
     Value is the x-position reached, relative to AREA of W.  */
! 
  static int
  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
       struct window *w;
***************
*** 5164,5170 ****
        /* Prepend glyph strings for glyphs in front of the first glyph
         string that are overwritten because of the first glyph
         string's left overhang.  The background of all strings
!        prepended must be drawn because the first glyph string 
         draws over it.  */
        i = x_left_overwritten (head);
        if (i >= 0)
--- 5164,5170 ----
        /* Prepend glyph strings for glyphs in front of the first glyph
         string that are overwritten because of the first glyph
         string's left overhang.  The background of all strings
!        prepended must be drawn because the first glyph string
         draws over it.  */
        i = x_left_overwritten (head);
        if (i >= 0)
***************
*** 5242,5251 ****
      {
        int x0 = head ? head->x : x;
        int x1 = tail ? tail->x + tail->background_width : x;
!       
        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
!       
        if (XFASTINT (w->left_margin_width) != 0)
        {
          int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
--- 5242,5251 ----
      {
        int x0 = head ? head->x : x;
        int x1 = tail ? tail->x + tail->background_width : x;
! 
        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
! 
        if (XFASTINT (w->left_margin_width) != 0)
        {
          int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
***************
*** 5267,5273 ****
        if (area > TEXT_AREA)
        x_reached -= window_box_width (w, TEXT_AREA);
      }
!   
    return x_reached;
  }
  
--- 5267,5273 ----
        if (area > TEXT_AREA)
        x_reached -= window_box_width (w, TEXT_AREA);
      }
! 
    return x_reached;
  }
  
***************
*** 5281,5289 ****
       enum glyph_row_area area;
  {
    int i, x;
!   
    BLOCK_INPUT;
!   
    if (area == LEFT_MARGIN_AREA)
      x = 0;
    else if (area == TEXT_AREA)
--- 5281,5289 ----
       enum glyph_row_area area;
  {
    int i, x;
! 
    BLOCK_INPUT;
! 
    if (area == LEFT_MARGIN_AREA)
      x = 0;
    else if (area == TEXT_AREA)
***************
*** 5315,5321 ****
          ++i;
        }
      }
!   
    UNBLOCK_INPUT;
  }
  
--- 5315,5321 ----
          ++i;
        }
      }
! 
    UNBLOCK_INPUT;
  }
  
***************
*** 5335,5341 ****
  
    xassert (updated_window && updated_row);
    BLOCK_INPUT;
!   
    /* Write glyphs.  */
  
    hpos = start - updated_row->glyphs[updated_area];
--- 5335,5341 ----
  
    xassert (updated_window && updated_row);
    BLOCK_INPUT;
! 
    /* Write glyphs.  */
  
    hpos = start - updated_row->glyphs[updated_area];
***************
*** 5353,5359 ****
      updated_window->phys_cursor_on_p = 0;
  
    UNBLOCK_INPUT;
!   
    /* Advance the output cursor.  */
    output_cursor.hpos += len;
    output_cursor.x = x;
--- 5353,5359 ----
      updated_window->phys_cursor_on_p = 0;
  
    UNBLOCK_INPUT;
! 
    /* Advance the output cursor.  */
    output_cursor.hpos += len;
    output_cursor.x = x;
***************
*** 5406,5412 ****
    hpos = start - row->glyphs[updated_area];
    x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len,
                 DRAW_NORMAL_TEXT, 0);
!   
    /* Advance the output cursor.  */
    output_cursor.hpos += len;
    output_cursor.x += shift_by_width;
--- 5406,5412 ----
    hpos = start - row->glyphs[updated_area];
    x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len,
                 DRAW_NORMAL_TEXT, 0);
! 
    /* Advance the output cursor.  */
    output_cursor.hpos += len;
    output_cursor.x += shift_by_width;
***************
*** 5456,5465 ****
    struct window *w = updated_window;
    int max_x, min_y, max_y;
    int from_x, from_y, to_y;
!   
    xassert (updated_window && updated_row);
    f = XFRAME (w->frame);
!   
    if (updated_row->full_width_p)
      {
        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);
--- 5456,5465 ----
    struct window *w = updated_window;
    int max_x, min_y, max_y;
    int from_x, from_y, to_y;
! 
    xassert (updated_window && updated_row);
    f = XFRAME (w->frame);
! 
    if (updated_row->full_width_p)
      {
        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);
***************
*** 5481,5487 ****
      to_x = min (to_x, max_x);
  
    to_y = min (max_y, output_cursor.y + updated_row->height);
!   
    /* Notice if the cursor will be cleared by this operation.  */
    if (!updated_row->full_width_p)
      notice_overwritten_cursor (w, updated_area,
--- 5481,5487 ----
      to_x = min (to_x, max_x);
  
    to_y = min (max_y, output_cursor.y + updated_row->height);
! 
    /* Notice if the cursor will be cleared by this operation.  */
    if (!updated_row->full_width_p)
      notice_overwritten_cursor (w, updated_area,
***************
*** 5490,5496 ****
                               MATRIX_ROW_BOTTOM_Y (updated_row));
  
    from_x = output_cursor.x;
!      
    /* Translate to frame coordinates.  */
    if (updated_row->full_width_p)
      {
--- 5490,5496 ----
                               MATRIX_ROW_BOTTOM_Y (updated_row));
  
    from_x = output_cursor.x;
! 
    /* Translate to frame coordinates.  */
    if (updated_row->full_width_p)
      {
***************
*** 5502,5512 ****
        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);
        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);
      }
!   
    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
!   
    /* Prevent inadvertently clearing to end of the X window.  */
    if (to_x > from_x && to_y > from_y)
      {
--- 5502,5512 ----
        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);
        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);
      }
! 
    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
! 
    /* Prevent inadvertently clearing to end of the X window.  */
    if (to_x > from_x && to_y > from_y)
      {
***************
*** 5576,5582 ****
        y.tv_usec -= 1000000 * nsec;
        y.tv_sec += nsec;
      }
!   
    if (x.tv_usec - y.tv_usec > 1000000)
      {
        int nsec = (y.tv_usec - x.tv_usec) / 1000000;
--- 5576,5582 ----
        y.tv_usec -= 1000000 * nsec;
        y.tv_sec += nsec;
      }
! 
    if (x.tv_usec - y.tv_usec > 1000000)
      {
        int nsec = (y.tv_usec - x.tv_usec) / 1000000;
***************
*** 5660,5666 ****
                          width, flash_height);
        }
        else
!       /* If it is short, flash it all.  */ 
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                        flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
                        width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
--- 5660,5666 ----
                          width, flash_height);
        }
        else
!       /* If it is short, flash it all.  */
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                        flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
                        width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
***************
*** 5714,5720 ****
                          width, flash_height);
        }
        else
!       /* If it is short, flash it all.  */ 
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                        flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
                        width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
--- 5714,5720 ----
                          width, flash_height);
        }
        else
!       /* If it is short, flash it all.  */
        XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
                        flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
                        width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
***************
*** 5736,5742 ****
  XTring_bell ()
  {
    struct frame *f = SELECTED_FRAME ();
!   
    if (FRAME_X_DISPLAY (f))
      {
  #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
--- 5736,5742 ----
  XTring_bell ()
  {
    struct frame *f = SELECTED_FRAME ();
! 
    if (FRAME_X_DISPLAY (f))
      {
  #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
***************
*** 5824,5830 ****
      }
  
    BLOCK_INPUT;
!   
    /* Cursor off.  Will be switched on again in x_update_window_end.  */
    updated_window = w;
    x_clear_cursor (w);
--- 5824,5830 ----
      }
  
    BLOCK_INPUT;
! 
    /* Cursor off.  Will be switched on again in x_update_window_end.  */
    updated_window = w;
    x_clear_cursor (w);
***************
*** 5835,5841 ****
             x, from_y,
             width, height,
             x, to_y);
!   
    UNBLOCK_INPUT;
  }
  
--- 5835,5841 ----
             x, from_y,
             width, height,
             x, to_y);
! 
    UNBLOCK_INPUT;
  }
  
***************
*** 5844,5850 ****
  /***********************************************************************
                           Exposure Events
   ***********************************************************************/
!                                                                       
  /* Redisplay an exposed area of frame F.  X and Y are the upper-left
     corner of the exposed rectangle.  W and H are width and height of
     the exposed area.  All are pixel values.  W or H zero means redraw
--- 5844,5850 ----
  /***********************************************************************
                           Exposure Events
   ***********************************************************************/
! 
  /* Redisplay an exposed area of frame F.  X and Y are the upper-left
     corner of the exposed rectangle.  W and H are width and height of
     the exposed area.  All are pixel values.  W or H zero means redraw
***************
*** 5939,5945 ****
  {
    struct frame *f = XFRAME (w->frame);
    int mouse_face_overwritten_p = 0;
!   
    while (w && !FRAME_GARBAGED_P (f))
      {
        if (!NILP (w->hchild))
--- 5939,5945 ----
  {
    struct frame *f = XFRAME (w->frame);
    int mouse_face_overwritten_p = 0;
! 
    while (w && !FRAME_GARBAGED_P (f))
      {
        if (!NILP (w->hchild))
***************
*** 5950,5956 ****
          |= expose_window_tree (XWINDOW (w->vchild), r);
        else
        mouse_face_overwritten_p |= expose_window (w, r);
!       
        w = NILP (w->next) ? NULL : XWINDOW (w->next);
      }
  
--- 5950,5956 ----
          |= expose_window_tree (XWINDOW (w->vchild), r);
        else
        mouse_face_overwritten_p |= expose_window (w, r);
! 
        w = NILP (w->next) ? NULL : XWINDOW (w->next);
      }
  
***************
*** 5998,6004 ****
          x += first->pixel_width;
          ++first;
        }
!       
        /* Find the last one.  */
        last = first;
        first_x = x;
--- 5998,6004 ----
          x += first->pixel_width;
          ++first;
        }
! 
        /* Find the last one.  */
        last = first;
        first_x = x;
***************
*** 6008,6014 ****
          x += last->pixel_width;
          ++last;
        }
!       
        /* Repaint.  */
        if (last > first)
        x_draw_glyphs (w, first_x - start_x, row, area,
--- 6008,6014 ----
          x += last->pixel_width;
          ++last;
        }
! 
        /* Repaint.  */
        if (last > first)
        x_draw_glyphs (w, first_x - start_x, row, area,
***************
*** 6017,6023 ****
                       DRAW_NORMAL_TEXT, 0);
      }
  }
!       
  
  /* Redraw the parts of the glyph row ROW on window W intersecting
     rectangle R.  R is in window-relative coordinates.  Value is
--- 6017,6023 ----
                       DRAW_NORMAL_TEXT, 0);
      }
  }
! 
  
  /* Redraw the parts of the glyph row ROW on window W intersecting
     rectangle R.  R is in window-relative coordinates.  Value is
***************
*** 6030,6036 ****
       XRectangle *r;
  {
    xassert (row->enabled_p);
!   
    if (row->mode_line_p || w->pseudo_window_p)
      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
                   DRAW_NORMAL_TEXT, 0);
--- 6030,6036 ----
       XRectangle *r;
  {
    xassert (row->enabled_p);
! 
    if (row->mode_line_p || w->pseudo_window_p)
      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
                   DRAW_NORMAL_TEXT, 0);
***************
*** 6088,6105 ****
       struct glyph_row *last_overlapping_row;
  {
    struct glyph_row *row;
!   
    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)
      if (row->overlapping_p)
        {
        xassert (row->enabled_p && !row->mode_line_p);
!         
        if (row->used[LEFT_MARGIN_AREA])
          x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);
!   
        if (row->used[TEXT_AREA])
          x_fix_overlapping_area (w, row, TEXT_AREA);
!   
        if (row->used[RIGHT_MARGIN_AREA])
          x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
        }
--- 6088,6105 ----
       struct glyph_row *last_overlapping_row;
  {
    struct glyph_row *row;
! 
    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)
      if (row->overlapping_p)
        {
        xassert (row->enabled_p && !row->mode_line_p);
! 
        if (row->used[LEFT_MARGIN_AREA])
          x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);
! 
        if (row->used[TEXT_AREA])
          x_fix_overlapping_area (w, row, TEXT_AREA);
! 
        if (row->used[RIGHT_MARGIN_AREA])
          x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
        }
***************
*** 6148,6154 ****
        struct glyph_row *row;
        int cursor_cleared_p;
        struct glyph_row *first_overlapping_row, *last_overlapping_row;
!   
        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
              r.x, r.y, r.width, r.height));
  
--- 6148,6154 ----
        struct glyph_row *row;
        int cursor_cleared_p;
        struct glyph_row *first_overlapping_row, *last_overlapping_row;
! 
        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
              r.x, r.y, r.width, r.height));
  
***************
*** 6174,6180 ****
        {
          int y0 = row->y;
          int y1 = MATRIX_ROW_BOTTOM_Y (row);
!         
          if ((y0 >= r.y && y0 < r.y + r.height)
              || (y1 > r.y && y1 < r.y + r.height)
              || (r.y >= y0 && r.y < y1)
--- 6174,6180 ----
        {
          int y0 = row->y;
          int y1 = MATRIX_ROW_BOTTOM_Y (row);
! 
          if ((y0 >= r.y && y0 < r.y + r.height)
              || (y1 > r.y && y1 < r.y + r.height)
              || (r.y >= y0 && r.y < y1)
***************
*** 6186,6196 ****
                    first_overlapping_row = row;
                  last_overlapping_row = row;
                }
!             
              if (expose_line (w, row, &r))
                mouse_face_overwritten_p = 1;
            }
!             
          if (y1 >= yb)
            break;
        }
--- 6186,6196 ----
                    first_overlapping_row = row;
                  last_overlapping_row = row;
                }
! 
              if (expose_line (w, row, &r))
                mouse_face_overwritten_p = 1;
            }
! 
          if (y1 >= yb)
            break;
        }
***************
*** 6210,6219 ****
          /* Fix the display of overlapping rows.  */
          if (first_overlapping_row)
            expose_overlaps (w, first_overlapping_row, last_overlapping_row);
!         
          /* Draw border between windows.  */
          x_draw_vertical_border (w);
!       
          /* Turn the cursor on again.  */
          if (cursor_cleared_p)
            x_update_window_cursor (w, 1);
--- 6210,6219 ----
          /* Fix the display of overlapping rows.  */
          if (first_overlapping_row)
            expose_overlaps (w, first_overlapping_row, last_overlapping_row);
! 
          /* Draw border between windows.  */
          x_draw_vertical_border (w);
! 
          /* Turn the cursor on again.  */
          if (cursor_cleared_p)
            x_update_window_cursor (w, 1);
***************
*** 6235,6241 ****
    XRectangle *left, *right;
    XRectangle *upper, *lower;
    int intersection_p = 0;
!   
    /* Rearrange so that R1 is the left-most rectangle.  */
    if (r1->x < r2->x)
      left = r1, right = r2;
--- 6235,6241 ----
    XRectangle *left, *right;
    XRectangle *upper, *lower;
    int intersection_p = 0;
! 
    /* Rearrange so that R1 is the left-most rectangle.  */
    if (r1->x < r2->x)
      left = r1, right = r2;
***************
*** 6247,6253 ****
    if (right->x <= left->x + left->width)
      {
        result->x = right->x;
!       
        /* The right end of the intersection is the minimum of the
         the right ends of left and right.  */
        result->width = (min (left->x + left->width, right->x + right->width)
--- 6247,6253 ----
    if (right->x <= left->x + left->width)
      {
        result->x = right->x;
! 
        /* The right end of the intersection is the minimum of the
         the right ends of left and right.  */
        result->width = (min (left->x + left->width, right->x + right->width)
***************
*** 6264,6273 ****
        if (lower->y <= upper->y + upper->height)
        {
          result->y = lower->y;
!         
          /* The lower end of the intersection is the minimum of the lower
             ends of upper and lower.  */
!         result->height = (min (lower->y + lower->height, 
                                 upper->y + upper->height)
                            - result->y);
          intersection_p = 1;
--- 6264,6273 ----
        if (lower->y <= upper->y + upper->height)
        {
          result->y = lower->y;
! 
          /* The lower end of the intersection is the minimum of the lower
             ends of upper and lower.  */
!         result->height = (min (lower->y + lower->height,
                                 upper->y + upper->height)
                            - result->y);
          intersection_p = 1;
***************
*** 6352,6358 ****
  
  /* Handle FocusIn and FocusOut state changes for FRAME.
     If FRAME has focus and there exists more than one frame, puts
!    an FOCUS_IN_EVENT into BUFP.
     Returns number of events inserted into BUFP. */
  
  static int
--- 6352,6358 ----
  
  /* Handle FocusIn and FocusOut state changes for FRAME.
     If FRAME has focus and there exists more than one frame, puts
!    a FOCUS_IN_EVENT into BUFP.
     Returns number of events inserted into BUFP. */
  
  static int
***************
*** 6372,6378 ****
          {
            x_new_focus_frame (dpyinfo, frame);
            dpyinfo->x_focus_event_frame = frame;
!       
            /* Don't stop displaying the initial startup message
               for a switch-frame event we don't need.  */
            if (numchars > 0
--- 6372,6378 ----
          {
            x_new_focus_frame (dpyinfo, frame);
            dpyinfo->x_focus_event_frame = frame;
! 
            /* Don't stop displaying the initial startup message
               for a switch-frame event we don't need.  */
            if (numchars > 0
***************
*** 6399,6405 ****
    else if (type == FocusOut)
      {
        frame->output_data.x->focus_state &= ~state;
!       
        if (dpyinfo->x_focus_event_frame == frame)
          {
            dpyinfo->x_focus_event_frame = 0;
--- 6399,6405 ----
    else if (type == FocusOut)
      {
        frame->output_data.x->focus_state &= ~state;
! 
        if (dpyinfo->x_focus_event_frame == frame)
          {
            dpyinfo->x_focus_event_frame = 0;
***************
*** 6429,6438 ****
  {
    struct frame *frame;
    int nr_events = 0;
!   
    frame = x_top_window_to_frame (dpyinfo, event->xany.window);
    if (! frame) return nr_events;
!   
    switch (event->type)
      {
      case EnterNotify:
--- 6429,6438 ----
  {
    struct frame *frame;
    int nr_events = 0;
! 
    frame = x_top_window_to_frame (dpyinfo, event->xany.window);
    if (! frame) return nr_events;
! 
    switch (event->type)
      {
      case EnterNotify:
***************
*** 6638,6644 ****
    EMACS_UINT mod_hyper = hyper_modifier;
    EMACS_UINT mod_super = super_modifier;
    Lisp_Object tem;
!   
    tem = Fget (Vx_alt_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
    tem = Fget (Vx_meta_keysym, Qmodifier_value);
--- 6638,6644 ----
    EMACS_UINT mod_hyper = hyper_modifier;
    EMACS_UINT mod_super = super_modifier;
    Lisp_Object tem;
! 
    tem = Fget (Vx_alt_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
    tem = Fget (Vx_meta_keysym, Qmodifier_value);
***************
*** 6647,6653 ****
    if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
    tem = Fget (Vx_super_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
!   
  
    return (  ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? 
shift_modifier : 0)
              | ((state & ControlMask)                  ? ctrl_modifier : 0)
--- 6647,6653 ----
    if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
    tem = Fget (Vx_super_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
! 
  
    return (  ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? 
shift_modifier : 0)
              | ((state & ControlMask)                  ? ctrl_modifier : 0)
***************
*** 6666,6674 ****
    EMACS_UINT mod_alt  = alt_modifier;
    EMACS_UINT mod_hyper = hyper_modifier;
    EMACS_UINT mod_super = super_modifier;
!   
    Lisp_Object tem;
!   
    tem = Fget (Vx_alt_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
    tem = Fget (Vx_meta_keysym, Qmodifier_value);
--- 6666,6674 ----
    EMACS_UINT mod_alt  = alt_modifier;
    EMACS_UINT mod_hyper = hyper_modifier;
    EMACS_UINT mod_super = super_modifier;
! 
    Lisp_Object tem;
! 
    tem = Fget (Vx_alt_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_alt = XUINT (tem);
    tem = Fget (Vx_meta_keysym, Qmodifier_value);
***************
*** 6677,6684 ****
    if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
    tem = Fget (Vx_super_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
!   
!   
    return (  ((state & mod_alt)                ? dpyinfo->alt_mod_mask   : 0)
              | ((state & mod_super)    ? dpyinfo->super_mod_mask : 0)
              | ((state & mod_hyper)    ? dpyinfo->hyper_mod_mask : 0)
--- 6677,6684 ----
    if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem);
    tem = Fget (Vx_super_keysym, Qmodifier_value);
    if (! EQ (tem, Qnil)) mod_super = XUINT (tem);
! 
! 
    return (  ((state & mod_alt)                ? dpyinfo->alt_mod_mask   : 0)
              | ((state & mod_super)    ? dpyinfo->super_mod_mask : 0)
              | ((state & mod_hyper)    ? dpyinfo->hyper_mod_mask : 0)
***************
*** 6947,6953 ****
          else if (!buffer_only_p || BUFFERP (glyph->object))
            break;
        }
!       
        x0 += glyph->pixel_width;
        ++glyph;
      }
--- 6947,6953 ----
          else if (!buffer_only_p || BUFFERP (glyph->object))
            break;
        }
! 
        x0 += glyph->pixel_width;
        ++glyph;
      }
***************
*** 6991,6997 ****
     display area of W, so the width of bitmap areas and scroll bars
     must be subtracted to get a position relative to the start of the
     mode line.  */
!  
  static void
  note_mode_line_or_margin_highlight (w, x, y, portion)
       struct window *w;
--- 6991,6997 ----
     display area of W, so the width of bitmap areas and scroll bars
     must be subtracted to get a position relative to the start of the
     mode line.  */
! 
  static void
  note_mode_line_or_margin_highlight (w, x, y, portion)
       struct window *w;
***************
*** 7011,7017 ****
    if (STRINGP (string))
      {
        pos = make_number (charpos);
!       
        /* If we're on a string with `help-echo' text property, arrange
         for the help to be displayed.  This is done by setting the
         global variable help_echo to the help string.  */
--- 7011,7017 ----
    if (STRINGP (string))
      {
        pos = make_number (charpos);
! 
        /* If we're on a string with `help-echo' text property, arrange
         for the help to be displayed.  This is done by setting the
         global variable help_echo to the help string.  */
***************
*** 7031,7037 ****
        if (KEYMAPP (map))
        cursor = f->output_data.x->nontext_cursor;
      }
!   
    XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
  }
  
--- 7031,7037 ----
        if (KEYMAPP (map))
        cursor = f->output_data.x->nontext_cursor;
      }
! 
    XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
  }
  
***************
*** 7105,7111 ****
        note_mode_line_or_margin_highlight (w, x, y, portion);
        return;
      }
!   
    if (portion == 2)
      cursor = f->output_data.x->horizontal_drag_cursor;
    else
--- 7105,7111 ----
        note_mode_line_or_margin_highlight (w, x, y, portion);
        return;
      }
! 
    if (portion == 2)
      cursor = f->output_data.x->horizontal_drag_cursor;
    else
***************
*** 7214,7226 ****
              if (!NILP (mouse_face))
                overlay = overlay_vec[i];
            }
!         
          /* If we're actually highlighting the same overlay as
             before, there's no need to do that again.  */
          if (!NILP (overlay)
              && EQ (overlay, dpyinfo->mouse_face_overlay))
            goto check_help_echo;
!           
          dpyinfo->mouse_face_overlay = overlay;
  
          /* Clear the display of the old active region, if any.  */
--- 7214,7226 ----
              if (!NILP (mouse_face))
                overlay = overlay_vec[i];
            }
! 
          /* If we're actually highlighting the same overlay as
             before, there's no need to do that again.  */
          if (!NILP (overlay)
              && EQ (overlay, dpyinfo->mouse_face_overlay))
            goto check_help_echo;
! 
          dpyinfo->mouse_face_overlay = overlay;
  
          /* Clear the display of the old active region, if any.  */
***************
*** 7247,7253 ****
                                  &dpyinfo->mouse_face_beg_row,
                                  &dpyinfo->mouse_face_beg_x,
                                  &dpyinfo->mouse_face_beg_y, Qnil);
!                      
              dpyinfo->mouse_face_past_end
                = !fast_find_position (w, XFASTINT (after),
                                       &dpyinfo->mouse_face_end_col,
--- 7247,7253 ----
                                  &dpyinfo->mouse_face_beg_row,
                                  &dpyinfo->mouse_face_beg_x,
                                  &dpyinfo->mouse_face_beg_y, Qnil);
! 
              dpyinfo->mouse_face_past_end
                = !fast_find_position (w, XFASTINT (after),
                                       &dpyinfo->mouse_face_end_col,
***************
*** 7281,7287 ****
              after
                = Fnext_single_property_change (position, Qmouse_face,
                                                object, end);
!               
              /* Record this as the current active region.  */
              fast_find_position (w, XFASTINT (before),
                                  &dpyinfo->mouse_face_beg_col,
--- 7281,7287 ----
              after
                = Fnext_single_property_change (position, Qmouse_face,
                                                object, end);
! 
              /* Record this as the current active region.  */
              fast_find_position (w, XFASTINT (before),
                                  &dpyinfo->mouse_face_beg_col,
***************
*** 7309,7315 ****
            {
              Lisp_Object b, e;
              int ignore;
!               
              b = Fprevious_single_property_change (make_number (pos + 1),
                                                    Qmouse_face,
                                                    object, Qnil);
--- 7309,7315 ----
            {
              Lisp_Object b, e;
              int ignore;
! 
              b = Fprevious_single_property_change (make_number (pos + 1),
                                                    Qmouse_face,
                                                    object, Qnil);
***************
*** 7343,7349 ****
                 the text ``under'' it might have.  */
              struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
              int start = MATRIX_ROW_START_CHARPOS (r);
!             
              pos = string_buffer_position (w, object, start);
              if (pos > 0)
                mouse_face = get_char_property_and_overlay (make_number (pos),
--- 7343,7349 ----
                 the text ``under'' it might have.  */
              struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
              int start = MATRIX_ROW_START_CHARPOS (r);
! 
              pos = string_buffer_position (w, object, start);
              if (pos > 0)
                mouse_face = get_char_property_and_overlay (make_number (pos),
***************
*** 7367,7373 ****
                                      &dpyinfo->mouse_face_beg_x,
                                      &dpyinfo->mouse_face_beg_y,
                                      object);
!                      
                  dpyinfo->mouse_face_past_end
                    = !fast_find_position (w, XFASTINT (after),
                                           &dpyinfo->mouse_face_end_col,
--- 7367,7373 ----
                                      &dpyinfo->mouse_face_beg_x,
                                      &dpyinfo->mouse_face_beg_y,
                                      object);
! 
                  dpyinfo->mouse_face_past_end
                    = !fast_find_position (w, XFASTINT (after),
                                           &dpyinfo->mouse_face_end_col,
***************
*** 7412,7418 ****
          {
            Lisp_Object object = glyph->object;
            int charpos = glyph->charpos;
!             
            /* Try text properties.  */
            if (STRINGP (object)
                && charpos >= 0
--- 7412,7418 ----
          {
            Lisp_Object object = glyph->object;
            int charpos = glyph->charpos;
! 
            /* Try text properties.  */
            if (STRINGP (object)
                && charpos >= 0
***************
*** 7445,7451 ****
                     && charpos < ZV)
              help = Fget_text_property (make_number (charpos), Qhelp_echo,
                                         object);
!           
            if (!NILP (help))
              {
                help_echo = help;
--- 7445,7451 ----
                     && charpos < ZV)
              help = Fget_text_property (make_number (charpos), Qhelp_echo,
                                         object);
! 
            if (!NILP (help))
              {
                help_echo = help;
***************
*** 7455,7468 ****
              }
          }
        }
!         
        BEGV = obegv;
        ZV = ozv;
        current_buffer = obuf;
      }
  
   set_cursor:
!   
    if (cursor != None)
      XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
  }
--- 7455,7468 ----
              }
          }
        }
! 
        BEGV = obegv;
        ZV = ozv;
        current_buffer = obuf;
      }
  
   set_cursor:
! 
    if (cursor != None)
      XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor);
  }
***************
*** 7533,7539 ****
          || *hpos < dpyinfo->mouse_face_end_col
          || dpyinfo->mouse_face_past_end))
      return 0;
!   
    return 1;
  }
  
--- 7533,7539 ----
          || *hpos < dpyinfo->mouse_face_end_col
          || dpyinfo->mouse_face_past_end))
      return 0;
! 
    return 1;
  }
  
***************
*** 7554,7560 ****
    Lisp_Object enabled_p;
    int x = button_event->x;
    int y = button_event->y;
!   
    /* If not on the highlighted tool-bar item, return.  */
    frame_to_window_pixel_xy (w, &x, &y);
    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)
--- 7554,7560 ----
    Lisp_Object enabled_p;
    int x = button_event->x;
    int y = button_event->y;
! 
    /* If not on the highlighted tool-bar item, return.  */
    frame_to_window_pixel_xy (w, &x, &y);
    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)
***************
*** 7564,7570 ****
    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
    if (NILP (enabled_p))
      return;
!   
    if (button_event->type == ButtonPress)
      {
        /* Show item in pressed state.  */
--- 7564,7570 ----
    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
    if (NILP (enabled_p))
      return;
! 
    if (button_event->type == ButtonPress)
      {
        /* Show item in pressed state.  */
***************
*** 7640,7646 ****
      goto set_help_echo;
  
    clear_mouse_face (dpyinfo);
!   
    /* Mouse is down, but on different tool-bar item?  */
    mouse_down_p = (dpyinfo->grabbed
                  && f == last_mouse_frame
--- 7640,7646 ----
      goto set_help_echo;
  
    clear_mouse_face (dpyinfo);
! 
    /* Mouse is down, but on different tool-bar item?  */
    mouse_down_p = (dpyinfo->grabbed
                  && f == last_mouse_frame
***************
*** 7651,7657 ****
  
    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
!   
    /* If tool-bar item is not enabled, don't highlight it.  */
    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
    if (!NILP (enabled_p))
--- 7651,7657 ----
  
    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
! 
    /* If tool-bar item is not enabled, don't highlight it.  */
    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
    if (!NILP (enabled_p))
***************
*** 7661,7688 ****
        row = MATRIX_ROW (w->current_matrix, vpos);
        for (i = x = 0; i < hpos; ++i)
        x += row->glyphs[TEXT_AREA][i].pixel_width;
!       
        /* Record this as the current active region.  */
        dpyinfo->mouse_face_beg_col = hpos;
        dpyinfo->mouse_face_beg_row = vpos;
        dpyinfo->mouse_face_beg_x = x;
        dpyinfo->mouse_face_beg_y = row->y;
        dpyinfo->mouse_face_past_end = 0;
!       
        dpyinfo->mouse_face_end_col = hpos + 1;
        dpyinfo->mouse_face_end_row = vpos;
        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;
        dpyinfo->mouse_face_end_y = row->y;
        dpyinfo->mouse_face_window = window;
        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
!       
        /* Display it as active.  */
        show_mouse_face (dpyinfo, draw);
        dpyinfo->mouse_face_image_state = draw;
      }
!       
   set_help_echo:
!   
    /* Set help_echo to a help string to display for this tool-bar item.
       XTread_socket does the rest.  */
    help_echo_object = help_echo_window = Qnil;
--- 7661,7688 ----
        row = MATRIX_ROW (w->current_matrix, vpos);
        for (i = x = 0; i < hpos; ++i)
        x += row->glyphs[TEXT_AREA][i].pixel_width;
! 
        /* Record this as the current active region.  */
        dpyinfo->mouse_face_beg_col = hpos;
        dpyinfo->mouse_face_beg_row = vpos;
        dpyinfo->mouse_face_beg_x = x;
        dpyinfo->mouse_face_beg_y = row->y;
        dpyinfo->mouse_face_past_end = 0;
! 
        dpyinfo->mouse_face_end_col = hpos + 1;
        dpyinfo->mouse_face_end_row = vpos;
        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;
        dpyinfo->mouse_face_end_y = row->y;
        dpyinfo->mouse_face_window = window;
        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
! 
        /* Display it as active.  */
        show_mouse_face (dpyinfo, draw);
        dpyinfo->mouse_face_image_state = draw;
      }
! 
   set_help_echo:
! 
    /* Set help_echo to a help string to display for this tool-bar item.
       XTread_socket does the rest.  */
    help_echo_object = help_echo_window = Qnil;
***************
*** 7704,7710 ****
  #if 0 /* This is a version of fast_find_position that's more correct
         in the presence of hscrolling, for example.  I didn't install
         it right away because the problem fixed is minor, it failed
!        in 20.x as well, and I think it's too risky to install 
         so near the release of 21.1.  2001-09-25 gerd.  */
  
  static int
--- 7704,7710 ----
  #if 0 /* This is a version of fast_find_position that's more correct
         in the presence of hscrolling, for example.  I didn't install
         it right away because the problem fixed is minor, it failed
!        in 20.x as well, and I think it's too risky to install
         so near the release of 21.1.  2001-09-25 gerd.  */
  
  static int
***************
*** 7737,7746 ****
    *x = row->x;
    *y = row->y;
    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
!   
    glyph = row->glyphs[TEXT_AREA];
    end = glyph + row->used[TEXT_AREA];
!   
    /* Skip over glyphs not having an object at the start of the row.
       These are special glyphs like truncation marks on terminal
       frames.  */
--- 7737,7746 ----
    *x = row->x;
    *y = row->y;
    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
! 
    glyph = row->glyphs[TEXT_AREA];
    end = glyph + row->used[TEXT_AREA];
! 
    /* Skip over glyphs not having an object at the start of the row.
       These are special glyphs like truncation marks on terminal
       frames.  */
***************
*** 7814,7824 ****
  
        if (row->y + row->height >= yb)
        break;
!       
        ++row;
        ++row_vpos;
      }
!   
    /* Find the right column within BEST_ROW.  */
    lastcol = 0;
    current_x = best_row->x;
--- 7814,7824 ----
  
        if (row->y + row->height >= yb)
        break;
! 
        ++row;
        ++row_vpos;
      }
! 
    /* Find the right column within BEST_ROW.  */
    lastcol = 0;
    current_x = best_row->x;
***************
*** 7942,7948 ****
          *x += best_glyph->pixel_width;
          ++*hpos;
        }
!       
        *y = best_row->y;
        *vpos = best_row - w->current_matrix->rows;
      }
--- 7942,7948 ----
          *x += best_glyph->pixel_width;
          ++*hpos;
        }
! 
        *y = best_row->y;
        *vpos = best_row - w->current_matrix->rows;
      }
***************
*** 7976,7982 ****
  
        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
!       
        for (row = first; row <= last && row->enabled_p; ++row)
        {
          int start_hpos, end_hpos, start_x;
--- 7976,7982 ----
  
        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
! 
        for (row = first; row <= last && row->enabled_p; ++row)
        {
          int start_hpos, end_hpos, start_x;
***************
*** 8000,8006 ****
  
          if (end_hpos > start_hpos)
            {
!             x_draw_glyphs (w, start_x, row, TEXT_AREA, 
                             start_hpos, end_hpos, draw, 0);
  
              row->mouse_face_p
--- 8000,8006 ----
  
          if (end_hpos > start_hpos)
            {
!             x_draw_glyphs (w, start_x, row, TEXT_AREA,
                             start_hpos, end_hpos, draw, 0);
  
              row->mouse_face_p
***************
*** 8037,8043 ****
       struct x_display_info *dpyinfo;
  {
    int cleared = 0;
!   
    if (!NILP (dpyinfo->mouse_face_window))
      {
        show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT);
--- 8037,8043 ----
       struct x_display_info *dpyinfo;
  {
    int cleared = 0;
! 
    if (!NILP (dpyinfo->mouse_face_window))
      {
        show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT);
***************
*** 8116,8129 ****
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        frame_to_window_pixel_xy (w, &x, &y);
!       
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
            struct glyph *g = r->glyphs[TEXT_AREA];
            struct glyph *end = g + r->used[TEXT_AREA];
            int gx;
!             
            for (gx = r->x; !found && g < end; gx += g->pixel_width, ++g)
              if (gx >= x)
                {
--- 8116,8129 ----
        struct glyph_row *end = r + w->current_matrix->nrows - 1;
  
        frame_to_window_pixel_xy (w, &x, &y);
! 
        for (; !found && r < end && r->enabled_p; ++r)
        if (r->y >= y)
          {
            struct glyph *g = r->glyphs[TEXT_AREA];
            struct glyph *end = g + r->used[TEXT_AREA];
            int gx;
! 
            for (gx = r->x; !found && g < end; gx += g->pixel_width, ++g)
              if (gx >= x)
                {
***************
*** 8326,8332 ****
  
            int width, height, gx, gy;
            XRectangle rect;
!           
            if (glyph_rect (f1, win_x, win_y, &rect))
              last_mouse_glyph = rect;
            else
--- 8326,8332 ----
  
            int width, height, gx, gy;
            XRectangle rect;
! 
            if (glyph_rect (f1, win_x, win_y, &rect))
              last_mouse_glyph = rect;
            else
***************
*** 8335,8341 ****
                height = FRAME_SMALLEST_FONT_HEIGHT (f1);
                gx = win_x;
                gy = win_y;
!             
                /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
--- 8335,8341 ----
                height = FRAME_SMALLEST_FONT_HEIGHT (f1);
                gx = win_x;
                gy = win_y;
! 
                /* Arrange for the division in PIXEL_TO_CHAR_COL etc. to
                   round down even for negative values.  */
                if (gx < 0)
***************
*** 8344,8350 ****
                  gy -= height - 1;
                gx = (gx + width - 1) / width * width;
                gy = (gy + height - 1) / height * height;
!           
                last_mouse_glyph.width  = width;
                last_mouse_glyph.height = height;
                last_mouse_glyph.x = gx;
--- 8344,8350 ----
                  gy -= height - 1;
                gx = (gx + width - 1) / width * width;
                gy = (gy + height - 1) / height * height;
! 
                last_mouse_glyph.width  = width;
                last_mouse_glyph.height = height;
                last_mouse_glyph.x = gx;
***************
*** 8439,8452 ****
       Window window;
  {
    Lisp_Object tail;
!   
    for (tail = Vframe_list;
         XGCTYPE (tail) == Lisp_Cons;
         tail = XCDR (tail))
      {
        Lisp_Object frame = XCAR (tail);
        Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
!       
        if (menu_bar && xlwmenu_window_p (menu_bar, window))
        return menu_bar;
      }
--- 8439,8452 ----
       Window window;
  {
    Lisp_Object tail;
! 
    for (tail = Vframe_list;
         XGCTYPE (tail) == Lisp_Cons;
         tail = XCDR (tail))
      {
        Lisp_Object frame = XCAR (tail);
        Widget menu_bar = XFRAME (frame)->output_data.x->menubar_widget;
! 
        if (menu_bar && xlwmenu_window_p (menu_bar, window))
        return menu_bar;
      }
***************
*** 8513,8519 ****
  {
    int scroll_bar_p;
    char *end_action;
!   
  #ifdef USE_MOTIF
    scroll_bar_p = XmIsScrollBar (widget);
    end_action = "Release";
--- 8513,8519 ----
  {
    int scroll_bar_p;
    char *end_action;
! 
  #ifdef USE_MOTIF
    scroll_bar_p = XmIsScrollBar (widget);
    end_action = "Release";
***************
*** 8527,8533 ****
        && WINDOWP (window_being_scrolled))
      {
        struct window *w;
!       
        x_send_scroll_bar_event (window_being_scrolled,
                               scroll_bar_end_scroll, 0, 0);
        w = XWINDOW (window_being_scrolled);
--- 8527,8533 ----
        && WINDOWP (window_being_scrolled))
      {
        struct window *w;
! 
        x_send_scroll_bar_event (window_being_scrolled,
                               scroll_bar_end_scroll, 0, 0);
        w = XWINDOW (window_being_scrolled);
***************
*** 8564,8570 ****
    int i;
  
    BLOCK_INPUT;
!   
    /* Construct a ClientMessage event to send to the frame.  */
    ev->type = ClientMessage;
    ev->message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_Scrollbar;
--- 8564,8570 ----
    int i;
  
    BLOCK_INPUT;
! 
    /* Construct a ClientMessage event to send to the frame.  */
    ev->type = ClientMessage;
    ev->message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_Scrollbar;
***************
*** 8585,8591 ****
        int new_size = max (10, 2 * scroll_bar_windows_size);
        size_t nbytes = new_size * sizeof *scroll_bar_windows;
        size_t old_nbytes = scroll_bar_windows_size * sizeof 
*scroll_bar_windows;
!       
        scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows,
                                                        nbytes);
        bzero (&scroll_bar_windows[i], nbytes - old_nbytes);
--- 8585,8591 ----
        int new_size = max (10, 2 * scroll_bar_windows_size);
        size_t nbytes = new_size * sizeof *scroll_bar_windows;
        size_t old_nbytes = scroll_bar_windows_size * sizeof 
*scroll_bar_windows;
! 
        scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows,
                                                        nbytes);
        bzero (&scroll_bar_windows[i], nbytes - old_nbytes);
***************
*** 8622,8634 ****
    Lisp_Object window;
    struct frame *f;
    struct window *w;
!   
    w = scroll_bar_windows[ev->data.l[0]];
    scroll_bar_windows[ev->data.l[0]] = NULL;
  
    XSETWINDOW (window, w);
    f = XFRAME (w->frame);
!   
    ievent->kind = SCROLL_BAR_CLICK_EVENT;
    ievent->frame_or_window = window;
    ievent->arg = Qnil;
--- 8622,8634 ----
    Lisp_Object window;
    struct frame *f;
    struct window *w;
! 
    w = scroll_bar_windows[ev->data.l[0]];
    scroll_bar_windows[ev->data.l[0]] = NULL;
  
    XSETWINDOW (window, w);
    f = XFRAME (w->frame);
! 
    ievent->kind = SCROLL_BAR_CLICK_EVENT;
    ievent->frame_or_window = window;
    ievent->arg = Qnil;
***************
*** 8689,8695 ****
        bar->dragging = Qnil;
        part = scroll_bar_to_top;
        break;
!       
      case XmCR_TO_BOTTOM:
        bar->dragging = Qnil;
        part = scroll_bar_to_bottom;
--- 8689,8695 ----
        bar->dragging = Qnil;
        part = scroll_bar_to_top;
        break;
! 
      case XmCR_TO_BOTTOM:
        bar->dragging = Qnil;
        part = scroll_bar_to_bottom;
***************
*** 8712,8718 ****
        bar->dragging = make_number (cs->value);
        }
        break;
!       
      case XmCR_VALUE_CHANGED:
        break;
      };
--- 8712,8718 ----
        bar->dragging = make_number (cs->value);
        }
        break;
! 
      case XmCR_VALUE_CHANGED:
        break;
      };
***************
*** 8846,8859 ****
        XtSetArg (av[ac], XmNforeground, pixel);
        ++ac;
      }
!   
    pixel = f->output_data.x->scroll_bar_background_pixel;
    if (pixel != -1)
      {
        XtSetArg (av[ac], XmNbackground, pixel);
        ++ac;
      }
!   
    widget = XmCreateScrollBar (f->output_data.x->edit_widget,
                              scroll_bar_name, av, ac);
  
--- 8846,8859 ----
        XtSetArg (av[ac], XmNforeground, pixel);
        ++ac;
      }
! 
    pixel = f->output_data.x->scroll_bar_background_pixel;
    if (pixel != -1)
      {
        XtSetArg (av[ac], XmNbackground, pixel);
        ++ac;
      }
! 
    widget = XmCreateScrollBar (f->output_data.x->edit_widget,
                              scroll_bar_name, av, ac);
  
***************
*** 8872,8878 ****
                 (XtPointer) bar);
    XtAddCallback (widget, XmNtoTopCallback, xm_scroll_callback,
                 (XtPointer) bar);
!   
    /* Realize the widget.  Only after that is the X window created.  */
    XtRealizeWidget (widget);
  
--- 8872,8878 ----
                 (XtPointer) bar);
    XtAddCallback (widget, XmNtoTopCallback, xm_scroll_callback,
                 (XtPointer) bar);
! 
    /* Realize the widget.  Only after that is the X window created.  */
    XtRealizeWidget (widget);
  
***************
*** 8880,8888 ****
       And I'm wondering why it hasn't an arrow cursor by default.  */
    XDefineCursor (XtDisplay (widget), XtWindow (widget),
                 f->output_data.x->nontext_cursor);
!   
  #else /* !USE_MOTIF i.e. use Xaw */
!   
    /* Set resources.  Create the widget.  The background of the
       Xaw3d scroll bar widget is a little bit light for my taste.
       We don't alter it here to let users change it according
--- 8880,8888 ----
       And I'm wondering why it hasn't an arrow cursor by default.  */
    XDefineCursor (XtDisplay (widget), XtWindow (widget),
                 f->output_data.x->nontext_cursor);
! 
  #else /* !USE_MOTIF i.e. use Xaw */
! 
    /* Set resources.  Create the widget.  The background of the
       Xaw3d scroll bar widget is a little bit light for my taste.
       We don't alter it here to let users change it according
***************
*** 8891,8904 ****
    XtSetArg (av[ac], XtNorientation, XtorientVertical); ++ac;
    /* For smoother scrolling with Xaw3d   -sm */
    /* XtSetArg (av[ac], XtNpickTop, True); ++ac; */
!   
    pixel = f->output_data.x->scroll_bar_foreground_pixel;
    if (pixel != -1)
      {
        XtSetArg (av[ac], XtNforeground, pixel);
        ++ac;
      }
!   
    pixel = f->output_data.x->scroll_bar_background_pixel;
    if (pixel != -1)
      {
--- 8891,8904 ----
    XtSetArg (av[ac], XtNorientation, XtorientVertical); ++ac;
    /* For smoother scrolling with Xaw3d   -sm */
    /* XtSetArg (av[ac], XtNpickTop, True); ++ac; */
! 
    pixel = f->output_data.x->scroll_bar_foreground_pixel;
    if (pixel != -1)
      {
        XtSetArg (av[ac], XtNforeground, pixel);
        ++ac;
      }
! 
    pixel = f->output_data.x->scroll_bar_background_pixel;
    if (pixel != -1)
      {
***************
*** 8975,8996 ****
        XtVaSetValues (widget, XtNcursorName, "top_left_arrow", NULL);
        }
    }
!   
    /* Define callbacks.  */
    XtAddCallback (widget, XtNjumpProc, xaw_jump_callback, (XtPointer) bar);
    XtAddCallback (widget, XtNscrollProc, xaw_scroll_callback,
                 (XtPointer) bar);
!   
    /* Realize the widget.  Only after that is the X window created.  */
    XtRealizeWidget (widget);
!   
  #endif /* !USE_MOTIF */
  
    /* Install an action hook that lets us detect when the user
       finishes interacting with a scroll bar.  */
    if (action_hook_id == 0)
      action_hook_id = XtAppAddActionHook (Xt_app_con, xt_action_hook, 0);
!   
    /* Remember X window and widget in the scroll bar vector.  */
    SET_SCROLL_BAR_X_WIDGET (bar, widget);
    xwindow = XtWindow (widget);
--- 8975,8996 ----
        XtVaSetValues (widget, XtNcursorName, "top_left_arrow", NULL);
        }
    }
! 
    /* Define callbacks.  */
    XtAddCallback (widget, XtNjumpProc, xaw_jump_callback, (XtPointer) bar);
    XtAddCallback (widget, XtNscrollProc, xaw_scroll_callback,
                 (XtPointer) bar);
! 
    /* Realize the widget.  Only after that is the X window created.  */
    XtRealizeWidget (widget);
! 
  #endif /* !USE_MOTIF */
  
    /* Install an action hook that lets us detect when the user
       finishes interacting with a scroll bar.  */
    if (action_hook_id == 0)
      action_hook_id = XtAppAddActionHook (Xt_app_con, xt_action_hook, 0);
! 
    /* Remember X window and widget in the scroll bar vector.  */
    SET_SCROLL_BAR_X_WIDGET (bar, widget);
    xwindow = XtWindow (widget);
***************
*** 9055,9061 ****
        value = top * XM_SB_RANGE;
        value = min (value, XM_SB_MAX - size);
        value = max (value, XM_SB_MIN);
!       
        XmScrollBarSetValues (widget, value, size, 0, 0, False);
      }
  #else /* !USE_MOTIF i.e. use Xaw */
--- 9055,9061 ----
        value = top * XM_SB_RANGE;
        value = min (value, XM_SB_MAX - size);
        value = max (value, XM_SB_MIN);
! 
        XmScrollBarSetValues (widget, value, size, 0, 0, False);
      }
  #else /* !USE_MOTIF i.e. use Xaw */
***************
*** 9097,9103 ****
  #ifdef HAVE_XAW3D
            ScrollbarWidget sb = (ScrollbarWidget) widget;
            int scroll_mode = 0;
!           
            /* `scroll_mode' only exists with Xaw3d + ARROW_SCROLLBAR.  */
            if (xaw3d_arrow_scroll)
              {
--- 9097,9103 ----
  #ifdef HAVE_XAW3D
            ScrollbarWidget sb = (ScrollbarWidget) widget;
            int scroll_mode = 0;
! 
            /* `scroll_mode' only exists with Xaw3d + ARROW_SCROLLBAR.  */
            if (xaw3d_arrow_scroll)
              {
***************
*** 9111,9119 ****
            /* Try to make the scrolling a tad smoother.  */
            if (!xaw3d_pick_top)
              shown = min (shown, old_shown);
!           
            XawScrollbarSetThumb (widget, top, shown);
!           
  #ifdef HAVE_XAW3D
            if (xaw3d_arrow_scroll && scroll_mode == 2)
              sb->scrollbar.scroll_mode = scroll_mode;
--- 9111,9119 ----
            /* Try to make the scrolling a tad smoother.  */
            if (!xaw3d_pick_top)
              shown = min (shown, old_shown);
! 
            XawScrollbarSetThumb (widget, top, shown);
! 
  #ifdef HAVE_XAW3D
            if (xaw3d_arrow_scroll && scroll_mode == 2)
              sb->scrollbar.scroll_mode = scroll_mode;
***************
*** 9133,9139 ****
  /************************************************************************
                         Scroll bars, general
   ************************************************************************/
!                                                                        
  /* Create a scroll bar and return the scroll bar vector for it.  W is
     the Emacs window on which to create the scroll bar. TOP, LEFT,
     WIDTH and HEIGHT are the pixel coordinates and dimensions of the
--- 9133,9139 ----
  /************************************************************************
                         Scroll bars, general
   ************************************************************************/
! 
  /* Create a scroll bar and return the scroll bar vector for it.  W is
     the Emacs window on which to create the scroll bar. TOP, LEFT,
     WIDTH and HEIGHT are the pixel coordinates and dimensions of the
***************
*** 9161,9167 ****
      a.background_pixel = f->output_data.x->scroll_bar_background_pixel;
      if (a.background_pixel == -1)
        a.background_pixel = f->output_data.x->background_pixel;
!     
      a.event_mask = (ButtonPressMask | ButtonReleaseMask
                    | ButtonMotionMask | PointerMotionHintMask
                    | ExposureMask);
--- 9161,9167 ----
      a.background_pixel = f->output_data.x->scroll_bar_background_pixel;
      if (a.background_pixel == -1)
        a.background_pixel = f->output_data.x->background_pixel;
! 
      a.event_mask = (ButtonPressMask | ButtonReleaseMask
                    | ButtonMotionMask | PointerMotionHintMask
                    | ExposureMask);
***************
*** 9231,9237 ****
  
  
  /* Draw BAR's handle in the proper position.
!    
     If the handle is already drawn from START to END, don't bother
     redrawing it, unless REBUILD is non-zero; in that case, always
     redraw it.  (REBUILD is handy for drawing the handle after expose
--- 9231,9237 ----
  
  
  /* Draw BAR's handle in the proper position.
! 
     If the handle is already drawn from START to END, don't bother
     redrawing it, unless REBUILD is non-zero; in that case, always
     redraw it.  (REBUILD is handy for drawing the handle after expose
***************
*** 9358,9364 ****
  #else
    XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
  #endif
!   
    /* Disassociate this scroll bar from its window.  */
    XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
  
--- 9358,9364 ----
  #else
    XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar));
  #endif
! 
    /* Disassociate this scroll bar from its window.  */
    XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
  
***************
*** 9405,9420 ****
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     sb_left = left + width - sb_width - (width - sb_width) / 2; 
    else
      sb_left = left + (width - sb_width) / 2;
  #else
    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     sb_left = left + width - sb_width; 
    else
      sb_left = left;
  #endif
!   
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
      {
--- 9405,9420 ----
    /* Compute the left edge of the scroll bar.  */
  #ifdef USE_TOOLKIT_SCROLL_BARS
    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     sb_left = left + width - sb_width - (width - sb_width) / 2;
    else
      sb_left = left + (width - sb_width) / 2;
  #else
    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
!     sb_left = left + width - sb_width;
    else
      sb_left = left;
  #endif
! 
    /* Does the scroll bar exist yet?  */
    if (NILP (w->vertical_scroll_bar))
      {
***************
*** 9425,9438 ****
                        left, top, width, height, False);
          UNBLOCK_INPUT;
        }
!       
        bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
      }
    else
      {
        /* It may just need to be moved and resized.  */
        unsigned int mask = 0;
!       
        bar = XSCROLL_BAR (w->vertical_scroll_bar);
  
        BLOCK_INPUT;
--- 9425,9438 ----
                        left, top, width, height, False);
          UNBLOCK_INPUT;
        }
! 
        bar = x_scroll_bar_create (w, top, sb_left, sb_width, height);
      }
    else
      {
        /* It may just need to be moved and resized.  */
        unsigned int mask = 0;
! 
        bar = XSCROLL_BAR (w->vertical_scroll_bar);
  
        BLOCK_INPUT;
***************
*** 9443,9451 ****
        mask |= CWY;
        if (sb_width != XINT (bar->width))
        mask |= CWWidth;
!       if (height != XINT (bar->height))       
        mask |= CWHeight;
!       
  #ifdef USE_TOOLKIT_SCROLL_BARS
  
        /* Since toolkit scroll bars are smaller than the space reserved
--- 9443,9451 ----
        mask |= CWY;
        if (sb_width != XINT (bar->width))
        mask |= CWWidth;
!       if (height != XINT (bar->height))
        mask |= CWHeight;
! 
  #ifdef USE_TOOLKIT_SCROLL_BARS
  
        /* Since toolkit scroll bars are smaller than the space reserved
***************
*** 9463,9469 ****
                           max (height, 1), 0);
  
  #else /* not USE_TOOLKIT_SCROLL_BARS */
!   
        /* Clear areas not covered by the scroll bar because of
         VERTICAL_SCROLL_BAR_WIDTH_TRIM.  */
        if (VERTICAL_SCROLL_BAR_WIDTH_TRIM)
--- 9463,9469 ----
                           max (height, 1), 0);
  
  #else /* not USE_TOOLKIT_SCROLL_BARS */
! 
        /* Clear areas not covered by the scroll bar because of
         VERTICAL_SCROLL_BAR_WIDTH_TRIM.  */
        if (VERTICAL_SCROLL_BAR_WIDTH_TRIM)
***************
*** 9495,9506 ****
                            left, top, rest, height, False);
          }
        }
!       
        /* Move/size the scroll bar window.  */
        if (mask)
        {
          XWindowChanges wc;
!         
          wc.x = sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM;
          wc.y = top;
          wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2;
--- 9495,9506 ----
                            left, top, rest, height, False);
          }
        }
! 
        /* Move/size the scroll bar window.  */
        if (mask)
        {
          XWindowChanges wc;
! 
          wc.x = sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM;
          wc.y = top;
          wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2;
***************
*** 9508,9514 ****
          XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar),
                            mask, &wc);
        }
!   
  #endif /* not USE_TOOLKIT_SCROLL_BARS */
  
        /* Remember new settings.  */
--- 9508,9514 ----
          XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar),
                            mask, &wc);
        }
! 
  #endif /* not USE_TOOLKIT_SCROLL_BARS */
  
        /* Remember new settings.  */
***************
*** 9516,9522 ****
        XSETINT (bar->top, top);
        XSETINT (bar->width, sb_width);
        XSETINT (bar->height, height);
!       
        UNBLOCK_INPUT;
      }
  
--- 9516,9522 ----
        XSETINT (bar->top, top);
        XSETINT (bar->width, sb_width);
        XSETINT (bar->height, height);
! 
        UNBLOCK_INPUT;
      }
  
***************
*** 9680,9686 ****
                  0, 0,
                  XINT (bar->width) - 1 - width_trim - width_trim,
                  XINT (bar->height) - 1);
!     
    UNBLOCK_INPUT;
  
  #endif /* not USE_TOOLKIT_SCROLL_BARS */
--- 9680,9686 ----
                  0, 0,
                  XINT (bar->width) - 1 - width_trim - width_trim,
                  XINT (bar->height) - 1);
! 
    UNBLOCK_INPUT;
  
  #endif /* not USE_TOOLKIT_SCROLL_BARS */
***************
*** 9706,9712 ****
    emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
    emacs_event->code = event->xbutton.button - Button1;
    emacs_event->modifiers
!     = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO 
                               (XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))),
                               event->xbutton.state)
         | (event->type == ButtonRelease
--- 9706,9712 ----
    emacs_event->kind = SCROLL_BAR_CLICK_EVENT;
    emacs_event->code = event->xbutton.button - Button1;
    emacs_event->modifiers
!     = (x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO
                               (XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))),
                               event->xbutton.state)
         | (event->type == ButtonRelease
***************
*** 10125,10131 ****
      abort ();                 /* Don't think this happens.  */
  
    ++handling_signal;
!   
    /* Find the display we are supposed to read input for.
       It's the one communicating on descriptor SD.  */
    for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
--- 10125,10131 ----
      abort ();                 /* Don't think this happens.  */
  
    ++handling_signal;
! 
    /* Find the display we are supposed to read input for.
       It's the one communicating on descriptor SD.  */
    for (dpyinfo = x_display_list; dpyinfo; dpyinfo = dpyinfo->next)
***************
*** 10221,10227 ****
         below are temporally close (on a fast machine), the call
         below can generate additional FocusIn events which confuse
         Emacs.  */
!                       
                        /* Since we set WM_TAKE_FOCUS, we must call
                           XSetInputFocus explicitly.  But not if f is null,
                           since that might be an event for a deleted frame.  */
--- 10221,10227 ----
         below are temporally close (on a fast machine), the call
         below can generate additional FocusIn events which confuse
         Emacs.  */
! 
                        /* Since we set WM_TAKE_FOCUS, we must call
                           XSetInputFocus explicitly.  But not if f is null,
                           since that might be an event for a deleted frame.  */
***************
*** 10240,10246 ****
                               if there is an error.  */
                            XSync (d, False);
                            x_uncatch_errors (d, count);
!                         }  
                        /* Not certain about handling scroll bars here */
  #endif /* 0 */
                      }
--- 10240,10246 ----
                               if there is an error.  */
                            XSync (d, False);
                            x_uncatch_errors (d, count);
!                         }
                        /* Not certain about handling scroll bars here */
  #endif /* 0 */
                      }
***************
*** 10528,10534 ****
                  tip_window = 0;
                  redo_mouse_highlight ();
                }
!             
              f = x_top_window_to_frame (dpyinfo, event.xunmap.window);
              if (f)            /* F may no longer exist if
                                   the frame was deleted.  */
--- 10528,10534 ----
                  tip_window = 0;
                  redo_mouse_highlight ();
                }
! 
              f = x_top_window_to_frame (dpyinfo, event.xunmap.window);
              if (f)            /* F may no longer exist if
                                   the frame was deleted.  */
***************
*** 10562,10568 ****
                /* The tooltip has been drawn already.  Avoid
                   the SET_FRAME_GARBAGED below.  */
                goto OTHER;
!             
              /* We use x_top_window_to_frame because map events can
                 come for sub-windows and they don't mean that the
                 frame is visible.  */
--- 10562,10568 ----
                /* The tooltip has been drawn already.  Avoid
                   the SET_FRAME_GARBAGED below.  */
                goto OTHER;
! 
              /* We use x_top_window_to_frame because map events can
                 come for sub-windows and they don't mean that the
                 frame is visible.  */
***************
*** 10881,10887 ****
                              else
                                c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
                                                            nbytes - i, len);
!                             
                              bufp->kind = (SINGLE_BYTE_CHAR_P (c)
                                            ? ASCII_KEYSTROKE_EVENT
                                            : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
--- 10881,10887 ----
                              else
                                c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
                                                            nbytes - i, len);
! 
                              bufp->kind = (SINGLE_BYTE_CHAR_P (c)
                                            ? ASCII_KEYSTROKE_EVENT
                                            : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
***************
*** 10935,10941 ****
                  {
                    bufp += n, count += n, numchars -= n;
                  }
!               
                f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
  
  #if 0
--- 10935,10941 ----
                  {
                    bufp += n, count += n, numchars -= n;
                  }
! 
                f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
  
  #if 0
***************
*** 11033,11039 ****
                previous_help_echo = help_echo;
                help_echo = help_echo_object = help_echo_window = Qnil;
                help_echo_pos = -1;
!               
                if (dpyinfo->grabbed && last_mouse_frame
                    && FRAME_LIVE_P (last_mouse_frame))
                  f = last_mouse_frame;
--- 11033,11039 ----
                previous_help_echo = help_echo;
                help_echo = help_echo_object = help_echo_window = Qnil;
                help_echo_pos = -1;
! 
                if (dpyinfo->grabbed && last_mouse_frame
                    && FRAME_LIVE_P (last_mouse_frame))
                  f = last_mouse_frame;
***************
*** 11111,11117 ****
                                        help_echo_pos);
                    bufp += n, count += n, numchars -= n;
                  }
!               
                goto OTHER;
              }
  
--- 11111,11117 ----
                                        help_echo_pos);
                    bufp += n, count += n, numchars -= n;
                  }
! 
                goto OTHER;
              }
  
***************
*** 11131,11137 ****
                  int columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width);
                    if (dont_resize)
                      goto OTHER;
!                 
                  /* In the toolkit version, change_frame_size
                     is called by the code that handles resizing
                     of the EmacsFrame widget.  */
--- 11131,11137 ----
                  int columns = PIXEL_TO_CHAR_WIDTH (f, event.xconfigure.width);
                    if (dont_resize)
                      goto OTHER;
! 
                  /* In the toolkit version, change_frame_size
                     is called by the code that handles resizing
                     of the EmacsFrame widget.  */
***************
*** 11184,11190 ****
                   by the rest of Emacs, we put it here.  */
                struct input_event emacs_event;
                int tool_bar_p = 0;
!               
                emacs_event.kind = NO_EVENT;
                bzero (&compose_status, sizeof (compose_status));
  
--- 11184,11190 ----
                   by the rest of Emacs, we put it here.  */
                struct input_event emacs_event;
                int tool_bar_p = 0;
! 
                emacs_event.kind = NO_EVENT;
                bzero (&compose_status, sizeof (compose_status));
  
***************
*** 11242,11248 ****
                       the ButtonPress.  */
                    if (f != 0)
                      f->mouse_moved = 0;
!                   
                    if (!tool_bar_p)
                      last_tool_bar_item = -1;
                  }
--- 11242,11248 ----
                       the ButtonPress.  */
                    if (f != 0)
                      f->mouse_moved = 0;
! 
                    if (!tool_bar_p)
                      last_tool_bar_item = -1;
                  }
***************
*** 11306,11312 ****
  
            case CirculateNotify:
              goto OTHER;
!             
            case CirculateRequest:
              goto OTHER;
  
--- 11306,11312 ----
  
            case CirculateNotify:
              goto OTHER;
! 
            case CirculateRequest:
              goto OTHER;
  
***************
*** 11420,11426 ****
             the buffer and window end because update_text_area
             doesn't draw that row.  (Except when it does, but
             that's handled in update_text_area.)  */
!         
          if (((y0 >= cy0 && y0 < cy1) || (y1 > cy0 && y1 < cy1))
              && w->current_matrix->rows[w->phys_cursor.vpos].displays_text_p)
            w->phys_cursor_on_p = 0;
--- 11420,11426 ----
             the buffer and window end because update_text_area
             doesn't draw that row.  (Except when it does, but
             that's handled in update_text_area.)  */
! 
          if (((y0 >= cy0 && y0 < cy1) || (y1 > cy0 && y1 < cy1))
              && w->current_matrix->rows[w->phys_cursor.vpos].displays_text_p)
            w->phys_cursor_on_p = 0;
***************
*** 11506,11512 ****
        && !x_stretch_cursor_p)
      wd = min (CANON_X_UNIT (f), wd);
    w->phys_cursor_width = wd;
!   
    /* The foreground of cursor_gc is typically the same as the normal
       background color, which can cause the cursor box to be invisible.  */
    xgcv.foreground = f->output_data.x->cursor_pixel;
--- 11506,11512 ----
        && !x_stretch_cursor_p)
      wd = min (CANON_X_UNIT (f), wd);
    w->phys_cursor_width = wd;
! 
    /* The foreground of cursor_gc is typically the same as the normal
       background color, which can cause the cursor box to be invisible.  */
    xgcv.foreground = f->output_data.x->cursor_pixel;
***************
*** 11540,11546 ****
  {
    struct frame *f = XFRAME (w->frame);
    struct glyph *cursor_glyph;
!       
    /* If cursor is out of bounds, don't draw garbage.  This can happen
       in mini-buffer windows when switching between echo area glyphs
       and mini-buffer.  */
--- 11540,11546 ----
  {
    struct frame *f = XFRAME (w->frame);
    struct glyph *cursor_glyph;
! 
    /* If cursor is out of bounds, don't draw garbage.  This can happen
       in mini-buffer windows when switching between echo area glyphs
       and mini-buffer.  */
***************
*** 11576,11582 ****
        else
        xgcv.background = xgcv.foreground = f->output_data.x->cursor_pixel;
        xgcv.graphics_exposures = 0;
!   
        if (gc)
        XChangeGC (dpy, gc, mask, &xgcv);
        else
--- 11576,11582 ----
        else
        xgcv.background = xgcv.foreground = f->output_data.x->cursor_pixel;
        xgcv.graphics_exposures = 0;
! 
        if (gc)
        XChangeGC (dpy, gc, mask, &xgcv);
        else
***************
*** 11584,11597 ****
          gc = XCreateGC (dpy, window, mask, &xgcv);
          FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc = gc;
        }
!   
        if (width < 0)
        width = FRAME_CURSOR_WIDTH (f);
        width = min (cursor_glyph->pixel_width, width);
!   
        w->phys_cursor_width = width;
        x_clip_to_row (w, row, gc, 0);
!       
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
                          WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
--- 11584,11597 ----
          gc = XCreateGC (dpy, window, mask, &xgcv);
          FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc = gc;
        }
! 
        if (width < 0)
        width = FRAME_CURSOR_WIDTH (f);
        width = min (cursor_glyph->pixel_width, width);
! 
        w->phys_cursor_width = width;
        x_clip_to_row (w, row, gc, 0);
! 
        if (kind == BAR_CURSOR)
          XFillRectangle (dpy, window, gc,
                          WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
***************
*** 11639,11645 ****
      {
        int on_p = w->phys_cursor_on_p;
        int x1;
!       
        x1 = x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
                          w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
                          hl, 0);
--- 11639,11645 ----
      {
        int on_p = w->phys_cursor_on_p;
        int x1;
! 
        x1 = x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
                          w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
                          hl, 0);
***************
*** 11685,11691 ****
       screen.  */
    if (w->phys_cursor_type == NO_CURSOR)
      goto mark_cursor_off;
!          
    /* VPOS >= active_glyphs->nrows means that window has been resized.
       Don't bother to erase the cursor.  */
    if (vpos >= active_glyphs->nrows)
--- 11685,11691 ----
       screen.  */
    if (w->phys_cursor_type == NO_CURSOR)
      goto mark_cursor_off;
! 
    /* VPOS >= active_glyphs->nrows means that window has been resized.
       Don't bother to erase the cursor.  */
    if (vpos >= active_glyphs->nrows)
***************
*** 11696,11708 ****
    cursor_row = MATRIX_ROW (active_glyphs, vpos);
    if (!cursor_row->enabled_p)
      goto mark_cursor_off;
!   
    /* If row is completely invisible, don't attempt to delete a cursor which
       isn't there.  This can happen if cursor is at top of a window, and
       we switch to a buffer with a header line in that window.  */
    if (cursor_row->visible_height <= 0)
      goto mark_cursor_off;
!   
    /* This can happen when the new row is shorter than the old one.
       In this case, either x_draw_glyphs or clear_end_of_line
       should have cleared the cursor.  Note that we wouldn't be
--- 11696,11708 ----
    cursor_row = MATRIX_ROW (active_glyphs, vpos);
    if (!cursor_row->enabled_p)
      goto mark_cursor_off;
! 
    /* If row is completely invisible, don't attempt to delete a cursor which
       isn't there.  This can happen if cursor is at top of a window, and
       we switch to a buffer with a header line in that window.  */
    if (cursor_row->visible_height <= 0)
      goto mark_cursor_off;
! 
    /* This can happen when the new row is shorter than the old one.
       In this case, either x_draw_glyphs or clear_end_of_line
       should have cleared the cursor.  Note that we wouldn't be
***************
*** 11710,11716 ****
       cursor glyph at hand.  */
    if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])
      goto mark_cursor_off;
!        
    /* If the cursor is in the mouse face area, redisplay that when
       we clear the cursor.  */
    if (! NILP (dpyinfo->mouse_face_window)
--- 11710,11716 ----
       cursor glyph at hand.  */
    if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])
      goto mark_cursor_off;
! 
    /* If the cursor is in the mouse face area, redisplay that when
       we clear the cursor.  */
    if (! NILP (dpyinfo->mouse_face_window)
***************
*** 11738,11744 ****
        goto mark_cursor_off;
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
!       
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    x,
                    WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
--- 11738,11744 ----
        goto mark_cursor_off;
  
        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
! 
        x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
                    x,
                    WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
***************
*** 11747,11753 ****
                    cursor_row->visible_height,
                    False);
      }
!   
    /* Erase the cursor by redrawing the character underneath it.  */
    if (mouse_face_here_p)
      hl = DRAW_MOUSE_FACE;
--- 11747,11753 ----
                    cursor_row->visible_height,
                    False);
      }
! 
    /* Erase the cursor by redrawing the character underneath it.  */
    if (mouse_face_here_p)
      hl = DRAW_MOUSE_FACE;
***************
*** 11769,11775 ****
  {
    struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
    int in_mouse_face = 0;
!   
    if (WINDOWP (dpyinfo->mouse_face_window)
        && XWINDOW (dpyinfo->mouse_face_window) == w)
      {
--- 11769,11775 ----
  {
    struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
    int in_mouse_face = 0;
! 
    if (WINDOWP (dpyinfo->mouse_face_window)
        && XWINDOW (dpyinfo->mouse_face_window) == w)
      {
***************
*** 11823,11830 ****
    current_glyphs = w->current_matrix;
    glyph_row = MATRIX_ROW (current_glyphs, vpos);
    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
!   
!   /* If cursor row is not enabled, we don't really know where to 
       display the cursor.  */
    if (!glyph_row->enabled_p)
      {
--- 11823,11830 ----
    current_glyphs = w->current_matrix;
    glyph_row = MATRIX_ROW (current_glyphs, vpos);
    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
! 
!   /* If cursor row is not enabled, we don't really know where to
       display the cursor.  */
    if (!glyph_row->enabled_p)
      {
***************
*** 11858,11864 ****
      {
        w->phys_cursor_ascent = glyph_row->ascent;
        w->phys_cursor_height = glyph_row->height;
!       
        /* Set phys_cursor_.* before x_draw_.* is called because some
         of them may need the information.  */
        w->phys_cursor.x = x;
--- 11858,11864 ----
      {
        w->phys_cursor_ascent = glyph_row->ascent;
        w->phys_cursor_height = glyph_row->height;
! 
        /* Set phys_cursor_.* before x_draw_.* is called because some
         of them may need the information.  */
        w->phys_cursor.x = x;
***************
*** 11893,11899 ****
        default:
          abort ();
        }
!       
  #ifdef HAVE_X_I18N
        if (w == XWINDOW (f->selected_window))
        if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition))
--- 11893,11899 ----
        default:
          abort ();
        }
! 
  #ifdef HAVE_X_I18N
        if (w == XWINDOW (f->selected_window))
        if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition))
***************
*** 12188,12197 ****
  
  /* Handle SIGPIPE, which can happen when the connection to a server
     simply goes away.  SIGPIPE is handled by x_connection_signal.
!    Don't need to do anything, because the write which caused the 
     SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
     which will do the appropriate cleanup for us.  */
!    
  static SIGTYPE
  x_connection_signal (signalnum)       /* If we don't have an argument, */
       int signalnum;           /* some compilers complain in signal calls.  */
--- 12188,12197 ----
  
  /* Handle SIGPIPE, which can happen when the connection to a server
     simply goes away.  SIGPIPE is handled by x_connection_signal.
!    Don't need to do anything, because the write which caused the
     SIGPIPE will fail, causing Xlib to invoke the X IO error handler,
     which will do the appropriate cleanup for us.  */
! 
  static SIGTYPE
  x_connection_signal (signalnum)       /* If we don't have an argument, */
       int signalnum;           /* some compilers complain in signal calls.  */
***************
*** 12234,12250 ****
    struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
    Lisp_Object frame, tail;
    int count;
!   
    error_msg = (char *) alloca (strlen (error_message) + 1);
    strcpy (error_msg, error_message);
    handling_signal = 0;
!   
    /* Prevent being called recursively because of an error condition
       below.  Otherwise, we might end up with printing ``can't find per
       display information'' in the recursive call instead of printing
       the original message here.  */
    count = x_catch_errors (dpy);
!   
    /* We have to close the display to inform Xt that it doesn't
       exist anymore.  If we don't, Xt will continue to wait for
       events from the display.  As a consequence, a sequence of
--- 12234,12250 ----
    struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
    Lisp_Object frame, tail;
    int count;
! 
    error_msg = (char *) alloca (strlen (error_message) + 1);
    strcpy (error_msg, error_message);
    handling_signal = 0;
! 
    /* Prevent being called recursively because of an error condition
       below.  Otherwise, we might end up with printing ``can't find per
       display information'' in the recursive call instead of printing
       the original message here.  */
    count = x_catch_errors (dpy);
! 
    /* We have to close the display to inform Xt that it doesn't
       exist anymore.  If we don't, Xt will continue to wait for
       events from the display.  As a consequence, a sequence of
***************
*** 12259,12265 ****
       Closing the display is reported to lead to a bus error on
       OpenWindows in certain situations.  I suspect that is a bug
       in OpenWindows.  I don't know how to cicumvent it here.  */
!   
  #ifdef USE_X_TOOLKIT
    /* If DPYINFO is null, this means we didn't open the display
       in the first place, so don't try to close it.  */
--- 12259,12265 ----
       Closing the display is reported to lead to a bus error on
       OpenWindows in certain situations.  I suspect that is a bug
       in OpenWindows.  I don't know how to cicumvent it here.  */
! 
  #ifdef USE_X_TOOLKIT
    /* If DPYINFO is null, this means we didn't open the display
       in the first place, so don't try to close it.  */
***************
*** 12307,12313 ****
      x_delete_display (dpyinfo);
  
    x_uncatch_errors (dpy, count);
!   
    if (x_display_list == 0)
      {
        fprintf (stderr, "%s\n", error_msg);
--- 12307,12313 ----
      x_delete_display (dpyinfo);
  
    x_uncatch_errors (dpy, count);
! 
    if (x_display_list == 0)
      {
        fprintf (stderr, "%s\n", error_msg);
***************
*** 12475,12481 ****
        && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));
  #endif
!   
    return build_string (fontsetname);
  }
  
--- 12475,12481 ----
        && (FRAME_XIC_STYLE (f) & (XIMPreeditPosition | XIMStatusArea)))
      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));
  #endif
! 
    return build_string (fontsetname);
  }
  
***************
*** 12584,12592 ****
  {
    struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
    Lisp_Object frame, tail;
!   
    BLOCK_INPUT;
!   
    /* No need to call XDestroyIC.. */
    FOR_EACH_FRAME (tail, frame)
      {
--- 12584,12592 ----
  {
    struct x_display_info *dpyinfo = (struct x_display_info *) client_data;
    Lisp_Object frame, tail;
! 
    BLOCK_INPUT;
! 
    /* No need to call XDestroyIC.. */
    FOR_EACH_FRAME (tail, frame)
      {
***************
*** 12601,12607 ****
            }
        }
      }
!   
    /* No need to call XCloseIM.  */
    dpyinfo->xim = NULL;
    XFree (dpyinfo->xim_styles);
--- 12601,12607 ----
            }
        }
      }
! 
    /* No need to call XCloseIM.  */
    dpyinfo->xim = NULL;
    XFree (dpyinfo->xim_styles);
***************
*** 12629,12638 ****
  #ifdef HAVE_X11R6
        XIMCallback destroy;
  #endif
!       
        /* Get supported styles and XIM values.  */
        XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
!       
  #ifdef HAVE_X11R6
        destroy.callback = xim_destroy_callback;
        destroy.client_data = (XPointer)dpyinfo;
--- 12629,12638 ----
  #ifdef HAVE_X11R6
        XIMCallback destroy;
  #endif
! 
        /* Get supported styles and XIM values.  */
        XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL);
! 
  #ifdef HAVE_X11R6
        destroy.callback = xim_destroy_callback;
        destroy.client_data = (XPointer)dpyinfo;
***************
*** 12640,12646 ****
        XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
  #endif
      }
!   
  #else /* not USE_XIM */
    dpyinfo->xim = NULL;
  #endif /* not USE_XIM */
--- 12640,12646 ----
        XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
  #endif
      }
! 
  #else /* not USE_XIM */
    dpyinfo->xim = NULL;
  #endif /* not USE_XIM */
***************
*** 12672,12678 ****
    /* We don't support multiple XIM connections. */
    if (dpyinfo->xim)
      return;
!   
    xim_open_dpy (dpyinfo, xim_inst->resource_name);
  
    /* Create XIC for the existing frames on the same display, as long
--- 12672,12678 ----
    /* We don't support multiple XIM connections. */
    if (dpyinfo->xim)
      return;
! 
    xim_open_dpy (dpyinfo, xim_inst->resource_name);
  
    /* Create XIC for the existing frames on the same display, as long
***************
*** 12685,12691 ****
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
!         
          if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
            if (FRAME_XIC (f) == NULL)
              {
--- 12685,12691 ----
        FOR_EACH_FRAME (tail, frame)
        {
          struct frame *f = XFRAME (frame);
! 
          if (FRAME_X_DISPLAY_INFO (f) == xim_inst->dpyinfo)
            if (FRAME_XIC (f) == NULL)
              {
***************
*** 12699,12705 ****
                  }
              }
        }
!       
        UNBLOCK_INPUT;
      }
  }
--- 12699,12705 ----
                  }
              }
        }
! 
        UNBLOCK_INPUT;
      }
  }
***************
*** 12721,12727 ****
  #ifdef HAVE_X11R6_XIM
    struct xim_inst_t *xim_inst;
    int len;
!   
    dpyinfo->xim = NULL;
    xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
    xim_inst->dpyinfo = dpyinfo;
--- 12721,12727 ----
  #ifdef HAVE_X11R6_XIM
    struct xim_inst_t *xim_inst;
    int len;
! 
    dpyinfo->xim = NULL;
    xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
    xim_inst->dpyinfo = dpyinfo;
***************
*** 12739,12745 ****
    dpyinfo->xim = NULL;
    xim_open_dpy (dpyinfo, resource_name);
  #endif /* not HAVE_X11R6_XIM */
!   
  #else /* not USE_XIM */
    dpyinfo->xim = NULL;
  #endif /* not USE_XIM */
--- 12739,12745 ----
    dpyinfo->xim = NULL;
    xim_open_dpy (dpyinfo, resource_name);
  #endif /* not HAVE_X11R6_XIM */
! 
  #else /* not USE_XIM */
    dpyinfo->xim = NULL;
  #endif /* not USE_XIM */
***************
*** 12861,12867 ****
  
         It's not obvious where the initial small difference comes from.
         2000-12-01, gerd.  */
!     
      XtVaGetValues (f->output_data.x->column_widget, XtNheight, &height, NULL);
  #endif
  
--- 12861,12867 ----
  
         It's not obvious where the initial small difference comes from.
         2000-12-01, gerd.  */
! 
      XtVaGetValues (f->output_data.x->column_widget, XtNheight, &height, NULL);
  #endif
  
***************
*** 12872,12878 ****
                                 - height
                                 + f->output_data.x->top_pos);
    }
!   
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
--- 12872,12878 ----
                                 - height
                                 + f->output_data.x->top_pos);
    }
! 
    /* The left_pos and top_pos
       are now relative to the top and left screen edges,
       so the flags should correspond.  */
***************
*** 12941,12952 ****
    if (f->output_data.x->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
!                       
        x_real_positions (f, &f->output_data.x->left_pos,
                          &f->output_data.x->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
!                   
        /* We do not need to move the window, it shall be taken care of
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
--- 12941,12952 ----
    if (f->output_data.x->want_fullscreen & FULLSCREEN_BOTH)
      {
        int width, height, ign;
! 
        x_real_positions (f, &f->output_data.x->left_pos,
                          &f->output_data.x->top_pos);
  
        x_fullscreen_adjust (f, &width, &height, &ign, &ign);
! 
        /* We do not need to move the window, it shall be taken care of
           when setting WM manager hints.
           If the frame is visible already, the position is checked by
***************
*** 12959,12965 ****
  
            /* Wait for the change of frame size to occur */
            f->output_data.x->want_fullscreen |= FULLSCREEN_WAIT;
!           
          }
      }
  }
--- 12959,12965 ----
  
            /* Wait for the change of frame size to occur */
            f->output_data.x->want_fullscreen |= FULLSCREEN_WAIT;
! 
          }
      }
  }
***************
*** 12983,12989 ****
        expect_top = 0;
      if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
!     
      if (expect_top != f->output_data.x->top_pos
          || expect_left != f->output_data.x->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
--- 12983,12989 ----
        expect_top = 0;
      if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
        expect_left = 0;
! 
      if (expect_top != f->output_data.x->top_pos
          || expect_left != f->output_data.x->left_pos)
        x_set_offset (f, expect_left, expect_top, 1);
***************
*** 13011,13021 ****
  
    *top_pos = f->output_data.x->top_pos;
    *left_pos = f->output_data.x->left_pos;
!   
    if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
      {
        int ph;
!       
        ph = FRAME_X_DISPLAY_INFO (f)->height;
        newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
        ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
--- 13011,13021 ----
  
    *top_pos = f->output_data.x->top_pos;
    *left_pos = f->output_data.x->left_pos;
! 
    if (f->output_data.x->want_fullscreen & FULLSCREEN_HEIGHT)
      {
        int ph;
! 
        ph = FRAME_X_DISPLAY_INFO (f)->height;
        newheight = PIXEL_TO_CHAR_HEIGHT (f, ph);
        ph = CHAR_TO_PIXEL_HEIGHT (f, newheight)
***************
*** 13027,13033 ****
    if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
      {
        int pw;
!       
        pw = FRAME_X_DISPLAY_INFO (f)->width;
        newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
        pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
--- 13027,13033 ----
    if (f->output_data.x->want_fullscreen & FULLSCREEN_WIDTH)
      {
        int pw;
! 
        pw = FRAME_X_DISPLAY_INFO (f)->width;
        newwidth = PIXEL_TO_CHAR_WIDTH (f, pw);
        pw = CHAR_TO_PIXEL_WIDTH (f, newwidth)
***************
*** 13115,13121 ****
    BLOCK_INPUT;
  
  #ifdef USE_X_TOOLKIT
!   
    if (f->output_data.x->widget != NULL)
      {
        /* The x and y position of the widget is clobbered by the
--- 13115,13121 ----
    BLOCK_INPUT;
  
  #ifdef USE_X_TOOLKIT
! 
    if (f->output_data.x->widget != NULL)
      {
        /* The x and y position of the widget is clobbered by the
***************
*** 13130,13147 ****
      }
    else
      x_set_window_size_1 (f, change_gravity, cols, rows);
!   
  #else /* not USE_X_TOOLKIT */
!   
    x_set_window_size_1 (f, change_gravity, cols, rows);
!   
  #endif /* not USE_X_TOOLKIT */
  
    /* If cursor was outside the new size, mark it as off.  */
    mark_window_cursors_off (XWINDOW (f->root_window));
  
    /* Clear out any recollection of where the mouse highlighting was,
!      since it might be in a place that's outside the new frame size. 
       Actually checking whether it is outside is a pain in the neck,
       so don't try--just let the highlighting be done afresh with new size.  */
    cancel_mouse_face (f);
--- 13130,13147 ----
      }
    else
      x_set_window_size_1 (f, change_gravity, cols, rows);
! 
  #else /* not USE_X_TOOLKIT */
! 
    x_set_window_size_1 (f, change_gravity, cols, rows);
! 
  #endif /* not USE_X_TOOLKIT */
  
    /* If cursor was outside the new size, mark it as off.  */
    mark_window_cursors_off (XWINDOW (f->root_window));
  
    /* Clear out any recollection of where the mouse highlighting was,
!      since it might be in a place that's outside the new frame size.
       Actually checking whether it is outside is a pain in the neck,
       so don't try--just let the highlighting be done afresh with new size.  */
    cancel_mouse_face (f);
***************
*** 13357,13363 ****
        Drawable rootw;
        int x, y;
        unsigned int width, height, border, depth;
!       
        BLOCK_INPUT;
  
        /* On some window managers (such as FVWM) moving an existing
--- 13357,13363 ----
        Drawable rootw;
        int x, y;
        unsigned int width, height, border, depth;
! 
        BLOCK_INPUT;
  
        /* On some window managers (such as FVWM) moving an existing
***************
*** 13420,13426 ****
         FreeBSD, Linux and Solaris.  It turns out that, for some
         unknown reason, the call to XtMapWidget is completely ignored.
         Mapping the widget a second time works.  */
!     
      if (!FRAME_VISIBLE_P (f) && --retry_count > 0)
        goto retry;
    }
--- 13420,13426 ----
         FreeBSD, Linux and Solaris.  It turns out that, for some
         unknown reason, the call to XtMapWidget is completely ignored.
         Mapping the widget a second time works.  */
! 
      if (!FRAME_VISIBLE_P (f) && --retry_count > 0)
        goto retry;
    }
***************
*** 13697,13703 ****
  
        if (FRAME_FACE_CACHE (f))
        free_frame_faces (f);
!       
        x_free_gcs (f);
        XFlush (FRAME_X_DISPLAY (f));
      }
--- 13697,13703 ----
  
        if (FRAME_FACE_CACHE (f))
        free_frame_faces (f);
! 
        x_free_gcs (f);
        XFlush (FRAME_X_DISPLAY (f));
      }
***************
*** 13707,13713 ****
  
    xfree (f->output_data.x);
    f->output_data.x = NULL;
!   
    if (f == dpyinfo->x_focus_frame)
      dpyinfo->x_focus_frame = 0;
    if (f == dpyinfo->x_focus_event_frame)
--- 13707,13713 ----
  
    xfree (f->output_data.x);
    f->output_data.x = NULL;
! 
    if (f == dpyinfo->x_focus_frame)
      dpyinfo->x_focus_frame = 0;
    if (f == dpyinfo->x_focus_event_frame)
***************
*** 13961,13967 ****
    }
  
  #else /* not USE_X_TOOLKIT */
!   
    f->output_data.x->wm_hints.flags |= IconPixmapHint;
    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
  
--- 13961,13967 ----
    }
  
  #else /* not USE_X_TOOLKIT */
! 
    f->output_data.x->wm_hints.flags |= IconPixmapHint;
    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
  
***************
*** 14141,14147 ****
              int width = 0;
              char *p = names[i];
              int average_width = -1, dashes = 0;
!             
              /* Count the number of dashes in NAMES[I].  If there are
                 14 dashes, and the field value following 12th dash
                 (AVERAGE_WIDTH) is 0, this is a auto-scaled font which
--- 14141,14147 ----
              int width = 0;
              char *p = names[i];
              int average_width = -1, dashes = 0;
! 
              /* Count the number of dashes in NAMES[I].  If there are
                 14 dashes, and the field value following 12th dash
                 (AVERAGE_WIDTH) is 0, this is a auto-scaled font which
***************
*** 14156,14162 ****
                    else if (dashes == 12) /* AVERAGE_WIDTH field */
                      average_width = atoi (p);
                  }
!             
              if (allow_scalable_fonts_p
                  || dashes < 14 || average_width != 0)
                {
--- 14156,14162 ----
                    else if (dashes == 12) /* AVERAGE_WIDTH field */
                      average_width = atoi (p);
                  }
! 
              if (allow_scalable_fonts_p
                  || dashes < 14 || average_width != 0)
                {
***************
*** 14176,14182 ****
                    }
                }
            }
!         
          if (!try_XLoadQueryFont)
            {
              BLOCK_INPUT;
--- 14176,14182 ----
                    }
                }
            }
! 
          if (!try_XLoadQueryFont)
            {
              BLOCK_INPUT;
***************
*** 14276,14282 ****
      }
  
    return newlist;
! }  
  
  
  #if GLYPH_DEBUG
--- 14276,14282 ----
      }
  
    return newlist;
! }
  
  
  #if GLYPH_DEBUG
***************
*** 14295,14301 ****
    xassert (font != NULL);
  
    for (i = 0; i < dpyinfo->n_fonts; i++)
!     if (dpyinfo->font_table[i].name 
        && font == dpyinfo->font_table[i].font)
        break;
  
--- 14295,14301 ----
    xassert (font != NULL);
  
    for (i = 0; i < dpyinfo->n_fonts; i++)
!     if (dpyinfo->font_table[i].name
        && font == dpyinfo->font_table[i].font)
        break;
  
***************
*** 14341,14360 ****
    XFontStruct *font;
    int old_width = dpyinfo->smallest_char_width;
    int old_height = dpyinfo->smallest_font_height;
!   
    dpyinfo->smallest_font_height = 100000;
    dpyinfo->smallest_char_width = 100000;
!   
    for (i = 0; i < dpyinfo->n_fonts; ++i)
      if (dpyinfo->font_table[i].name)
        {
        struct font_info *fontp = dpyinfo->font_table + i;
        int w, h;
!       
        font = (XFontStruct *) fontp->font;
        xassert (font != (XFontStruct *) ~0);
        x_font_min_bounds (font, &w, &h);
!       
        dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);
        dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);
        }
--- 14341,14360 ----
    XFontStruct *font;
    int old_width = dpyinfo->smallest_char_width;
    int old_height = dpyinfo->smallest_font_height;
! 
    dpyinfo->smallest_font_height = 100000;
    dpyinfo->smallest_char_width = 100000;
! 
    for (i = 0; i < dpyinfo->n_fonts; ++i)
      if (dpyinfo->font_table[i].name)
        {
        struct font_info *fontp = dpyinfo->font_table + i;
        int w, h;
! 
        font = (XFontStruct *) fontp->font;
        xassert (font != (XFontStruct *) ~0);
        x_font_min_bounds (font, &w, &h);
! 
        dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);
        dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);
        }
***************
*** 14489,14495 ****
  
        XFree (name);
        }
!     
      if (full_name != 0)
        fontp->full_name = full_name;
      else
--- 14489,14495 ----
  
        XFree (name);
        }
! 
      if (full_name != 0)
        fontp->full_name = full_name;
      else
***************
*** 14621,14627 ****
                  >= 0)))
        break;
      }
!   
    if (! NILP (list))
      {
        struct ccl_program *ccl
--- 14621,14627 ----
                  >= 0)))
        break;
      }
! 
    if (! NILP (list))
      {
        struct ccl_program *ccl
***************
*** 14824,14830 ****
    dpyinfo->next = x_display_list;
    x_display_list = dpyinfo;
  
!   /* Put it on x_display_name_list as well, to keep them parallel.  */ 
    x_display_name_list = Fcons (Fcons (display_name, Qnil),
                               x_display_name_list);
    dpyinfo->name_list_element = XCAR (x_display_name_list);
--- 14824,14830 ----
    dpyinfo->next = x_display_list;
    x_display_list = dpyinfo;
  
!   /* Put it on x_display_name_list as well, to keep them parallel.  */
    x_display_name_list = Fcons (Fcons (display_name, Qnil),
                               x_display_name_list);
    dpyinfo->name_list_element = XCAR (x_display_name_list);
***************
*** 14911,14917 ****
    else
      dpyinfo->cmap = XCreateColormap (dpyinfo->display, dpyinfo->root_window,
                                     dpyinfo->visual, AllocNone);
!       
    {
      int screen_number = XScreenNumberOfScreen (dpyinfo->screen);
      double pixels = DisplayHeight (dpyinfo->display, screen_number);
--- 14911,14917 ----
    else
      dpyinfo->cmap = XCreateColormap (dpyinfo->display, dpyinfo->root_window,
                                     dpyinfo->visual, AllocNone);
! 
    {
      int screen_number = XScreenNumberOfScreen (dpyinfo->screen);
      double pixels = DisplayHeight (dpyinfo->display, screen_number);
***************
*** 14921,14927 ****
      mm = DisplayWidthMM (dpyinfo->display, screen_number);
      dpyinfo->resx = pixels * 25.4 / mm;
    }
!   
    dpyinfo->Xatom_wm_protocols
      = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False);
    dpyinfo->Xatom_wm_take_focus
--- 14921,14927 ----
      mm = DisplayWidthMM (dpyinfo->display, screen_number);
      dpyinfo->resx = pixels * 25.4 / mm;
    }
! 
    dpyinfo->Xatom_wm_protocols
      = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False);
    dpyinfo->Xatom_wm_take_focus
***************
*** 14975,14981 ****
    /* Ghostscript support.  */
    dpyinfo->Xatom_PAGE = XInternAtom (dpyinfo->display, "PAGE", False);
    dpyinfo->Xatom_DONE = XInternAtom (dpyinfo->display, "DONE", False);
!   
    dpyinfo->Xatom_Scrollbar = XInternAtom (dpyinfo->display, "SCROLLBAR",
                                          False);
  
--- 14975,14981 ----
    /* Ghostscript support.  */
    dpyinfo->Xatom_PAGE = XInternAtom (dpyinfo->display, "PAGE", False);
    dpyinfo->Xatom_DONE = XInternAtom (dpyinfo->display, "DONE", False);
! 
    dpyinfo->Xatom_Scrollbar = XInternAtom (dpyinfo->display, "SCROLLBAR",
                                          False);
  
***************
*** 14990,14996 ****
      null_bits[0] = 0x00;
  
      dpyinfo->null_pixel
!       = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, 
                                     null_bits, 1, 1, (long) 0, (long) 0,
                                     1);
    }
--- 14990,14996 ----
      null_bits[0] = 0x00;
  
      dpyinfo->null_pixel
!       = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
                                     null_bits, 1, 1, (long) 0, (long) 0,
                                     1);
    }
***************
*** 15008,15014 ****
  #ifdef HAVE_X_I18N
    xim_initialize (dpyinfo, resource_name);
  #endif
!   
  #ifdef subprocesses
    /* This is only needed for distinguishing keyboard and process input.  */
    if (connection != 0)
--- 15008,15014 ----
  #ifdef HAVE_X_I18N
    xim_initialize (dpyinfo, resource_name);
  #endif
! 
  #ifdef subprocesses
    /* This is only needed for distinguishing keyboard and process input.  */
    if (connection != 0)
***************
*** 15040,15046 ****
      XrmValue d, fr, to;
      Font font;
      int count;
!     
      d.addr = (XPointer)&dpy;
      d.size = sizeof (Display *);
      fr.addr = XtDefaultFont;
--- 15040,15046 ----
      XrmValue d, fr, to;
      Font font;
      int count;
! 
      d.addr = (XPointer)&dpy;
      d.size = sizeof (Display *);
      fr.addr = XtDefaultFont;
***************
*** 15070,15076 ****
            || !strcmp (SDATA (value), "on")))
        XSynchronize (dpyinfo->display, True);
    }
!   
    UNBLOCK_INPUT;
  
    return dpyinfo;
--- 15070,15076 ----
            || !strcmp (SDATA (value), "on")))
        XSynchronize (dpyinfo->display, True);
    }
! 
    UNBLOCK_INPUT;
  
    return dpyinfo;
***************
*** 15133,15139 ****
    if (dpyinfo->xim)
      xim_close_dpy (dpyinfo);
  #endif
!   
    xfree (dpyinfo->font_table);
    xfree (dpyinfo->x_id_name);
    xfree (dpyinfo->color_cells);
--- 15133,15139 ----
    if (dpyinfo->xim)
      xim_close_dpy (dpyinfo);
  #endif
! 
    xfree (dpyinfo->font_table);
    xfree (dpyinfo->x_id_name);
    xfree (dpyinfo->color_cells);
***************
*** 15196,15202 ****
    x_noop_count = 0;
    last_tool_bar_item = -1;
    any_help_event_p = 0;
!   
    /* Try to use interrupt input; if we can't, then start polling.  */
    Fset_input_mode (Qt, Qnil, Qt, Qnil);
  
--- 15196,15202 ----
    x_noop_count = 0;
    last_tool_bar_item = -1;
    any_help_event_p = 0;
! 
    /* Try to use interrupt input; if we can't, then start polling.  */
    Fset_input_mode (Qt, Qnil, Qt, Qnil);
  
***************
*** 15204,15210 ****
    XtToolkitInitialize ();
  
    Xt_app_con = XtCreateApplicationContext ();
!   
    /* Register a converter from strings to pixels, which uses
       Emacs' color allocation infrastructure.  */
    XtAppSetTypeConverter (Xt_app_con,
--- 15204,15210 ----
    XtToolkitInitialize ();
  
    Xt_app_con = XtCreateApplicationContext ();
! 
    /* Register a converter from strings to pixels, which uses
       Emacs' color allocation infrastructure.  */
    XtAppSetTypeConverter (Xt_app_con,
***************
*** 15226,15232 ****
      start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
    }
  #endif
!   
  #ifdef USE_TOOLKIT_SCROLL_BARS
    xaw3d_arrow_scroll = False;
    xaw3d_pick_top = True;
--- 15226,15232 ----
      start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
    }
  #endif
! 
  #ifdef USE_TOOLKIT_SCROLL_BARS
    xaw3d_arrow_scroll = False;
    xaw3d_pick_top = True;
***************
*** 15319,15325 ****
  
    staticpro (&last_mouse_motion_frame);
    last_mouse_motion_frame = Qnil;
!   
    Qmodifier_value = intern ("modifier-value");
    Qalt = intern ("alt");
    Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
--- 15319,15325 ----
  
    staticpro (&last_mouse_motion_frame);
    last_mouse_motion_frame = Qnil;
! 
    Qmodifier_value = intern ("modifier-value");
    Qalt = intern ("alt");
    Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
***************
*** 15329,15356 ****
    Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
    Qsuper = intern ("super");
    Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
!   
    DEFVAR_LISP ("x-alt-keysym", &Vx_alt_keysym,
      doc: /* Which keys Emacs uses for the alt modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `alt' means use the Alt_L and Alt_R keysyms.  The default
  is nil, which is the same as `alt'.  */);
    Vx_alt_keysym = Qnil;
!   
    DEFVAR_LISP ("x-hyper-keysym", &Vx_hyper_keysym,
      doc: /* Which keys Emacs uses for the hyper modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `hyper' means use the Hyper_L and Hyper_R keysyms.  The
  default is nil, which is the same as `hyper'.  */);
    Vx_hyper_keysym = Qnil;
!   
    DEFVAR_LISP ("x-meta-keysym", &Vx_meta_keysym,
      doc: /* Which keys Emacs uses for the meta modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `meta' means use the Meta_L and Meta_R keysyms.  The
  default is nil, which is the same as `meta'.  */);
    Vx_meta_keysym = Qnil;
!   
    DEFVAR_LISP ("x-super-keysym", &Vx_super_keysym,
      doc: /* Which keys Emacs uses for the super modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
--- 15329,15356 ----
    Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
    Qsuper = intern ("super");
    Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
! 
    DEFVAR_LISP ("x-alt-keysym", &Vx_alt_keysym,
      doc: /* Which keys Emacs uses for the alt modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `alt' means use the Alt_L and Alt_R keysyms.  The default
  is nil, which is the same as `alt'.  */);
    Vx_alt_keysym = Qnil;
! 
    DEFVAR_LISP ("x-hyper-keysym", &Vx_hyper_keysym,
      doc: /* Which keys Emacs uses for the hyper modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `hyper' means use the Hyper_L and Hyper_R keysyms.  The
  default is nil, which is the same as `hyper'.  */);
    Vx_hyper_keysym = Qnil;
! 
    DEFVAR_LISP ("x-meta-keysym", &Vx_meta_keysym,
      doc: /* Which keys Emacs uses for the meta modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.
  For example, `meta' means use the Meta_L and Meta_R keysyms.  The
  default is nil, which is the same as `meta'.  */);
    Vx_meta_keysym = Qnil;
! 
    DEFVAR_LISP ("x-super-keysym", &Vx_super_keysym,
      doc: /* Which keys Emacs uses for the super modifier.
  This should be one of the symbols `alt', `hyper', `meta', `super'.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]