/[emacs]/emacs/src/macterm.c
ViewVC logotype

Diff of /emacs/src/macterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by akochoi, Tue Jan 28 18:46:06 2003 UTC revision 1.34 by lektu, Tue Feb 4 14:03:12 2003 UTC
# Line 202  Lisp_Object Vx_toolkit_scroll_bars; Line 202  Lisp_Object Vx_toolkit_scroll_bars;
202    
203  /* If a string, XTread_socket generates an event to display that string.  /* If a string, XTread_socket generates an event to display that string.
204     (The display is done in read_char.)  */     (The display is done in read_char.)  */
205      
206  static Lisp_Object help_echo;  static Lisp_Object help_echo;
207  static Lisp_Object help_echo_window;  static Lisp_Object help_echo_window;
208  static Lisp_Object help_echo_object;  static Lisp_Object help_echo_object;
# Line 259  extern int waiting_for_input; Line 259  extern int waiting_for_input;
259    
260  struct frame *pending_autoraise_frame;  struct frame *pending_autoraise_frame;
261    
262  /* Nominal cursor position -- where to draw output.    /* Nominal cursor position -- where to draw output.
263     HPOS and VPOS are window relative glyph matrix coordinates.     HPOS and VPOS are window relative glyph matrix coordinates.
264     X and Y are window relative pixel coordinates.  */     X and Y are window relative pixel coordinates.  */
265    
# Line 456  static void x_update_cursor_in_window_tr Line 456  static void x_update_cursor_in_window_tr
456  static void x_update_window_cursor P_ ((struct window *, int));  static void x_update_window_cursor P_ ((struct window *, int));
457  static void x_erase_phys_cursor P_ ((struct window *));  static void x_erase_phys_cursor P_ ((struct window *));
458  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));  void x_display_and_set_cursor P_ ((struct window *, int, int, int, int, int));
459  static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *,  static void x_draw_fringe_bitmap P_ ((struct window *, struct glyph_row *,
460                                        enum fringe_bitmap_type, int left_p));                                        enum fringe_bitmap_type, int left_p));
461  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,  static void x_clip_to_row P_ ((struct window *, struct glyph_row *,
462                                 GC, int));                                 GC, int));
# Line 505  XFreePixmap (display, pixmap) Line 505  XFreePixmap (display, pixmap)
505       Pixmap pixmap;       Pixmap pixmap;
506  {  {
507    PixMap *p = (PixMap *) pixmap;    PixMap *p = (PixMap *) pixmap;
508      
509    xfree (p->baseAddr);    xfree (p->baseAddr);
510    xfree (p);    xfree (p);
511  }  }
# Line 518  static void Line 518  static void
518  mac_set_forecolor (unsigned long color)  mac_set_forecolor (unsigned long color)
519  {  {
520    RGBColor fg_color;    RGBColor fg_color;
521                                                    
522    fg_color.red = RED_FROM_ULONG (color) * 256;    fg_color.red = RED_FROM_ULONG (color) * 256;
523    fg_color.green = GREEN_FROM_ULONG (color) * 256;    fg_color.green = GREEN_FROM_ULONG (color) * 256;
524    fg_color.blue = BLUE_FROM_ULONG (color) * 256;    fg_color.blue = BLUE_FROM_ULONG (color) * 256;
525                            
526    RGBForeColor (&fg_color);      RGBForeColor (&fg_color);
527  }  }
528    
529    
# Line 534  static void Line 534  static void
534  mac_set_backcolor (unsigned long color)  mac_set_backcolor (unsigned long color)
535  {  {
536    RGBColor bg_color;    RGBColor bg_color;
537                                                    
538    bg_color.red = RED_FROM_ULONG (color) * 256;    bg_color.red = RED_FROM_ULONG (color) * 256;
539    bg_color.green = GREEN_FROM_ULONG (color) * 256;    bg_color.green = GREEN_FROM_ULONG (color) * 256;
540    bg_color.blue = BLUE_FROM_ULONG (color) * 256;    bg_color.blue = BLUE_FROM_ULONG (color) * 256;
541                            
542    RGBBackColor (&bg_color);      RGBBackColor (&bg_color);
543  }  }
544    
545  /* Set foreground and background color for subsequent QuickDraw  /* Set foreground and background color for subsequent QuickDraw
# Line 626  XClearWindow (display, w) Line 626  XClearWindow (display, w)
626  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
627    {    {
628      Rect r;      Rect r;
629        
630      GetWindowPortBounds (w, &r);      GetWindowPortBounds (w, &r);
631      EraseRect (&r);      EraseRect (&r);
632    }    }
# Line 667  mac_draw_bitmap (display, w, gc, x, y, b Line 667  mac_draw_bitmap (display, w, gc, x, y, b
667      UnlockPortBits (GetWindowPort (w));      UnlockPortBits (GetWindowPort (w));
668    }    }
669  #else /* not TARGET_API_MAC_CARBON */  #else /* not TARGET_API_MAC_CARBON */
670    CopyBits (bitmap, &(w->portBits), &(bitmap->bounds), &r, srcCopy, 0);    CopyBits (bitmap, &(w->portBits), &(bitmap->bounds), &r, srcCopy, 0);
671  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
672  }  }
673    
# Line 698  mac_reset_clipping (display, w) Line 698  mac_reset_clipping (display, w)
698       WindowPtr w;       WindowPtr w;
699  {  {
700    Rect r;    Rect r;
701      
702  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
703    SetPort (GetWindowPort (w));    SetPort (GetWindowPort (w));
704  #else  #else
# Line 957  static void Line 957  static void
957  local_to_global_coord (short *h, short *v)  local_to_global_coord (short *h, short *v)
958  {  {
959    Point p;    Point p;
960      
961    p.h = *h;    p.h = *h;
962    p.v = *v;    p.v = *v;
963      
964    LocalToGlobal (&p);    LocalToGlobal (&p);
965      
966    *h = p.h;    *h = p.h;
967    *v = p.v;    *v = p.v;
968  }  }
# Line 1023  mac_scroll_area (display, w, gc, src_x, Line 1023  mac_scroll_area (display, w, gc, src_x,
1023    ForeColor (blackColor);    ForeColor (blackColor);
1024    BackColor (whiteColor);    BackColor (whiteColor);
1025    CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);    CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
1026      
1027    mac_set_colors (gc);    mac_set_colors (gc);
1028  #endif  #endif
1029  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
# Line 1033  mac_scroll_area (display, w, gc, src_x, Line 1033  mac_scroll_area (display, w, gc, src_x,
1033  /* Mac replacement for XCopyArea: dest must be Pixmap.  */  /* Mac replacement for XCopyArea: dest must be Pixmap.  */
1034    
1035  static void  static void
1036  mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,  mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1037                       dest_x, dest_y)                       dest_x, dest_y)
1038       Display *display;       Display *display;
1039       Pixmap src;       Pixmap src;
# Line 1050  mac_copy_area_to_pixmap (display, src, d Line 1050  mac_copy_area_to_pixmap (display, src, d
1050    int h = src_bottom - src_y;    int h = src_bottom - src_y;
1051    
1052    mac_set_colors (gc);    mac_set_colors (gc);
1053        
1054    SetRect (&src_r, src_x, src_y, src_right, src_bottom);    SetRect (&src_r, src_x, src_y, src_right, src_bottom);
1055    SetRect (&dest_r, dest_x, dest_y, dest_x + w, dest_y + h);    SetRect (&dest_r, dest_x, dest_y, dest_x + w, dest_y + h);
1056    
# Line 1160  x_sync (f) Line 1160  x_sync (f)
1160  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
1161  #define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL)  #define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL)
1162  #else  #else
1163  #define XFlush(DISPLAY) (void) 0  #define XFlush(DISPLAY) (void) 0
1164  #endif  #endif
1165    
1166  /* Flush display of frame F, or of all frames if F is null.  */  /* Flush display of frame F, or of all frames if F is null.  */
# Line 1200  mac_display_info_for_display (dpy) Line 1200  mac_display_info_for_display (dpy)
1200  /***********************************************************************  /***********************************************************************
1201                      Starting and ending an update                      Starting and ending an update
1202   ***********************************************************************/   ***********************************************************************/
1203                                                                            
1204  /* Start an update of frame F.  This function is installed as a hook  /* Start an update of frame F.  This function is installed as a hook
1205     for update_begin, i.e. it is called when update_begin is called.     for update_begin, i.e. it is called when update_begin is called.
1206     This function is called prior to calls to x_update_window_begin for     This function is called prior to calls to x_update_window_begin for
# Line 1224  x_update_window_begin (w) Line 1224  x_update_window_begin (w)
1224  {  {
1225    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
1226    struct mac_display_info *display_info = FRAME_MAC_DISPLAY_INFO (f);    struct mac_display_info *display_info = FRAME_MAC_DISPLAY_INFO (f);
1227      
1228    updated_window = w;    updated_window = w;
1229    set_output_cursor (&w->cursor);    set_output_cursor (&w->cursor);
1230    
# Line 1246  x_update_window_begin (w) Line 1246  x_update_window_begin (w)
1246           flag set.  So, rows containing mouse-face glyphs are never           flag set.  So, rows containing mouse-face glyphs are never
1247           scrolled, and we don't have to switch the mouse highlight off           scrolled, and we don't have to switch the mouse highlight off
1248           here to prevent it from being scrolled.  */           here to prevent it from being scrolled.  */
1249          
1250        /* Can we tell that this update does not affect the window        /* Can we tell that this update does not affect the window
1251           where the mouse highlight is?  If so, no need to turn off.           where the mouse highlight is?  If so, no need to turn off.
1252           Likewise, don't do anything if the frame is garbaged;           Likewise, don't do anything if the frame is garbaged;
# Line 1279  x_draw_vertical_border (w) Line 1279  x_draw_vertical_border (w)
1279       struct window *w;       struct window *w;
1280  {  {
1281    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
1282      
1283    /* Redraw borders between horizontally adjacent windows.  Don't    /* Redraw borders between horizontally adjacent windows.  Don't
1284       do it for frames with vertical scroll bars because either the       do it for frames with vertical scroll bars because either the
1285       right scroll bar of a window, or the left scroll bar of its       right scroll bar of a window, or the left scroll bar of its
# Line 1292  x_draw_vertical_border (w) Line 1292  x_draw_vertical_border (w)
1292        window_box_edges (w, -1, &x0, &y0, &x1, &y1);        window_box_edges (w, -1, &x0, &y0, &x1, &y1);
1293        x1 += FRAME_X_RIGHT_FRINGE_WIDTH (f);        x1 += FRAME_X_RIGHT_FRINGE_WIDTH (f);
1294        y1 -= 1;        y1 -= 1;
1295          
1296        XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),        XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1297                   f->output_data.mac->normal_gc, x1, y0, x1, y1);                   f->output_data.mac->normal_gc, x1, y0, x1, y1);
1298      }      }
1299  }  }
1300    
1301      
1302  /* End update of window W (which is equal to updated_window).  /* End update of window W (which is equal to updated_window).
1303    
1304     Draw vertical borders between horizontally adjacent windows, and     Draw vertical borders between horizontally adjacent windows, and
# Line 1328  x_update_window_end (w, cursor_on_p, mou Line 1328  x_update_window_end (w, cursor_on_p, mou
1328          x_display_and_set_cursor (w, 1, output_cursor.hpos,          x_display_and_set_cursor (w, 1, output_cursor.hpos,
1329                                    output_cursor.vpos,                                    output_cursor.vpos,
1330                                    output_cursor.x, output_cursor.y);                                    output_cursor.x, output_cursor.y);
1331          
1332        x_draw_vertical_border (w);        x_draw_vertical_border (w);
1333        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1334      }      }
# Line 1371  x_update_end (f) Line 1371  x_update_end (f)
1371  #endif  #endif
1372    
1373    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1374      
1375    /* Mouse highlight may be displayed again.  */    /* Mouse highlight may be displayed again.  */
1376    FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;    FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1377    
# Line 1424  x_after_update_window_line (desired_row) Line 1424  x_after_update_window_line (desired_row)
1424    int width, height;    int width, height;
1425    
1426    xassert (w);    xassert (w);
1427      
1428    if (!desired_row->mode_line_p && !w->pseudo_window_p)    if (!desired_row->mode_line_p && !w->pseudo_window_p)
1429      {      {
1430        BLOCK_INPUT;        BLOCK_INPUT;
# Line 1459  x_after_update_window_line (desired_row) Line 1459  x_after_update_window_line (desired_row)
1459        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1460                    f->output_data.mac->pixel_width - width, y,                    f->output_data.mac->pixel_width - width, y,
1461                    width, height, 0);                    width, height, 0);
1462          
1463        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1464      }      }
1465  }  }
# Line 1506  x_draw_fringe_bitmap (w, row, which, lef Line 1506  x_draw_fringe_bitmap (w, row, which, lef
1506        h = left_height;        h = left_height;
1507        bits = left_bits;        bits = left_bits;
1508        break;        break;
1509          
1510      case OVERLAY_ARROW_BITMAP:      case OVERLAY_ARROW_BITMAP:
1511        wd = ov_width;        wd = ov_width;
1512        h = ov_height;        h = ov_height;
1513        bits = ov_bits;        bits = ov_bits;
1514        break;        break;
1515          
1516      case RIGHT_TRUNCATION_BITMAP:      case RIGHT_TRUNCATION_BITMAP:
1517        wd = right_width;        wd = right_width;
1518        h = right_height;        h = right_height;
# Line 1524  x_draw_fringe_bitmap (w, row, which, lef Line 1524  x_draw_fringe_bitmap (w, row, which, lef
1524        h = continued_height;        h = continued_height;
1525        bits = continued_bits;        bits = continued_bits;
1526        break;        break;
1527          
1528      case CONTINUATION_LINE_BITMAP:      case CONTINUATION_LINE_BITMAP:
1529        wd = continuation_width;        wd = continuation_width;
1530        h = continuation_height;        h = continuation_height;
# Line 1731  set_output_cursor (cursor) Line 1731  set_output_cursor (cursor)
1731    
1732     HPOS and VPOS are column/row positions in a window glyph matrix.  X     HPOS and VPOS are column/row positions in a window glyph matrix.  X
1733     and Y are window text area relative pixel positions.     and Y are window text area relative pixel positions.
1734      
1735     If this is done during an update, updated_window will contain the     If this is done during an update, updated_window will contain the
1736     window that is being updated and the position is the future output     window that is being updated and the position is the future output
1737     cursor position for that window.  If updated_window is null, use     cursor position for that window.  If updated_window is null, use
# Line 1905  x_encode_char (c, char2b, font_info) Line 1905  x_encode_char (c, char2b, font_info)
1905            ccl->reg[1] = char2b->byte1;            ccl->reg[1] = char2b->byte1;
1906            ccl->reg[2] = char2b->byte2;            ccl->reg[2] = char2b->byte2;
1907          }          }
1908          
1909        ccl_driver (ccl, NULL, NULL, 0, 0, NULL);        ccl_driver (ccl, NULL, NULL, 0, 0, NULL);
1910          
1911        /* We assume that MSBs are appropriately set/reset by CCL        /* We assume that MSBs are appropriately set/reset by CCL
1912           program.  */           program.  */
1913        if (font->max_byte1 == 0) /* 1-byte font */        if (font->max_byte1 == 0) /* 1-byte font */
# Line 1920  x_encode_char (c, char2b, font_info) Line 1920  x_encode_char (c, char2b, font_info)
1920        /* Fixed encoding scheme.  See fontset.h for the meaning of the        /* Fixed encoding scheme.  See fontset.h for the meaning of the
1921           encoding numbers.  */           encoding numbers.  */
1922        int enc = font_info->encoding[charset];        int enc = font_info->encoding[charset];
1923          
1924        if ((enc == 1 || enc == 2)        if ((enc == 1 || enc == 2)
1925            && CHARSET_DIMENSION (charset) == 2)            && CHARSET_DIMENSION (charset) == 2)
1926          char2b->byte1 |= 0x80;          char2b->byte1 |= 0x80;
1927          
1928        if (enc == 1 || enc == 3)        if (enc == 1 || enc == 3)
1929          char2b->byte2 |= 0x80;          char2b->byte2 |= 0x80;
1930    
# Line 1972  x_get_char_face_and_encoding (f, c, face Line 1972  x_get_char_face_and_encoding (f, c, face
1972    else    else
1973      {      {
1974        int c1, c2, charset;        int c1, c2, charset;
1975          
1976        /* Split characters into bytes.  If c2 is -1 afterwards, C is        /* Split characters into bytes.  If c2 is -1 afterwards, C is
1977           really a one-byte character so that byte1 is zero.  */           really a one-byte character so that byte1 is zero.  */
1978        SPLIT_CHAR (c, charset, c1, c2);        SPLIT_CHAR (c, charset, c1, c2);
# Line 1994  x_get_char_face_and_encoding (f, c, face Line 1994  x_get_char_face_and_encoding (f, c, face
1994    /* Make sure X resources of the face are allocated.  */    /* Make sure X resources of the face are allocated.  */
1995    xassert (face != NULL);    xassert (face != NULL);
1996    PREPARE_FACE_FOR_DISPLAY (f, face);    PREPARE_FACE_FOR_DISPLAY (f, face);
1997      
1998    return face;    return face;
1999  }  }
2000    
# Line 2035  x_get_glyph_face_and_encoding (f, glyph, Line 2035  x_get_glyph_face_and_encoding (f, glyph,
2035    else    else
2036      {      {
2037        int c1, c2, charset;        int c1, c2, charset;
2038          
2039        /* Split characters into bytes.  If c2 is -1 afterwards, C is        /* Split characters into bytes.  If c2 is -1 afterwards, C is
2040           really a one-byte character so that byte1 is zero.  */           really a one-byte character so that byte1 is zero.  */
2041        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);        SPLIT_CHAR (glyph->u.ch, charset, c1, c2);
# Line 2066  x_get_glyph_face_and_encoding (f, glyph, Line 2066  x_get_glyph_face_and_encoding (f, glyph,
2066  }  }
2067    
2068    
2069  /* Store one glyph for IT->char_to_display in IT->glyph_row.    /* Store one glyph for IT->char_to_display in IT->glyph_row.
2070     Called from x_produce_glyphs when IT->glyph_row is non-null.  */     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
2071    
2072  static INLINE void  static INLINE void
# Line 2075  x_append_glyph (it) Line 2075  x_append_glyph (it)
2075  {  {
2076    struct glyph *glyph;    struct glyph *glyph;
2077    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
2078      
2079    xassert (it->glyph_row);    xassert (it->glyph_row);
2080    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');    xassert (it->char_to_display != '\n' && it->char_to_display != '\t');
2081      
2082    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
2083    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
2084      {      {
# Line 2100  x_append_glyph (it) Line 2100  x_append_glyph (it)
2100      }      }
2101  }  }
2102    
2103  /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.    /* Store one glyph for the composition IT->cmp_id in IT->glyph_row.
2104     Called from x_produce_glyphs when IT->glyph_row is non-null.  */     Called from x_produce_glyphs when IT->glyph_row is non-null.  */
2105    
2106  static INLINE void  static INLINE void
# Line 2109  x_append_composite_glyph (it) Line 2109  x_append_composite_glyph (it)
2109  {  {
2110    struct glyph *glyph;    struct glyph *glyph;
2111    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
2112      
2113    xassert (it->glyph_row);    xassert (it->glyph_row);
2114      
2115    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
2116    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
2117      {      {
# Line 2181  x_produce_image_glyph (it) Line 2181  x_produce_image_glyph (it)
2181    it->pixel_width = img->width + 2 * img->hmargin;    it->pixel_width = img->width + 2 * img->hmargin;
2182    
2183    it->nglyphs = 1;    it->nglyphs = 1;
2184      
2185    if (face->box != FACE_NO_BOX)    if (face->box != FACE_NO_BOX)
2186      {      {
2187        if (face->box_line_width > 0)        if (face->box_line_width > 0)
# Line 2189  x_produce_image_glyph (it) Line 2189  x_produce_image_glyph (it)
2189            it->ascent += face->box_line_width;            it->ascent += face->box_line_width;
2190            it->descent += face->box_line_width;            it->descent += face->box_line_width;
2191          }          }
2192          
2193        if (it->start_of_box_run_p)        if (it->start_of_box_run_p)
2194          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
2195        if (it->end_of_box_run_p)        if (it->end_of_box_run_p)
# Line 2197  x_produce_image_glyph (it) Line 2197  x_produce_image_glyph (it)
2197      }      }
2198    
2199    take_vertical_position_into_account (it);    take_vertical_position_into_account (it);
2200      
2201    if (it->glyph_row)    if (it->glyph_row)
2202      {      {
2203        struct glyph *glyph;        struct glyph *glyph;
2204        enum glyph_row_area area = it->area;        enum glyph_row_area area = it->area;
2205          
2206        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];        glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
2207        if (glyph < it->glyph_row->glyphs[area + 1])        if (glyph < it->glyph_row->glyphs[area + 1])
2208          {          {
# Line 2226  x_produce_image_glyph (it) Line 2226  x_produce_image_glyph (it)
2226    
2227    
2228  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source  /* Append a stretch glyph to IT->glyph_row.  OBJECT is the source
2229     of the glyph, WIDTH and HEIGHT are the width and height of the     of the glyph, WIDTH and HEIGHT are the width and height of the
2230     stretch.  ASCENT is the percentage/100 of HEIGHT to use for the     stretch.  ASCENT is the percentage/100 of HEIGHT to use for the
2231     ascent of the glyph (0 <= ASCENT <= 1).  */     ascent of the glyph (0 <= ASCENT <= 1).  */
2232      
2233  static void  static void
2234  x_append_stretch_glyph (it, object, width, height, ascent)  x_append_stretch_glyph (it, object, width, height, ascent)
2235       struct it *it;       struct it *it;
# Line 2241  x_append_stretch_glyph (it, object, widt Line 2241  x_append_stretch_glyph (it, object, widt
2241    enum glyph_row_area area = it->area;    enum glyph_row_area area = it->area;
2242    
2243    xassert (ascent >= 0 && ascent <= 1);    xassert (ascent >= 0 && ascent <= 1);
2244      
2245    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];    glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
2246    if (glyph < it->glyph_row->glyphs[area + 1])    if (glyph < it->glyph_row->glyphs[area + 1])
2247      {      {
# Line 2270  x_append_stretch_glyph (it, object, widt Line 2270  x_append_stretch_glyph (it, object, widt
2270     being recognized:     being recognized:
2271    
2272     1. `:width WIDTH' specifies that the space should be WIDTH *     1. `:width WIDTH' specifies that the space should be WIDTH *
2273     canonical char width wide.  WIDTH may be an integer or floating     canonical char width wide.  WIDTH may be an integer or floating
2274     point number.     point number.
2275    
2276     2. `:relative-width FACTOR' specifies that the width of the stretch     2. `:relative-width FACTOR' specifies that the width of the stretch
# Line 2280  x_append_stretch_glyph (it, object, widt Line 2280  x_append_stretch_glyph (it, object, widt
2280     3. `:align-to HPOS' specifies that the space should be wide enough     3. `:align-to HPOS' specifies that the space should be wide enough
2281     to reach HPOS, a value in canonical character units.     to reach HPOS, a value in canonical character units.
2282    
2283     Exactly one of the above pairs must be present.       Exactly one of the above pairs must be present.
2284    
2285     4. `:height HEIGHT' specifies that the height of the stretch produced     4. `:height HEIGHT' specifies that the height of the stretch produced
2286     should be HEIGHT, measured in canonical character units.     should be HEIGHT, measured in canonical character units.
# Line 2318  x_produce_stretch_glyph (it) Line 2318  x_produce_stretch_glyph (it)
2318    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);    XFontStruct *font = face->font ? face->font : FRAME_FONT (it->f);
2319    
2320    PREPARE_FACE_FOR_DISPLAY (it->f, face);    PREPARE_FACE_FOR_DISPLAY (it->f, face);
2321      
2322    /* List should start with `space'.  */    /* List should start with `space'.  */
2323    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));    xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
2324    plist = XCDR (it->object);    plist = XCDR (it->object);
# Line 2336  x_produce_stretch_glyph (it) Line 2336  x_produce_stretch_glyph (it)
2336           property.  */           property.  */
2337        struct it it2;        struct it it2;
2338        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));        unsigned char *p = BYTE_POS_ADDR (IT_BYTEPOS (*it));
2339          
2340        it2 = *it;        it2 = *it;
2341        if (it->multibyte_p)        if (it->multibyte_p)
2342          {          {
# Line 2358  x_produce_stretch_glyph (it) Line 2358  x_produce_stretch_glyph (it)
2358    else    else
2359      /* Nothing specified -> width defaults to canonical char width.  */      /* Nothing specified -> width defaults to canonical char width.  */
2360      width = CANON_X_UNIT (it->f);      width = CANON_X_UNIT (it->f);
2361      
2362    /* Compute height.  */    /* Compute height.  */
2363    if (prop = Fplist_get (plist, QCheight),    if (prop = Fplist_get (plist, QCheight),
2364        NUMVAL (prop) > 0)        NUMVAL (prop) > 0)
# Line 2369  x_produce_stretch_glyph (it) Line 2369  x_produce_stretch_glyph (it)
2369    else    else
2370      height = FONT_HEIGHT (font);      height = FONT_HEIGHT (font);
2371    
2372    /* Compute percentage of height used for ascent.  If    /* Compute percentage of height used for ascent.  If
2373       `:ascent ASCENT' is present and valid, use that.  Otherwise,       `:ascent ASCENT' is present and valid, use that.  Otherwise,
2374       derive the ascent from the font in use.  */       derive the ascent from the font in use.  */
2375    if (prop = Fplist_get (plist, QCascent),    if (prop = Fplist_get (plist, QCascent),
# Line 2403  x_produce_stretch_glyph (it) Line 2403  x_produce_stretch_glyph (it)
2403            it->ascent += face->box_line_width;            it->ascent += face->box_line_width;
2404            it->descent += face->box_line_width;            it->descent += face->box_line_width;
2405          }          }
2406          
2407        if (it->start_of_box_run_p)        if (it->start_of_box_run_p)
2408          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
2409        if (it->end_of_box_run_p)        if (it->end_of_box_run_p)
2410          it->pixel_width += abs (face->box_line_width);          it->pixel_width += abs (face->box_line_width);
2411      }      }
2412      
2413    take_vertical_position_into_account (it);    take_vertical_position_into_account (it);
2414  }  }
2415    
# Line 2501  x_produce_glyphs (it) Line 2501  x_produce_glyphs (it)
2501                face = FACE_FROM_ID (it->f, it->face_id);                face = FACE_FROM_ID (it->f, it->face_id);
2502              }              }
2503          }          }
2504          
2505        /* Get font to use.  Encode IT->char_to_display.  */        /* Get font to use.  Encode IT->char_to_display.  */
2506        x_get_char_face_and_encoding (it->f, it->char_to_display,        x_get_char_face_and_encoding (it->f, it->char_to_display,
2507                                      it->face_id, &char2b,                                      it->face_id, &char2b,
# Line 2549  x_produce_glyphs (it) Line 2549  x_produce_glyphs (it)
2549                it->phys_descent = FONT_DESCENT (font) - boff;                it->phys_descent = FONT_DESCENT (font) - boff;
2550                it->pixel_width = FONT_WIDTH (font);                it->pixel_width = FONT_WIDTH (font);
2551              }              }
2552              
2553            /* If this is a space inside a region of text with            /* If this is a space inside a region of text with
2554               `space-width' property, change its width.  */               `space-width' property, change its width.  */
2555            stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);            stretched_p = it->char_to_display == ' ' && !NILP (it->space_width);
# Line 2562  x_produce_glyphs (it) Line 2562  x_produce_glyphs (it)
2562            if (face->box != FACE_NO_BOX)            if (face->box != FACE_NO_BOX)
2563              {              {
2564                int thick = face->box_line_width;                int thick = face->box_line_width;
2565                  
2566                if (thick > 0)                if (thick > 0)
2567                  {                  {
2568                    it->ascent += thick;                    it->ascent += thick;
# Line 2570  x_produce_glyphs (it) Line 2570  x_produce_glyphs (it)
2570                  }                  }
2571                else                else
2572                  thick = -thick;                  thick = -thick;
2573                  
2574                if (it->start_of_box_run_p)                if (it->start_of_box_run_p)
2575                  it->pixel_width += thick;                  it->pixel_width += thick;
2576                if (it->end_of_box_run_p)                if (it->end_of_box_run_p)
# Line 2583  x_produce_glyphs (it) Line 2583  x_produce_glyphs (it)
2583              it->ascent += 2;              it->ascent += 2;
2584    
2585            take_vertical_position_into_account (it);            take_vertical_position_into_account (it);
2586      
2587            /* If we have to actually produce glyphs, do it.  */            /* If we have to actually produce glyphs, do it.  */
2588            if (it->glyph_row)            if (it->glyph_row)
2589              {              {
# Line 2593  x_produce_glyphs (it) Line 2593  x_produce_glyphs (it)
2593                       into a stretch glyph.  */                       into a stretch glyph.  */
2594                    double ascent = (double) FONT_BASE (font)                    double ascent = (double) FONT_BASE (font)
2595                                  / FONT_HEIGHT (font);                                  / FONT_HEIGHT (font);
2596                    x_append_stretch_glyph (it, it->object, it->pixel_width,                    x_append_stretch_glyph (it, it->object, it->pixel_width,
2597                                            it->ascent + it->descent, ascent);                                            it->ascent + it->descent, ascent);
2598                  }                  }
2599                else                else
# Line 2613  x_produce_glyphs (it) Line 2613  x_produce_glyphs (it)
2613            it->nglyphs = 0;            it->nglyphs = 0;
2614            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
2615            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
2616          
2617            if (face->box != FACE_NO_BOX            if (face->box != FACE_NO_BOX
2618                && face->box_line_width > 0)                && face->box_line_width > 0)
2619              {              {
# Line 2626  x_produce_glyphs (it) Line 2626  x_produce_glyphs (it)
2626            int tab_width = it->tab_width * CANON_X_UNIT (it->f);            int tab_width = it->tab_width * CANON_X_UNIT (it->f);
2627            int x = it->current_x + it->continuation_lines_width;            int x = it->current_x + it->continuation_lines_width;
2628            int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;            int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width;
2629          
2630            /* If the distance from the current position to the next tab            /* If the distance from the current position to the next tab
2631               stop is less than a canonical character width, use the               stop is less than a canonical character width, use the
2632               tab stop after that.  */               tab stop after that.  */
# Line 2637  x_produce_glyphs (it) Line 2637  x_produce_glyphs (it)
2637            it->nglyphs = 1;            it->nglyphs = 1;
2638            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;            it->ascent = it->phys_ascent = FONT_BASE (font) + boff;
2639            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;            it->descent = it->phys_descent = FONT_DESCENT (font) - boff;
2640              
2641            if (it->glyph_row)            if (it->glyph_row)
2642              {              {
2643                double ascent = (double) it->ascent / (it->ascent + it->descent);                double ascent = (double) it->ascent / (it->ascent + it->descent);
2644                x_append_stretch_glyph (it, it->object, it->pixel_width,                x_append_stretch_glyph (it, it->object, it->pixel_width,
2645                                        it->ascent + it->descent, ascent);                                        it->ascent + it->descent, ascent);
2646              }              }
2647          }          }
2648        else        else
2649          {          {
2650            /* A multi-byte character.  Assume that the display width of the            /* A multi-byte character.  Assume that the display width of the
2651               character is the width of the character multiplied by the               character is the width of the character multiplied by the
# Line 2691  x_produce_glyphs (it) Line 2691  x_produce_glyphs (it)
2691                  }                  }
2692                else                else
2693                  thick = - thick;                  thick = - thick;
2694              
2695                if (it->start_of_box_run_p)                if (it->start_of_box_run_p)
2696                  it->pixel_width += thick;                  it->pixel_width += thick;
2697                if (it->end_of_box_run_p)                if (it->end_of_box_run_p)
2698                  it->pixel_width += thick;                  it->pixel_width += thick;
2699              }              }
2700      
2701            /* If face has an overline, add the height of the overline            /* If face has an overline, add the height of the overline
2702               (1 pixel) and a 1 pixel margin to the character height.  */               (1 pixel) and a 1 pixel margin to the character height.  */
2703            if (face->overline_p)            if (face->overline_p)
2704              it->ascent += 2;              it->ascent += 2;
2705    
2706            take_vertical_position_into_account (it);            take_vertical_position_into_account (it);
2707      
2708            if (it->glyph_row)            if (it->glyph_row)
2709              x_append_glyph (it);              x_append_glyph (it);
2710          }          }
# Line 2798  x_produce_glyphs (it) Line 2798  x_produce_glyphs (it)
2798                ascent = FONT_BASE (font);                ascent = FONT_BASE (font);
2799                descent = FONT_DESCENT (font);                descent = FONT_DESCENT (font);
2800              }              }
2801              
2802            rightmost = width;            rightmost = width;
2803            lowest = - descent + boff;            lowest = - descent + boff;
2804            highest = ascent + boff;            highest = ascent + boff;
2805            leftmost = 0;            leftmost = 0;
2806              
2807            if (font_info            if (font_info
2808                && font_info->default_ascent                && font_info->default_ascent
2809                && CHAR_TABLE_P (Vuse_default_ascent)                && CHAR_TABLE_P (Vuse_default_ascent)
# Line 2964  x_produce_glyphs (it) Line 2964  x_produce_glyphs (it)
2964              }              }
2965            else            else
2966              thick = - thick;              thick = - thick;
2967              
2968            if (it->start_of_box_run_p)            if (it->start_of_box_run_p)
2969              it->pixel_width += thick;              it->pixel_width += thick;
2970            if (it->end_of_box_run_p)            if (it->end_of_box_run_p)
2971              it->pixel_width += thick;              it->pixel_width += thick;
2972          }          }
2973      
2974        /* If face has an overline, add the height of the overline        /* If face has an overline, add the height of the overline
2975           (1 pixel) and a 1 pixel margin to the character height.  */           (1 pixel) and a 1 pixel margin to the character height.  */
2976        if (face->overline_p)        if (face->overline_p)
2977          it->ascent += 2;          it->ascent += 2;
2978    
2979        take_vertical_position_into_account (it);        take_vertical_position_into_account (it);
2980      
2981        if (it->glyph_row)        if (it->glyph_row)
2982          x_append_composite_glyph (it);          x_append_composite_glyph (it);
2983      }      }
# Line 3024  x_estimate_mode_line_height (f, face_id) Line 3024  x_estimate_mode_line_height (f, face_id)
3024                height += 2 * face->box_line_width;                height += 2 * face->box_line_width;
3025            }            }
3026        }        }
3027      
3028    return height;    return height;
3029  }  }
3030    
# Line 3194  static int x_fill_glyph_string P_ ((stru Line 3194  static int x_fill_glyph_string P_ ((stru
3194  static void x_init_glyph_string P_ ((struct glyph_string *,  static void x_init_glyph_string P_ ((struct glyph_string *,
3195                                          XChar2b *, struct window *,                                          XChar2b *, struct window *,
3196                                          struct glyph_row *,                                          struct glyph_row *,
3197                                          enum glyph_row_area, int,                                          enum glyph_row_area, int,
3198                                          enum draw_glyphs_face));                                          enum draw_glyphs_face));
3199  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,  static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
3200                                enum glyph_row_area, int, int,                                enum glyph_row_area, int, int,
# Line 3240  static int x_fill_stretch_glyph_string P Line 3240  static int x_fill_stretch_glyph_string P
3240  static void x_check_font P_ ((struct frame *, XFontStruct *));  static void x_check_font P_ ((struct frame *, XFontStruct *));
3241  #endif  #endif
3242    
3243        
3244  /* Append the list of glyph strings with head H and tail T to the list  /* Append the list of glyph strings with head H and tail T to the list
3245     with head *HEAD and tail *TAIL.  Set *HEAD and *TAIL to the result.  */     with head *HEAD and tail *TAIL.  Set *HEAD and *TAIL to the result.  */
3246    
# Line 3349  x_set_cursor_gc (s) Line 3349  x_set_cursor_gc (s)
3349    
3350    
3351  /* Set up S->gc of glyph string S for drawing text in mouse face.  */  /* Set up S->gc of glyph string S for drawing text in mouse face.  */
3352      
3353  static void  static void
3354  x_set_mouse_face_gc (s)  x_set_mouse_face_gc (s)
3355       struct glyph_string *s;       struct glyph_string *s;
3356  {      {
3357    int face_id;    int face_id;
3358    struct face *face;    struct face *face;
3359    
# Line 3362  x_set_mouse_face_gc (s) Line 3362  x_set_mouse_face_gc (s)
3362    face = FACE_FROM_ID (s->f, face_id);    face = FACE_FROM_ID (s->f, face_id);
3363    if (face == NULL)    if (face == NULL)
3364      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);      face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
3365      
3366    if (s->first_glyph->type == CHAR_GLYPH)    if (s->first_glyph->type == CHAR_GLYPH)
3367      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);      face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch);
3368    else    else
# Line 3379  x_set_mouse_face_gc (s) Line 3379  x_set_mouse_face_gc (s)
3379           but font FONT.  */           but font FONT.  */
3380        XGCValues xgcv;        XGCValues xgcv;
3381        unsigned long mask;        unsigned long mask;
3382          
3383        xgcv.background = s->face->background;        xgcv.background = s->face->background;
3384        xgcv.foreground = s->face->foreground;        xgcv.foreground = s->face->foreground;
3385        IF_DEBUG (x_check_font (s->f, s->font));        IF_DEBUG (x_check_font (s->f, s->font));
3386        xgcv.font = s->font;        xgcv.font = s->font;
3387        mask = GCForeground | GCBackground | GCFont;        mask = GCForeground | GCBackground | GCFont;
3388          
3389        if (FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc)        if (FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc)
3390          XChangeGC (s->display, FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc,          XChangeGC (s->display, FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc,
3391                     mask, &xgcv);                     mask, &xgcv);
3392        else        else
3393          FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc          FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc
3394            = XCreateGC (s->display, s->window, mask, &xgcv);            = XCreateGC (s->display, s->window, mask, &xgcv);
3395          
3396        s->gc = FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc;        s->gc = FRAME_MAC_DISPLAY_INFO (s->f)->scratch_cursor_gc;
3397      }      }
3398    
# Line 3407  x_set_mouse_face_gc (s) Line 3407  x_set_mouse_face_gc (s)
3407  static INLINE void  static INLINE void
3408  x_set_mode_line_face_gc (s)  x_set_mode_line_face_gc (s)
3409       struct glyph_string *s;       struct glyph_string *s;
3410  {      {
3411    s->gc = s->face->gc;    s->gc = s->face->gc;
3412  }  }
3413    
# Line 3421  x_set_glyph_string_gc (s) Line 3421  x_set_glyph_string_gc (s)
3421       struct glyph_string *s;       struct glyph_string *s;
3422  {  {
3423    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);    PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
3424      
3425    if (s->hl == DRAW_NORMAL_TEXT)    if (s->hl == DRAW_NORMAL_TEXT)
3426      {      {
3427        s->gc = s->face->gc;        s->gc = s->face->gc;
# Line 3472  x_get_glyph_string_clip_rect (s, r) Line 3472  x_get_glyph_string_clip_rect (s, r)
3472      {      {
3473        /* Draw full-width.  X coordinates are relative to S->w->left.  */        /* Draw full-width.  X coordinates are relative to S->w->left.  */
3474        int canon_x = CANON_X_UNIT (s->f);        int canon_x = CANON_X_UNIT (s->f);
3475          
3476        r->left = WINDOW_LEFT_MARGIN (s->w) * canon_x;        r->left = WINDOW_LEFT_MARGIN (s->w) * canon_x;
3477        r_width = XFASTINT (s->w->width) * canon_x;        r_width = XFASTINT (s->w->width) * canon_x;
3478    
# Line 3482  x_get_glyph_string_clip_rect (s, r) Line 3482  x_get_glyph_string_clip_rect (s, r)
3482            if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))            if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (s->f))
3483              r->left -= width;              r->left -= width;
3484          }          }
3485          
3486        r->left += FRAME_INTERNAL_BORDER_WIDTH (s->f);        r->left += FRAME_INTERNAL_BORDER_WIDTH (s->f);
3487    
3488        /* Unless displaying a mode or menu bar line, which are always        /* Unless displaying a mode or menu bar line, which are always
# Line 3568  x_compute_glyph_string_overhangs (s) Line 3568  x_compute_glyph_string_overhangs (s)
3568  /* Compute overhangs and x-positions for glyph string S and its  /* Compute overhangs and x-positions for glyph string S and its
3569     predecessors, or successors.  X is the starting x-position for S.     predecessors, or successors.  X is the starting x-position for S.
3570     BACKWARD_P non-zero means process predecessors.  */     BACKWARD_P non-zero means process predecessors.  */
3571      
3572  static void  static void
3573  x_compute_overhangs_and_x (s, x, backward_p)  x_compute_overhangs_and_x (s, x, backward_p)
3574       struct glyph_string *s;       struct glyph_string *s;
# Line 3609  x_get_glyph_overhangs (glyph, f, left, r Line 3609  x_get_glyph_overhangs (glyph, f, left, r
3609       int *left, *right;       int *left, *right;
3610  {  {
3611    *left = *right = 0;    *left = *right = 0;
3612      
3613    if (glyph->type == CHAR_GLYPH)    if (glyph->type == CHAR_GLYPH)
3614      {      {
3615        XFontStruct *font;        XFontStruct *font;
# Line 3642  x_left_overwritten (s) Line 3642  x_left_overwritten (s)
3642       struct glyph_string *s;       struct glyph_string *s;
3643  {  {
3644    int k;    int k;
3645        
3646    if (s->left_overhang)    if (s->left_overhang)
3647      {      {
3648        int x = 0, i;        int x = 0, i;
# Line 3704  x_right_overwritten (s) Line 3704  x_right_overwritten (s)
3704        struct glyph *glyphs = s->row->glyphs[s->area];        struct glyph *glyphs = s->row->glyphs[s->area];
3705        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);        int first = (s->first_glyph - glyphs) + (s->cmp ? 1 : s->nchars);
3706        int end = s->row->used[s->area];        int end = s->row->used[s->area];
3707          
3708        for (i = first; i < end && s->right_overhang > x; ++i)        for (i = first; i < end && s->right_overhang > x; ++i)
3709          x += glyphs[i].pixel_width;          x += glyphs[i].pixel_width;
3710    
# Line 3927  x_frame_of_widget (widget) Line 3927  x_frame_of_widget (widget)
3927    struct x_display_info *dpyinfo;    struct x_display_info *dpyinfo;
3928    Lisp_Object tail;    Lisp_Object tail;
3929    struct frame *f;    struct frame *f;
3930      
3931    dpyinfo = x_display_info_for_display (XtDisplay (widget));    dpyinfo = x_display_info_for_display (XtDisplay (widget));
3932      
3933    /* Find the top-level shell of the widget.  Note that this function    /* Find the top-level shell of the widget.  Note that this function
3934       can be called when the widget is not yet realized, so XtWindow       can be called when the widget is not yet realized, so XtWindow
3935       (widget) == 0.  That's the reason we can't simply use       (widget) == 0.  That's the reason we can't simply use
# Line 4016  x_alloc_nearest_color (f, cmap, color) Line 4016  x_alloc_nearest_color (f, cmap, color)
4016                nearest_delta = delta;                nearest_delta = delta;
4017              }              }
4018          }          }
4019          
4020        color->red   = cells[nearest].red;        color->red   = cells[nearest].red;
4021        color->green = cells[nearest].green;        color->green = cells[nearest].green;
4022        color->blue  = cells[nearest].blue;        color->blue  = cells[nearest].blue;
# Line 4027  x_alloc_nearest_color (f, cmap, color) Line 4027  x_alloc_nearest_color (f, cmap, color)
4027    if (rc)    if (rc)
4028      register_color (color->pixel);      register_color (color->pixel);
4029  #endif /* DEBUG_X_COLORS */  #endif /* DEBUG_X_COLORS */
4030      
4031    return rc;    return rc;
4032  }  }
4033    
# Line 4124  mac_alloc_lighter_color (f, color, facto Line 4124  mac_alloc_lighter_color (f, color, facto
4124     DELTA lighter or darker than the relief's background which is found     DELTA lighter or darker than the relief's background which is found
4125     in S->f->output_data.x->relief_background.  If such a color cannot     in S->f->output_data.x->relief_background.  If such a color cannot
4126     be allocated, use DEFAULT_PIXEL, instead.  */     be allocated, use DEFAULT_PIXEL, instead.  */
4127      
4128  static void  static void
4129  x_setup_relief_color (f, relief, factor, delta, default_pixel)  x_setup_relief_color (f, relief, factor, delta, default_pixel)
4130       struct frame *f;       struct frame *f;
# Line 4150  x_setup_relief_color (f, relief, factor, Line 4150  x_setup_relief_color (f, relief, factor,
4150        relief->allocated_p = 1;        relief->allocated_p = 1;
4151        xgcv.foreground = relief->pixel = pixel;        xgcv.foreground = relief->pixel = pixel;
4152      }      }
4153      
4154    if (relief->gc == 0)    if (relief->gc == 0)
4155      {      {
4156  #if 0 /* MAC_TODO: stipple */  #if 0 /* MAC_TODO: stipple */
# Line 4178  x_setup_relief_colors (s) Line 4178  x_setup_relief_colors (s)
4178    else    else
4179      {      {
4180        XGCValues xgcv;        XGCValues xgcv;
4181          
4182        /* Get the background color of the face.  */        /* Get the background color of the face.  */
4183        XGetGCValues (s->display, s->gc, GCBackground, &xgcv);        XGetGCValues (s->display, s->gc, GCBackground, &xgcv);
4184        color = xgcv.background;        color = xgcv.background;
# Line 4213  x_draw_relief_rect (f, left_x, top_y, ri Line 4213  x_draw_relief_rect (f, left_x, top_y, ri
4213  {  {
4214    int i;    int i;
4215    GC gc;    GC gc;
4216      
4217    if (raised_p)    if (raised_p)
4218      gc = f->output_data.mac->white_relief.gc;      gc = f->output_data.mac->white_relief.gc;
4219    else    else
# Line 4239  x_draw_relief_rect (f, left_x, top_y, ri Line 4239  x_draw_relief_rect (f, left_x, top_y, ri
4239      gc = f->output_data.mac->white_relief.gc;      gc = f->output_data.mac->white_relief.gc;
4240    mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),    mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4241                            clip_rect);                            clip_rect);
4242      
4243    /* Bottom.  */    /* Bottom.  */
4244    for (i = 0; i < width; ++i)    for (i = 0; i < width; ++i)
4245      XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), gc,      XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), gc,
4246                 left_x + i * left_p, bottom_y - i,                 left_x + i * left_p, bottom_y - i,
4247                 right_x + 1 - i * right_p, bottom_y - i);                 right_x + 1 - i * right_p, bottom_y - i);
4248      
4249    /* Right.  */    /* Right.  */
4250    if (right_p)    if (right_p)
4251      for (i = 0; i < width; ++i)      for (i = 0; i < width; ++i)
# Line 4271  x_draw_box_rect (s, left_x, top_y, right Line 4271  x_draw_box_rect (s, left_x, top_y, right
4271       Rect *clip_rect;       Rect *clip_rect;
4272  {  {
4273    XGCValues xgcv;    XGCValues xgcv;
4274      
4275    xgcv.foreground = s->face->box_color;    xgcv.foreground = s->face->box_color;
4276    mac_set_clip_rectangle (s->display, s->window, clip_rect);    mac_set_clip_rectangle (s->display, s->window, clip_rect);
4277      
4278    /* Top.  */    /* Top.  */
4279    XFillRectangle (s->display, s->window, &xgcv,    XFillRectangle (s->display, s->window, &xgcv,
4280                    left_x, top_y, right_x - left_x, width);                    left_x, top_y, right_x - left_x, width);
# Line 4287  x_draw_box_rect (s, left_x, top_y, right Line 4287  x_draw_box_rect (s, left_x, top_y, right
4287    /* Bottom.  */    /* Bottom.  */
4288    XFillRectangle (s->display, s->window, &xgcv,    XFillRectangle (s->display, s->window, &xgcv,
4289                    left_x, bottom_y - width, right_x - left_x, width);                    left_x, bottom_y - width, right_x - left_x, width);
4290      
4291    /* Right.  */    /* Right.  */
4292    if (right_p)    if (right_p)
4293      XFillRectangle (s->display, s->window, &xgcv,      XFillRectangle (s->display, s->window, &xgcv,
# Line 4316  x_draw_glyph_string_box (s) Line 4316  x_draw_glyph_string_box (s)
4316        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))        if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (s->f))
4317          last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);          last_x += FRAME_SCROLL_BAR_WIDTH (s->f) * CANON_X_UNIT (s->f);
4318      }      }
4319      
4320    /* The glyph that may have a right box line.  */    /* The glyph that may have a right box line.  */
4321    last_glyph = (s->cmp || s->img    last_glyph = (s->cmp || s->img
4322                  ? s->first_glyph                  ? s->first_glyph
# Line 4339  x_draw_glyph_string_box (s) Line 4339  x_draw_glyph_string_box (s)
4339               || (s->hl == DRAW_MOUSE_FACE               || (s->hl == DRAW_MOUSE_FACE
4340                   && (s->next == NULL                   && (s->next == NULL
4341                       || s->next->hl != s->hl)));                       || s->next->hl != s->hl)));
4342      
4343    x_get_glyph_string_clip_rect (s, &clip_rect);    x_get_glyph_string_clip_rect (s, &clip_rect);
4344    
4345    if (s->face->box == FACE_SIMPLE_BOX)    if (s->face->box == FACE_SIMPLE_BOX)
# Line 4396  x_draw_image_foreground (s) Line 4396  x_draw_image_foreground (s)
4396            xgcv.clip_y_origin = y;            xgcv.clip_y_origin = y;
4397            xgcv.function = GXcopy;            xgcv.function = GXcopy;
4398            XChangeGC (s->display, s->gc, mask, &xgcv);            XChangeGC (s->display, s->gc, mask, &xgcv);
4399              
4400            x_get_glyph_string_clip_rect (s, &clip_rect);            x_get_glyph_string_clip_rect (s, &clip_rect);
4401            image_rect.x = x;            image_rect.x = x;
4402            image_rect.y = y;            image_rect.y = y;
# Line 4411  x_draw_image_foreground (s) Line 4411  x_draw_image_foreground (s)
4411          {          {
4412            mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,            mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
4413                         0, 0, s->img->width, s->img->height, x, y);                         0, 0, s->img->width, s->img->height, x, y);
4414              
4415            /* When the image has a mask, we can expect that at            /* When the image has a mask, we can expect that at
4416               least part of a mouse highlight or a block cursor will               least part of a mouse highlight or a block cursor will
4417               be visible.  If the image doesn't have a mask, make               be visible.  If the image doesn't have a mask, make
# Line 4445  x_draw_image_relief (s) Line 4445  x_draw_image_relief (s)
4445    Rect r;    Rect r;
4446    int x;    int x;
4447    int y = s->ybase - image_ascent (s->img, s->face);    int y = s->ybase - image_ascent (s->img, s->face);
4448    
4449    /* If first glyph of S has a left box line, start drawing it to the    /* If first glyph of S has a left box line, start drawing it to the
4450       right of that line.  */       right of that line.  */
4451    if (s->face->box != FACE_NO_BOX    if (s->face->box != FACE_NO_BOX
# Line 4453  x_draw_image_relief (s) Line 4453  x_draw_image_relief (s)
4453      x = s->x + abs (s->face->box_line_width);      x = s->x + abs (s->face->box_line_width);
4454    else    else
4455      x = s->x;      x = s->x;
4456      
4457    /* If there is a margin around the image, adjust x- and y-position    /* If there is a margin around the image, adjust x- and y-position
4458       by that margin.  */       by that margin.  */
4459    x += s->img->hmargin;    x += s->img->hmargin;
4460    y += s->img->vmargin;    y += s->img->vmargin;
4461      
4462    if (s->hl == DRAW_IMAGE_SUNKEN    if (s->hl == DRAW_IMAGE_SUNKEN
4463        || s->hl == DRAW_IMAGE_RAISED)        || s->hl == DRAW_IMAGE_RAISED)
4464      {      {
# Line 4470  x_draw_image_relief (s) Line 4470  x_draw_image_relief (s)
4470        thick = abs (s->img->relief);        thick = abs (s->img->relief);
4471        raised_p = s->img->relief > 0;        raised_p = s->img->relief > 0;
4472      }      }
4473      
4474    x0 = x - thick;    x0 = x - thick;
4475    y0 = y - thick;    y0 = y - thick;
4476    x1 = x + s->img->width + thick - 1;    x1 = x + s->img->width + thick - 1;
4477    y1 = y + s->img->height + thick - 1;    y1 = y + s->img->height + thick - 1;
4478      
4479    x_setup_relief_colors (s);    x_setup_relief_colors (s);
4480    x_get_glyph_string_clip_rect (s, &r);    x_get_glyph_string_clip_rect (s, &r);
4481    x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);    x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
# Line 4534  x_draw_image_foreground_1 (s, pixmap) Line 4534  x_draw_image_foreground_1 (s, pixmap)
4534          {          {
4535            mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,            mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
4536                                 0, 0, s->img->width, s->img->height, x, y);                                 0, 0, s->img->width, s->img->height, x, y);
4537              
4538            /* When the image has a mask, we can expect that at            /* When the image has a mask, we can expect that at
4539               least part of a mouse highlight or a block cursor will               least part of a mouse highlight or a block cursor will
4540               be visible.  If the image doesn't have a mask, make               be visible.  If the image doesn't have a mask, make
# Line 4579  x_draw_glyph_string_bg_rect (s, x, y, w, Line 4579  x_draw_glyph_string_bg_rect (s, x, y, w,
4579  }  }
4580    
4581    
4582  /* Draw image glyph string S.    /* Draw image glyph string S.
4583    
4584              s->y              s->y
4585     s->x      +-------------------------     s->x      +-------------------------
# Line 4622  x_draw_image_glyph_string (s) Line 4622  x_draw_image_glyph_string (s)
4622          x = s->x + box_line_hwidth;          x = s->x + box_line_hwidth;
4623        else        else
4624          x = s->x;          x = s->x;
4625          
4626        y = s->y + box_line_vwidth;        y = s->y + box_line_vwidth;
4627  #if 0 /* TODO: image mask */  #if 0 /* TODO: image mask */
4628        if (s->img->mask)        if (s->img->mask)
# Line 4637  x_draw_image_glyph_string (s) Line 4637  x_draw_image_glyph_string (s)
4637            pixmap = XCreatePixmap (s->display, s->window,            pixmap = XCreatePixmap (s->display, s->window,
4638                                    s->background_width,                                    s->background_width,
4639                                    s->height, depth);                                    s->height, depth);
4640              
4641            /* Don't clip in the following because we're working on the            /* Don't clip in the following because we're working on the
4642               pixmap.  */               pixmap.  */
4643            XSetClipMask (s->display, s->gc, None);            XSetClipMask (s->display, s->gc, None);
# Line 4665  x_draw_image_glyph_string (s) Line 4665  x_draw_image_glyph_string (s)
4665        else        else
4666  #endif  #endif
4667          x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);          x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
4668          
4669        s->background_filled_p = 1;        s->background_filled_p = 1;
4670      }      }
4671    
# Line 4725  x_draw_stretch_glyph_string (s) Line 4725  x_draw_stretch_glyph_string (s)
4725              }              }
4726            else            else
4727              gc = s->face->gc;              gc = s->face->gc;
4728      
4729            x_get_glyph_string_clip_rect (s, &r);            x_get_glyph_string_clip_rect (s, &r);
4730            mac_set_clip_rectangle (s->display, s->window, &r);            mac_set_clip_rectangle (s->display, s->window, &r);
4731    
# Line 4753  x_draw_stretch_glyph_string (s) Line 4753  x_draw_stretch_glyph_string (s)
4753    else if (!s->background_filled_p)    else if (!s->background_filled_p)
4754      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,      x_draw_glyph_string_bg_rect (s, s->x, s->y, s->background_width,
4755                                   s->height);                                   s->height);
4756      
4757    s->background_filled_p = 1;    s->background_filled_p = 1;
4758  }  }
4759    
# Line 4835  x_draw_glyph_string (s) Line 4835  x_draw_glyph_string (s)
4835          {          {
4836            unsigned long h = 1;            unsigned long h = 1;
4837            unsigned long dy = s->height - h;            unsigned long dy = s->height - h;
4838          
4839            if (s->face->underline_defaulted_p)            if (s->face->underline_defaulted_p)
4840              XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,              XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy,
4841                              s->width, h);                              s->width, h);
# Line 4868  x_draw_glyph_string (s) Line 4868  x_draw_glyph_string (s)
4868                XSetForeground (s->display, s->gc, xgcv.foreground);                XSetForeground (s->display, s->gc, xgcv.foreground);
4869              }              }
4870          }          }
4871      
4872        /* Draw strike-through.  */        /* Draw strike-through.  */
4873        if (s->face->strike_through_p)        if (s->face->strike_through_p)
4874          {          {
# Line 4888  x_draw_glyph_string (s) Line 4888  x_draw_glyph_string (s)
4888                XSetForeground (s->display, s->gc, xgcv.foreground);                XSetForeground (s->display, s->gc, xgcv.foreground);
4889              }              }
4890          }          }
4891      
4892        /* Draw relief.  */        /* Draw relief.  */
4893        if (!relief_drawn_p && s->face->box != FACE_NO_BOX)        if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
4894          x_draw_glyph_string_box (s);          x_draw_glyph_string_box (s);
# Line 4904  static int x_fill_composite_glyph_string Line 4904  static int x_fill_composite_glyph_string
4904    
4905    
4906  /* Fill glyph string S with composition components specified by S->cmp.  /* Fill glyph string S with composition components specified by S->cmp.
4907      
4908     FACES is an array of faces for all components of this composition.     FACES is an array of faces for all components of this composition.
4909     S->gidx is the index of the first component for S.     S->gidx is the index of the first component for S.
4910     OVERLAPS_P non-zero means S should draw the foreground only, and     OVERLAPS_P non-zero means S should draw the foreground only, and
# Line 4952  x_fill_composite_glyph_string (s, faces, Line 4952  x_fill_composite_glyph_string (s, faces,
4952    
4953    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
4954    s->ybase += s->first_glyph->voffset;    s->ybase += s->first_glyph->voffset;
4955      
4956    xassert (s->face && s->face->gc);    xassert (s->face && s->face->gc);
4957    
4958    /* This glyph string must always be drawn with 16-bit functions.  */    /* This glyph string must always be drawn with 16-bit functions.  */
# Line 4963  x_fill_composite_glyph_string (s, faces, Line 4963  x_fill_composite_glyph_string (s, faces,
4963    
4964    
4965  /* Fill glyph string S from a sequence of character glyphs.  /* Fill glyph string S from a sequence of character glyphs.
4966      
4967     FACE_ID is the face id of the string.  START is the index of the     FACE_ID is the face id of the string.  START is the index of the
4968     first glyph to consider, END is the index of the last + 1.     first glyph to consider, END is the index of the last + 1.
4969     OVERLAPS_P non-zero means S should draw the foreground only, and     OVERLAPS_P non-zero means S should draw the foreground only, and
# Line 5013  x_fill_glyph_string (s, face_id, start, Line 5013  x_fill_glyph_string (s, face_id, start,
5013    
5014    s->font = s->face->font;    s->font = s->face->font;
5015    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);    s->font_info = FONT_INFO_FROM_ID (s->f, s->face->font_info_id);
5016      
5017    /* If the specified font could not be loaded, use the frame's font,    /* If the specified font could not be loaded, use the frame's font,
5018       but record the fact that we couldn't load it in       but record the fact that we couldn't load it in
5019       S->font_not_found_p so that we can draw rectangles for the       S->font_not_found_p so that we can draw rectangles for the
# Line 5026  x_fill_glyph_string (s, face_id, start, Line 5026  x_fill_glyph_string (s, face_id, start,
5026    
5027    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
5028    s->ybase += voffset;    s->ybase += voffset;
5029      
5030    xassert (s->face && s->face->gc);    xassert (s->face && s->face->gc);
5031    return glyph - s->row->glyphs[s->area];    return glyph - s->row->glyphs[s->area];
5032  }  }
# Line 5044  x_fill_image_glyph_string (s) Line 5044  x_fill_image_glyph_string (s)
5044    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);    s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
5045    s->font = s->face->font;    s->font = s->face->font;
5046    s->width = s->first_glyph->pixel_width;    s->width = s->first_glyph->pixel_width;
5047      
5048    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
5049    s->ybase += s->first_glyph->voffset;    s->ybase += s->first_glyph->voffset;
5050  }  }
# Line 5067  x_fill_stretch_glyph_string (s, row, are Line 5067  x_fill_stretch_glyph_string (s, row, are
5067  {  {
5068    struct glyph *glyph, *last;    struct glyph *glyph, *last;
5069    int voffset, face_id;    int voffset, face_id;
5070      
5071    xassert (s->first_glyph->type == STRETCH_GLYPH);    xassert (s->first_glyph->type == STRETCH_GLYPH);
5072      
5073    glyph = s->row->glyphs[s->area] + start;    glyph = s->row->glyphs[s->area] + start;
5074    last = s->row->glyphs[s->area] + end;    last = s->row->glyphs[s->area] + end;
5075    face_id = glyph->face_id;    face_id = glyph->face_id;
# Line 5086  x_fill_stretch_glyph_string (s, row, are Line 5086  x_fill_stretch_glyph_string (s, row, are
5086          && glyph->face_id == face_id);          && glyph->face_id == face_id);
5087         ++glyph)         ++glyph)
5088      s->width += glyph->pixel_width;      s->width += glyph->pixel_width;
5089      
5090    /* Adjust base line for subscript/superscript text.  */    /* Adjust base line for subscript/superscript text.  */
5091    s->ybase += voffset;    s->ybase += voffset;
5092    
# Line 5102  x_fill_stretch_glyph_string (s, row, are Line 5102  x_fill_stretch_glyph_string (s, row, are
5102     and area within the row from which S is constructed.  START is the     and area within the row from which S is constructed.  START is the
5103     index of the first glyph structure covered by S.  HL is a     index of the first glyph structure covered by S.  HL is a
5104     face-override for drawing S.  */     face-override for drawing S.  */
5105      
5106  static void  static void
5107  x_init_glyph_string (s, char2b, w, row, area, start, hl)  x_init_glyph_string (s, char2b, w, row, area, start, hl)
5108       struct glyph_string *s;       struct glyph_string *s;
# Line 5129  x_init_glyph_string (s, char2b, w, row, Line 5129  x_init_glyph_string (s, char2b, w, row,
5129    /* Display the internal border below the tool-bar window.  */    /* Display the internal border below the tool-bar window.  */
5130    if (s->w == XWINDOW (s->f->tool_bar_window))    if (s->w == XWINDOW (s->f->tool_bar_window))
5131      s->y -= s->f->output_data.mac->internal_border_width;      s->y -= s->f->output_data.mac->internal_border_width;
5132      
5133    s->ybase = s->y + row->ascent;    s->ybase = s->y + row->ascent;
5134  }  }
5135    
# Line 5147  x_set_glyph_string_background_width (s, Line 5147  x_set_glyph_string_background_width (s,
5147    /* If the face of this glyph string has to be drawn to the end of    /* If the face of this glyph string has to be drawn to the end of
5148       the drawing area, set S->extends_to_end_of_line_p.  */       the drawing area, set S->extends_to_end_of_line_p.  */
5149    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);    struct face *default_face = FACE_FROM_ID (s->f, DEFAULT_FACE_ID);
5150      
5151    if (start == s->row->used[s->area]    if (start == s->row->used[s->area]
5152        && s->area == TEXT_AREA        && s->area == TEXT_AREA
5153        && ((s->hl == DRAW_NORMAL_TEXT        && ((s->hl == DRAW_NORMAL_TEXT
# Line 5159  x_set_glyph_string_background_width (s, Line 5159  x_set_glyph_string_background_width (s,
5159            || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)            || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
5160                && s->row->fill_line_p)))                && s->row->fill_line_p)))
5161      s->extends_to_end_of_line_p = 1;      s->extends_to_end_of_line_p = 1;
5162      
5163    /* If S extends its face to the end of the line, set its    /* If S extends its face to the end of the line, set its
5164       background_width to the distance to the right edge of the drawing       background_width to the distance to the right edge of the drawing
5165       area.  */       area.  */
# Line 5240  x_set_glyph_string_background_width (s, Line 5240  x_set_glyph_string_background_width (s,
5240                                            OVERLAPS_P);                     \                                            OVERLAPS_P);                     \
5241         }                                                                   \         }                                                                   \
5242       while (0)       while (0)
5243        
5244    
5245  /* Add a glyph string for a composite sequence to the list of strings  /* Add a glyph string for a composite sequence to the list of strings
5246     between HEAD and TAIL.  START is the index of the first glyph in     between HEAD and TAIL.  START is the index of the first glyph in
# Line 5296  x_set_glyph_string_background_width (s, Line 5296  x_set_glyph_string_background_width (s,
5296      ++START;                                                              \      ++START;                                                              \
5297      s = first_s;                                                          \      s = first_s;                                                          \
5298    } while (0)    } while (0)
5299        
5300    
5301  /* Build a list of glyph strings between HEAD and TAIL for the glyphs  /* Build a list of glyph strings between HEAD and TAIL for the glyphs
5302     of AREA of glyph row ROW on window W between indices START and END.     of AREA of glyph row ROW on window W between indices START and END.
# Line 5365  x_set_glyph_string_background_width (s, Line 5365  x_set_glyph_string_background_width (s,
5365     and clip to the physical height of ROW.     and clip to the physical height of ROW.
5366    
5367     Value is the x-position reached, relative to AREA of W.  */     Value is the x-position reached, relative to AREA of W.  */
5368        
5369  static int  static int
5370  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)  x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
5371       struct window *w;       struct window *w;
# Line 5446  x_draw_glyphs (w, x, row, area, start, e Line 5446  x_draw_glyphs (w, x, row, area, start, e
5446        /* Prepend glyph strings for glyphs in front of the first glyph        /* Prepend glyph strings for glyphs in front of the first glyph
5447           string that are overwritten because of the first glyph           string that are overwritten because of the first glyph
5448           string's left overhang.  The background of all strings           string's left overhang.  The background of all strings
5449           prepended must be drawn because the first glyph string           prepended must be drawn because the first glyph string
5450           draws over it.  */           draws over it.  */
5451        i = x_left_overwritten (head);        i = x_left_overwritten (head);
5452        if (i >= 0)        if (i >= 0)
# Line 5524  x_draw_glyphs (w, x, row, area, start, e Line 5524  x_draw_glyphs (w, x, row, area, start, e
5524      {      {
5525        int x0 = head ? head->x : x;        int x0 = head ? head->x : x;
5526        int x1 = tail ? tail->x + tail->background_width : x;        int x1 = tail ? tail->x + tail->background_width : x;
5527          
5528        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);        x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
5529        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);        x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
5530          
5531        if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)        if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)
5532          {          {
5533            int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);            int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
# Line 5563  x_fix_overlapping_area (w, row, area) Line 5563  x_fix_overlapping_area (w, row, area)
5563       enum glyph_row_area area;       enum glyph_row_area area;
5564  {  {
5565    int i, x;    int i, x;
5566      
5567    BLOCK_INPUT;    BLOCK_INPUT;
5568      
5569    if (area == LEFT_MARGIN_AREA)    if (area == LEFT_MARGIN_AREA)
5570      x = 0;      x = 0;
5571    else if (area == TEXT_AREA)    else if (area == TEXT_AREA)
# Line 5597  x_fix_overlapping_area (w, row, area) Line 5597  x_fix_overlapping_area (w, row, area)
5597            ++i;            ++i;
5598          }          }
5599      }      }
5600      
5601    UNBLOCK_INPUT;    UNBLOCK_INPUT;
5602  }  }
5603    
# Line 5617  x_write_glyphs (start, len) Line 5617  x_write_glyphs (start, len)
5617    
5618    xassert (updated_window && updated_row);    xassert (updated_window && updated_row);
5619    BLOCK_INPUT;    BLOCK_INPUT;
5620      
5621    /* Write glyphs.  */    /* Write glyphs.  */
5622    
5623    hpos = start - updated_row->glyphs[updated_area];    hpos = start - updated_row->glyphs[updated_area];
# Line 5627  x_write_glyphs (start, len) Line 5627  x_write_glyphs (start, len)
5627                       DRAW_NORMAL_TEXT, 0);                       DRAW_NORMAL_TEXT, 0);
5628    
5629    UNBLOCK_INPUT;    UNBLOCK_INPUT;
5630      
5631    /* Advance the output cursor.  */    /* Advance the output cursor.  */
5632    output_cursor.hpos += len;    output_cursor.hpos += len;
5633    output_cursor.x = x;    output_cursor.x = x;
# Line 5715  x_clear_end_of_line (to_x) Line 5715  x_clear_end_of_line (to_x)
5715    struct window *w = updated_window;    struct window *w = updated_window;
5716    int max_x, min_y, max_y;    int max_x, min_y, max_y;
5717    int from_x, from_y, to_y;    int from_x, from_y, to_y;
5718      
5719    xassert (updated_window && updated_row);    xassert (updated_window && updated_row);
5720    f = XFRAME (w->frame);    f = XFRAME (w->frame);
5721      
5722    if (updated_row->full_width_p)    if (updated_row->full_width_p)
5723      {      {
5724        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);        max_x = XFASTINT (w->width) * CANON_X_UNIT (f);
# Line 5740  x_clear_end_of_line (to_x) Line 5740  x_clear_end_of_line (to_x)
5740      to_x = min (to_x, max_x);      to_x = min (to_x, max_x);
5741    
5742    to_y = min (max_y, output_cursor.y + updated_row->height);    to_y = min (max_y, output_cursor.y + updated_row->height);
5743      
5744    /* Notice if the cursor will be cleared by this operation.  */    /* Notice if the cursor will be cleared by this operation.  */
5745    if (!updated_row->full_width_p)    if (!updated_row->full_width_p)
5746      notice_overwritten_cursor (w, updated_area,      notice_overwritten_cursor (w, updated_area,
# Line 5761  x_clear_end_of_line (to_x) Line 5761  x_clear_end_of_line (to_x)
5761        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);        from_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, from_x);
5762        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);        to_x = WINDOW_AREA_TO_FRAME_PIXEL_X (w, updated_area, to_x);
5763      }      }
5764      
5765    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);    min_y = WINDOW_DISPLAY_HEADER_LINE_HEIGHT (w);
5766    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));    from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y));
5767    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);    to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
5768      
5769    /* Prevent inadvertently clearing to end of the X window.  */    /* Prevent inadvertently clearing to end of the X window.  */
5770    if (to_x > from_x && to_y > from_y)    if (to_x > from_x && to_y > from_y)
5771      {      {
# Line 5836  timeval_subtract (result, x, y) Line 5836  timeval_subtract (result, x, y)
5836        y.tv_usec -= 1000000 * nsec;        y.tv_usec -= 1000000 * nsec;
5837        y.tv_sec += nsec;        y.tv_sec += nsec;
5838      }      }
5839      
5840    if (x.tv_usec - y.tv_usec > 1000000)    if (x.tv_usec - y.tv_usec > 1000000)
5841      {      {
5842        int nsec = (y.tv_usec - x.tv_usec) / 1000000;        int nsec = (y.tv_usec - x.tv_usec) / 1000000;
# Line 5888  XTflash (f) Line 5888  XTflash (f)
5888          select (0, NULL, NULL, NULL, &timeout);          select (0, NULL, NULL, NULL, &timeout);
5889        }        }
5890    }    }
5891      
5892    FlashMenuBar (0);    FlashMenuBar (0);
5893    
5894    UNBLOCK_INPUT;    UNBLOCK_INPUT;
# Line 5903  void Line 5903  void
5903  XTring_bell ()  XTring_bell ()
5904  {  {
5905    struct frame *f = SELECTED_FRAME ();    struct frame *f = SELECTED_FRAME ();
5906      
5907  #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)  #if defined (HAVE_TIMEVAL) && defined (HAVE_SELECT)
5908    if (visible_bell)    if (visible_bell)
5909      XTflash (f);      XTflash (f);
# Line 5989  x_scroll_run (w, run) Line 5989  x_scroll_run (w, run)
5989      }      }
5990    
5991    BLOCK_INPUT;    BLOCK_INPUT;
5992      
5993    /* Cursor off.  Will be switched on again in x_update_window_end.  */    /* Cursor off.  Will be switched on again in x_update_window_end.  */
5994    updated_window = w;    updated_window = w;
5995    x_clear_cursor (w);    x_clear_cursor (w);
# Line 5999  x_scroll_run (w, run) Line 5999  x_scroll_run (w, run)
5999                   x, from_y,                   x, from_y,
6000                   width, height,                   width, height,
6001                   x, to_y);                   x, to_y);
6002      
6003    UNBLOCK_INPUT;    UNBLOCK_INPUT;
6004  }  }
6005    
# Line 6008  x_scroll_run (w, run) Line 6008  x_scroll_run (w, run)
6008  /***********************************************************************  /***********************************************************************
6009                             Exposure Events                             Exposure Events
6010   ***********************************************************************/   ***********************************************************************/
6011                                                                            
6012  /* Redisplay an exposed area of frame F.  X and Y are the upper-left  /* Redisplay an exposed area of frame F.  X and Y are the upper-left
6013     corner of the exposed rectangle.  W and H are width and height of     corner of the exposed rectangle.  W and H are width and height of
6014     the exposed area.  All are pixel values.  W or H zero means redraw     the exposed area.  All are pixel values.  W or H zero means redraw
# Line 6167  expose_area (w, row, r, area) Line 6167  expose_area (w, row, r, area)
6167            x += first->pixel_width;            x += first->pixel_width;
6168            ++first;            ++first;
6169          }          }
6170      
6171        /* Find the last one.  */        /* Find the last one.  */
6172        last = first;        last = first;
6173        first_x = x;        first_x = x;
# Line 6199  expose_line (w, row, r) Line 6199  expose_line (w, row, r)
6199       Rect *r;       Rect *r;
6200  {  {
6201    xassert (row->enabled_p);    xassert (row->enabled_p);
6202      
6203    if (row->mode_line_p || w->pseudo_window_p)    if (row->mode_line_p || w->pseudo_window_p)
6204      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],      x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
6205                     DRAW_NORMAL_TEXT, 0);                     DRAW_NORMAL_TEXT, 0);
# Line 6257  expose_overlaps (w, first_overlapping_ro Line 6257  expose_overlaps (w, first_overlapping_ro
6257       struct glyph_row *last_overlapping_row;       struct glyph_row *last_overlapping_row;
6258  {  {
6259    struct glyph_row *row;    struct glyph_row *row;
6260      
6261    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)    for (row = first_overlapping_row; row <= last_overlapping_row; ++row)
6262      if (row->overlapping_p)      if (row->overlapping_p)
6263        {        {
6264          xassert (row->enabled_p && !row->mode_line_p);          xassert (row->enabled_p && !row->mode_line_p);
6265              
6266          if (row->used[LEFT_MARGIN_AREA])          if (row->used[LEFT_MARGIN_AREA])
6267            x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);            x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA);
6268      
6269          if (row->used[TEXT_AREA])          if (row->used[TEXT_AREA])
6270            x_fix_overlapping_area (w, row, TEXT_AREA);            x_fix_overlapping_area (w, row, TEXT_AREA);
6271      
6272          if (row->used[RIGHT_MARGIN_AREA])          if (row->used[RIGHT_MARGIN_AREA])
6273            x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);            x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
6274        }        }
# Line 6317  expose_window (w, fr) Line 6317  expose_window (w, fr)
6317        struct glyph_row *row;        struct glyph_row *row;
6318        int cursor_cleared_p;        int cursor_cleared_p;
6319        struct glyph_row *first_overlapping_row, *last_overlapping_row;        struct glyph_row *first_overlapping_row, *last_overlapping_row;
6320      
6321        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",        TRACE ((stderr, "expose_window (%d, %d, %d, %d)\n",
6322                r.left, r.top, r.right, r.bottom));                r.left, r.top, r.right, r.bottom));
6323    
# Line 6357  expose_window (w, fr) Line 6357  expose_window (w, fr)
6357                      first_overlapping_row = row;                      first_overlapping_row = row;
6358                    last_overlapping_row = row;                    last_overlapping_row = row;
6359                  }                  }
6360                  
6361                if (expose_line (w, row, &r))                if (expose_line (w, row, &r))
6362                  mouse_face_overwritten_p = 1;                  mouse_face_overwritten_p = 1;
6363              }              }
6364                  
6365            if (y1 >= yb)            if (y1 >= yb)
6366              break;              break;
6367          }          }
# Line 6381  expose_window (w, fr) Line 6381  expose_window (w, fr)
6381            /* Fix the display of overlapping rows.  */            /* Fix the display of overlapping rows.  */
6382            if (first_overlapping_row)            if (first_overlapping_row)
6383              expose_overlaps (w, first_overlapping_row, last_overlapping_row);              expose_overlaps (w, first_overlapping_row, last_overlapping_row);
6384              
6385            /* Draw border between windows.  */            /* Draw border between windows.  */
6386            x_draw_vertical_border (w);            x_draw_vertical_border (w);
6387          
6388            /* Turn the cursor on again.  */            /* Turn the cursor on again.  */
6389            if (cursor_cleared_p)            if (cursor_cleared_p)
6390              x_update_window_cursor (w, 1);              x_update_window_cursor (w, 1);
# Line 6410  x_intersect_rectangles (r1, r2, result) Line 6410  x_intersect_rectangles (r1, r2, result)
6410    Rect *left, *right;    Rect *left, *right;
6411    Rect *upper, *lower;    Rect *upper, *lower;
6412    int intersection_p = 0;    int intersection_p = 0;
6413      
6414    /* Rerrange so that R1 is the left-most rectangle.  */    /* Rerrange so that R1 is the left-most rectangle.  */
6415    if (r1->left < r2->left)    if (r1->left < r2->left)
6416      left = r1, right = r2;      left = r1, right = r2;
# Line 6422  x_intersect_rectangles (r1, r2, result) Line 6422  x_intersect_rectangles (r1, r2, result)
6422    if (right->left <= left->right)    if (right->left <= left->right)
6423      {      {
6424        result->left = right->left;        result->left = right->left;
6425          
6426        /* The right end of the intersection is the minimum of the        /* The right end of the intersection is the minimum of the
6427           the right ends of left and right.  */           the right ends of left and right.  */
6428        result->right = min (left->right, right->right);        result->right = min (left->right, right->right);
# Line 6438  x_intersect_rectangles (r1, r2, result) Line 6438  x_intersect_rectangles (r1, r2, result)
6438        if (lower->top <= upper->bottom)        if (lower->top <= upper->bottom)
6439          {          {
6440            result->top = lower->top;            result->top = lower->top;
6441              
6442            /* The lower end of the intersection is the minimum of the lower            /* The lower end of the intersection is the minimum of the lower
6443               ends of upper and lower.  */               ends of upper and lower.  */
6444            result->bottom = min (lower->bottom, upper->bottom);            result->bottom = min (lower->bottom, upper->bottom);
# Line 6989  x_y_to_hpos_vpos (w, x, y, hpos, vpos, a Line 6989  x_y_to_hpos_vpos (w, x, y, hpos, vpos, a
6989            else if (!buffer_only_p || BUFFERP (glyph->object))            else if (!buffer_only_p || BUFFERP (glyph->object))
6990              break;              break;
6991          }          }
6992          
6993        x0 += glyph->pixel_width;        x0 += glyph->pixel_width;
6994        ++glyph;        ++glyph;
6995      }      }
# Line 7052  note_mode_line_highlight (w, x, mode_lin Line 7052  note_mode_line_highlight (w, x, mode_lin
7052        struct glyph *glyph, *end;        struct glyph *glyph, *end;
7053        Lisp_Object help, map;        Lisp_Object help, map;
7054        int x0;        int x0;
7055          
7056        /* Find the glyph under X.  */        /* Find the glyph under X.  */
7057        glyph = row->glyphs[TEXT_AREA];        glyph = row->glyphs[TEXT_AREA];
7058        end = glyph + row->used[TEXT_AREA];        end = glyph + row->used[TEXT_AREA];
7059        x0 = - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f)        x0 = - (FRAME_LEFT_SCROLL_BAR_WIDTH (f) * CANON_X_UNIT (f)
7060                + FRAME_X_LEFT_FRINGE_WIDTH (f));                + FRAME_X_LEFT_FRINGE_WIDTH (f));
7061          
7062        while (glyph < end        while (glyph < end
7063               && x >= x0 + glyph->pixel_width)               && x >= x0 + glyph->pixel_width)
7064          {          {
# Line 7418  note_mouse_highlight (f, x, y) Line 7418  note_mouse_highlight (f, x, y)
7418                   the text ``under'' it might have.  */                   the text ``under'' it might have.  */
7419                struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);                struct glyph_row *r = MATRIX_ROW (w->current_matrix, vpos);
7420                int start = MATRIX_ROW_START_CHARPOS (r);                int start = MATRIX_ROW_START_CHARPOS (r);
7421                  
7422                pos = string_buffer_position (w, object, start);                pos = string_buffer_position (w, object, start);
7423                if (pos > 0)                if (pos > 0)
7424                  mouse_face = get_char_property_and_overlay (make_number (pos),                  mouse_face = get_char_property_and_overlay (make_number (pos),
# Line 7442  note_mouse_highlight (f, x, y) Line 7442  note_mouse_highlight (f, x, y)
7442                                        &dpyinfo->mouse_face_beg_x,                                        &dpyinfo->mouse_face_beg_x,
7443                                        &dpyinfo->mouse_face_beg_y,                                        &dpyinfo->mouse_face_beg_y,
7444                                        object);                                        object);
7445                          
7446                    dpyinfo->mouse_face_past_end                    dpyinfo->mouse_face_past_end
7447                      = !fast_find_position (w, XFASTINT (after),                      = !fast_find_position (w, XFASTINT (after),
7448                                             &dpyinfo->mouse_face_end_col,                                             &dpyinfo->mouse_face_end_col,
# Line 7474  note_mouse_highlight (f, x, y) Line 7474  note_mouse_highlight (f, x, y)
7474          for (i = noverlays - 1; i >= 0 && NILP (help); --i)          for (i = noverlays - 1; i >= 0 && NILP (help); --i)
7475            {            {
7476              overlay = overlay_vec[i];              overlay = overlay_vec[i];
7477              help = Foverlay_get (overlay, Qhelp_echo);              help = Foverlay_get (overlay, Qhelp_echo);
7478            }            }
7479    
7480          if (!NILP (help))          if (!NILP (help))
# Line 7521  note_mouse_highlight (f, x, y) Line 7521  note_mouse_highlight (f, x, y)
7521                       && charpos < ZV)                       && charpos < ZV)
7522                help = Fget_text_property (make_number (charpos), Qhelp_echo,                help = Fget_text_property (make_number (charpos), Qhelp_echo,
7523                                           object);                                           object);
7524                
7525              if (!NILP (help))              if (!NILP (help))
7526                {                {
7527                  help_echo = help;                  help_echo = help;
# Line 7608  x_tool_bar_item (f, x, y, glyph, hpos, v Line 7608  x_tool_bar_item (f, x, y, glyph, hpos, v
7608            || *hpos < dpyinfo->mouse_face_end_col            || *hpos < dpyinfo->mouse_face_end_col
7609            || dpyinfo->mouse_face_past_end))            || dpyinfo->mouse_face_past_end))
7610      return 0;      return 0;
7611      
7612    return 1;    return 1;
7613  }  }
7614    
# Line 7629  x_handle_tool_bar_click (f, button_event Line 7629  x_handle_tool_bar_click (f, button_event
7629    Lisp_Object enabled_p;    Lisp_Object enabled_p;
7630    int x = button_event->where.h;    int x = button_event->where.h;
7631    int y = button_event->where.v;    int y = button_event->where.v;
7632      
7633    /* If not on the highlighted tool-bar item, return.  */    /* If not on the highlighted tool-bar item, return.  */
7634    frame_to_window_pixel_xy (w, &x, &y);    frame_to_window_pixel_xy (w, &x, &y);
7635    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)    if (x_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0)
# Line 7639  x_handle_tool_bar_click (f, button_event Line 7639  x_handle_tool_bar_click (f, button_event
7639    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
7640    if (NILP (enabled_p))    if (NILP (enabled_p))
7641      return;      return;
7642      
7643    if (button_event->what == mouseDown)    if (button_event->what == mouseDown)
7644      {      {
7645        /* Show item in pressed state.  */        /* Show item in pressed state.  */
# Line 7716  note_tool_bar_highlight (f, x, y) Line 7716  note_tool_bar_highlight (f, x, y)
7716      goto set_help_echo;      goto set_help_echo;
7717    
7718    clear_mouse_face (dpyinfo);    clear_mouse_face (dpyinfo);
7719      
7720    /* Mouse is down, but on different tool-bar item?  */    /* Mouse is down, but on different tool-bar item?  */
7721    mouse_down_p = (dpyinfo->grabbed    mouse_down_p = (dpyinfo->grabbed
7722                    && f == last_mouse_frame                    && f == last_mouse_frame
# Line 7727  note_tool_bar_highlight (f, x, y) Line 7727  note_tool_bar_highlight (f, x, y)
7727    
7728    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;    dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
7729    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;    draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
7730      
7731    /* If tool-bar item is not enabled, don't highlight it.  */    /* If tool-bar item is not enabled, don't highlight it.  */
7732    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);    enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P);
7733    if (!NILP (enabled_p))    if (!NILP (enabled_p))
# Line 7737  note_tool_bar_highlight (f, x, y) Line 7737  note_tool_bar_highlight (f, x, y)
7737        row = MATRIX_ROW (w->current_matrix, vpos);        row = MATRIX_ROW (w->current_matrix, vpos);
7738        for (i = x = 0; i < hpos; ++i)        for (i = x = 0; i < hpos; ++i)
7739          x += row->glyphs[TEXT_AREA][i].pixel_width;          x += row->glyphs[TEXT_AREA][i].pixel_width;
7740          
7741        /* Record this as the current active region.  */        /* Record this as the current active region.  */
7742        dpyinfo->mouse_face_beg_col = hpos;        dpyinfo->mouse_face_beg_col = hpos;
7743        dpyinfo->mouse_face_beg_row = vpos;        dpyinfo->mouse_face_beg_row = vpos;
7744        dpyinfo->mouse_face_beg_x = x;        dpyinfo->mouse_face_beg_x = x;
7745        dpyinfo->mouse_face_beg_y = row->y;        dpyinfo->mouse_face_beg_y = row->y;
7746        dpyinfo->mouse_face_past_end = 0;        dpyinfo->mouse_face_past_end = 0;
7747          
7748        dpyinfo->mouse_face_end_col = hpos + 1;        dpyinfo->mouse_face_end_col = hpos + 1;
7749        dpyinfo->mouse_face_end_row = vpos;        dpyinfo->mouse_face_end_row = vpos;
7750        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;        dpyinfo->mouse_face_end_x = x + glyph->pixel_width;
7751        dpyinfo->mouse_face_end_y = row->y;        dpyinfo->mouse_face_end_y = row->y;
7752        dpyinfo->mouse_face_window = window;        dpyinfo->mouse_face_window = window;
7753        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;        dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
7754          
7755        /* Display it as active.  */        /* Display it as active.  */
7756        show_mouse_face (dpyinfo, draw);        show_mouse_face (dpyinfo, draw);
7757        dpyinfo->mouse_face_image_state = draw;        dpyinfo->mouse_face_image_state = draw;
7758      }      }
7759          
7760   set_help_echo:   set_help_echo:
7761      
7762    /* Set help_echo to a help string.to display for this tool-bar item.    /* Set help_echo to a help string.to display for this tool-bar item.
7763       XTread_socket does the rest.  */       XTread_socket does the rest.  */
7764    help_echo_object = help_echo_window = Qnil;    help_echo_object = help_echo_window = Qnil;
# Line 7780  note_tool_bar_highlight (f, x, y) Line 7780  note_tool_bar_highlight (f, x, y)
7780  #if 0 /* This is a version of fast_find_position that's more correct  #if 0 /* This is a version of fast_find_position that's more correct
7781           in the presence of hscrolling, for example.  I didn't install           in the presence of hscrolling, for example.  I didn't install
7782           it right away because the problem fixed is minor, it failed           it right away because the problem fixed is minor, it failed
7783           in 20.x as well, and I think it's too risky to install           in 20.x as well, and I think it's too risky to install
7784           so near the release of 21.1.  2001-09-25 gerd.  */           so near the release of 21.1.  2001-09-25 gerd.  */
7785    
7786  static int  static int
# Line 7813  fast_find_position (w, charpos, hpos, vp Line 7813  fast_find_position (w, charpos, hpos, vp
7813    *x = row->x;    *x = row->x;
7814    *y = row->y;    *y = row->y;
7815    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);    *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
7816      
7817    glyph = row->glyphs[TEXT_AREA];    glyph = row->glyphs[TEXT_AREA];
7818    end = glyph + row->used[TEXT_AREA];    end = glyph + row->used[TEXT_AREA];
7819      
7820    /* Skip over glyphs not having an object at the start of the row.    /* Skip over glyphs not having an object at the start of the row.
7821       These are special glyphs like truncation marks on terminal       These are special glyphs like truncation marks on terminal
7822       frames.  */       frames.  */
# Line 8018  fast_find_string_pos (w, pos, object, hp Line 8018  fast_find_string_pos (w, pos, object, hp
8018            *x += best_glyph->pixel_width;            *x += best_glyph->pixel_width;
8019            ++*hpos;            ++*hpos;
8020          }          }
8021          
8022        *y = best_row->y;        *y = best_row->y;
8023        *vpos = best_row - w->current_matrix->rows;        *vpos = best_row - w->current_matrix->rows;
8024      }      }
# Line 8037  show_mouse_face (dpyinfo, draw) Line 8037  show_mouse_face (dpyinfo, draw)
8037  {  {
8038    struct window *w = XWINDOW (dpyinfo->mouse_face_window);    struct window *w = XWINDOW (dpyinfo->mouse_face_window);
8039    struct frame *f = XFRAME (WINDOW_FRAME (w));    struct frame *f = XFRAME (WINDOW_FRAME (w));
8040      
8041    if (/* If window is in the process of being destroyed, don't bother    if (/* If window is in the process of being destroyed, don't bother
8042           to do anything.  */           to do anything.  */
8043        w->current_matrix != NULL        w->current_matrix != NULL
# Line 8052  show_mouse_face (dpyinfo, draw) Line 8052  show_mouse_face (dpyinfo, draw)
8052    
8053        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);        first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
8054        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);        last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
8055          
8056        for (row = first; row <= last && row->enabled_p; ++row)        for (row = first; row <= last && row->enabled_p; ++row)
8057          {          {
8058            int start_hpos, end_hpos, start_x;            int start_hpos, end_hpos, start_x;
# Line 8076  show_mouse_face (dpyinfo, draw) Line 8076  show_mouse_face (dpyinfo, draw)
8076    
8077            if (end_hpos > start_hpos)            if (end_hpos > start_hpos)
8078              {              {
8079                x_draw_glyphs (w, start_x, row, TEXT_AREA,                x_draw_glyphs (w, start_x, row, TEXT_AREA,
8080                               start_hpos, end_hpos, draw, 0);                               start_hpos, end_hpos, draw, 0);
8081    
8082                row->mouse_face_p                row->mouse_face_p
# Line 8307  XTmouse_position (fp, insist, bar_window Line 8307  XTmouse_position (fp, insist, bar_window
8307    Lisp_Object frame, tail;    Lisp_Object frame, tail;
8308    
8309    if (is_emacs_window(wp))    if (is_emacs_window(wp))
8310      f = ((mac_output *) GetWRefCon (wp))->mFP;              f = ((mac_output *) GetWRefCon (wp))->mFP;
8311    
8312    BLOCK_INPUT;    BLOCK_INPUT;
8313    
# Line 8339  XTmouse_position (fp, insist, bar_window Line 8339  XTmouse_position (fp, insist, bar_window
8339        XSETINT (*y, mouse_pos.v);        XSETINT (*y, mouse_pos.v);
8340        *time = last_mouse_movement_time;        *time = last_mouse_movement_time;
8341      }      }
8342      
8343    UNBLOCK_INPUT;    UNBLOCK_INPUT;
8344  }  }
8345    
# Line 8347  XTmouse_position (fp, insist, bar_window Line 8347  XTmouse_position (fp, insist, bar_window
8347  /************************************************************************  /************************************************************************
8348                           Scroll bars, general                           Scroll bars, general
8349   ************************************************************************/   ************************************************************************/
8350                                                                            
8351  /* Create a scroll bar and return the scroll bar vector for it.  W is  /* Create a scroll bar and return the scroll bar vector for it.  W is
8352     the Emacs window on which to create the scroll bar. TOP, LEFT,     the Emacs window on which to create the scroll bar. TOP, LEFT,
8353     WIDTH and HEIGHT are the pixel coordinates and dimensions of the     WIDTH and HEIGHT are the pixel coordinates and dimensions of the
# Line 8370  x_scroll_bar_create (w, top, left, width Line 8370  x_scroll_bar_create (w, top, left, width
8370    r.top = disp_top;    r.top = disp_top;
8371    r.right = left + width;    r.right = left + width;
8372    r.bottom = disp_top + disp_height;    r.bottom = disp_top + disp_height;
8373      
8374  #ifdef TARGET_API_MAC_CARBON  #ifdef TARGET_API_MAC_CARBON
8375    ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,    ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,
8376                     kControlScrollBarProc, 0L);                     kControlScrollBarProc, 0L);
# Line 8403  x_scroll_bar_create (w, top, left, width Line 8403  x_scroll_bar_create (w, top, left, width
8403    
8404    
8405  /* Draw BAR's handle in the proper position.  /* Draw BAR's handle in the proper position.
8406      
8407     If the handle is already drawn from START to END, don't bother     If the handle is already drawn from START to END, don't bother
8408     redrawing it, unless REBUILD is non-zero; in that case, always     redrawing it, unless REBUILD is non-zero; in that case, always
8409     redraw it.  (REBUILD is handy for drawing the handle after expose     redraw it.  (REBUILD is handy for drawing the handle after expose
# Line 8442  x_scroll_bar_set_handle (bar, start, end Line 8442  x_scroll_bar_set_handle (bar, start, end
8442    else if (start > top_range)    else if (start > top_range)
8443      start = top_range;      start = top_range;
8444    end = start + length;    end = start + length;
8445      
8446    if (end < start)    if (end < start)
8447      end = start;      end = start;
8448    else if (end > top_range && ! dragging)    else if (end > top_range && ! dragging)
# Line 8536  XTset_vertical_scroll_bar (w, portion, w Line 8536  XTset_vertical_scroll_bar (w, portion, w
8536    
8537    /* Compute the left edge of the scroll bar.  */    /* Compute the left edge of the scroll bar.  */
8538    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))    if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
8539      sb_left = left + width - sb_width - (width - sb_width) / 2;      sb_left = left + width - sb_width - (width - sb_width) / 2;
8540    else    else
8541      sb_left = left + (width - sb_width) / 2;      sb_left = left + (width - sb_width) / 2;
8542      
8543    /* Adjustments according to Inside Macintosh to make it look nice */    /* Adjustments according to Inside Macintosh to make it look nice */
8544    disp_top = top;    disp_top = top;
8545    disp_height = height;    disp_height = height;
# Line 8553  XTset_vertical_scroll_bar (w, portion, w Line 8553  XTset_vertical_scroll_bar (w, portion, w
8553        disp_top++;        disp_top++;
8554        disp_height--;        disp_height--;
8555      }      }
8556        
8557    if (sb_left + sb_width == PIXEL_WIDTH (f))    if (sb_left + sb_width == PIXEL_WIDTH (f))
8558      sb_left++;      sb_left++;
8559      
8560    /* Does the scroll bar exist yet?  */    /* Does the scroll bar exist yet?  */
8561    if (NILP (w->vertical_scroll_bar))    if (NILP (w->vertical_scroll_bar))
8562      {      {
# Line 8572  XTset_vertical_scroll_bar (w, portion, w Line 8572  XTset_vertical_scroll_bar (w, portion, w
8572      {      {
8573        /* It may just need to be moved and resized.  */        /* It may just need to be moved and resized.  */
8574        ControlHandle ch;        ControlHandle ch;
8575                
8576        bar = XSCROLL_BAR (w->vertical_scroll_bar);        bar = XSCROLL_BAR (w->vertical_scroll_bar);
8577        ch = SCROLL_BAR_CONTROL_HANDLE (bar);        ch = SCROLL_BAR_CONTROL_HANDLE (bar);
8578    
# Line 8605  XTset_vertical_scroll_bar (w, portion, w Line 8605  XTset_vertical_scroll_bar (w, portion, w
8605            SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,            SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
8606                         disp_height);                         disp_height);
8607            ShowControl (ch);            ShowControl (ch);
8608          
8609            /* Remember new settings.  */            /* Remember new settings.  */
8610            XSETINT (bar->left, sb_left);            XSETINT (bar->left, sb_left);
8611            XSETINT (bar->top, top);            XSETINT (bar->top, top);
# Line 8749  activate_scroll_bars (frame) Line 8749  activate_scroll_bars (frame)
8749  {  {
8750    Lisp_Object bar;    Lisp_Object bar;
8751    ControlHandle ch;    ControlHandle ch;
8752      
8753    bar = FRAME_SCROLL_BARS (frame);    bar = FRAME_SCROLL_BARS (frame);
8754    while (! NILP (bar))    while (! NILP (bar))
8755      {      {
# Line 8773  deactivate_scroll_bars (frame) Line 8773  deactivate_scroll_bars (frame)
8773  {  {
8774    Lisp_Object bar;    Lisp_Object bar;
8775    ControlHandle ch;    ControlHandle ch;
8776      
8777    bar = FRAME_SCROLL_BARS (frame);    bar = FRAME_SCROLL_BARS (frame);
8778    while (! NILP (bar))    while (! NILP (bar))
8779      {      {
# Line 8782  deactivate_scroll_bars (frame) Line 8782  deactivate_scroll_bars (frame)
8782        DeactivateControl (ch);        DeactivateControl (ch);
8783  #else  #else
8784        SetControlMaximum (ch, XINT (-1));        SetControlMaximum (ch, XINT (-1));
8785  #endif        #endif
8786        bar = XSCROLL_BAR (bar)->next;        bar = XSCROLL_BAR (bar)->next;
8787      }      }
8788  }  }
# Line 8808  x_scroll_bar_handle_click (bar, part_cod Line 8808  x_scroll_bar_handle_click (bar, part_cod
8808    bufp->arg = Qnil;    bufp->arg = Qnil;
8809    
8810    bar->dragging = Qnil;    bar->dragging = Qnil;
8811    
8812    switch (part_code)    switch (part_code)
8813      {      {
8814      case kControlUpButtonPart:      case kControlUpButtonPart:
# Line 9034  x_draw_hollow_cursor (w, row) Line 9034  x_draw_hollow_cursor (w, row)
9034    if (cursor_glyph->type == STRETCH_GLYPH    if (cursor_glyph->type == STRETCH_GLYPH
9035        && !x_stretch_cursor_p)        && !x_stretch_cursor_p)
9036      wd = min (CANON_X_UNIT (f), wd);      wd = min (CANON_X_UNIT (f), wd);
9037      
9038    /* The foreground of cursor_gc is typically the same as the normal    /* The foreground of cursor_gc is typically the same as the normal
9039       background color, which can cause the cursor box to be invisible.  */       background color, which can cause the cursor box to be invisible.  */
9040    xgcv.foreground = f->output_data.mac->cursor_pixel;    xgcv.foreground = f->output_data.mac->cursor_pixel;
# Line 9078  x_draw_bar_cursor (w, row, width) Line 9078  x_draw_bar_cursor (w, row, width)
9078        XGCValues xgcv;        XGCValues xgcv;
9079        Display *dpy;        Display *dpy;
9080        Window window;        Window window;
9081          
9082        cursor_glyph = get_phys_cursor_glyph (w);        cursor_glyph = get_phys_cursor_glyph (w);
9083        if (cursor_glyph == NULL)        if (cursor_glyph == NULL)
9084          return;          return;
# Line 9089  x_draw_bar_cursor (w, row, width) Line 9089  x_draw_bar_cursor (w, row, width)
9089        dpy = FRAME_MAC_DISPLAY (f);        dpy = FRAME_MAC_DISPLAY (f);
9090        window = FRAME_MAC_WINDOW (f);        window = FRAME_MAC_WINDOW (f);
9091        gc = FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc;        gc = FRAME_X_DISPLAY_INFO (f)->scratch_cursor_gc;
9092          
9093        if (gc)        if (gc)
9094          XChangeGC (dpy, gc, mask, &xgcv);          XChangeGC (dpy, gc, mask, &xgcv);
9095        else        else
# Line 9183  x_erase_phys_cursor (w) Line 9183  x_erase_phys_cursor (w)
9183       screen.  */       screen.  */
9184    if (w->phys_cursor_type == NO_CURSOR)    if (w->phys_cursor_type == NO_CURSOR)
9185      goto mark_cursor_off;      goto mark_cursor_off;
9186              
9187    /* VPOS >= active_glyphs->nrows means that window has been resized.    /* VPOS >= active_glyphs->nrows means that window has been resized.
9188       Don't bother to erase the cursor.  */       Don't bother to erase the cursor.  */
9189    if (vpos >= active_glyphs->nrows)    if (vpos >= active_glyphs->nrows)
# Line 9194  x_erase_phys_cursor (w) Line 9194  x_erase_phys_cursor (w)
9194    cursor_row = MATRIX_ROW (active_glyphs, vpos);    cursor_row = MATRIX_ROW (active_glyphs, vpos);
9195    if (!cursor_row->enabled_p)    if (!cursor_row->enabled_p)
9196      goto mark_cursor_off;      goto mark_cursor_off;
9197      
9198    /* If row is completely invisible, don't attempt to delete a cursor which    /* If row is completely invisible, don't attempt to delete a cursor which
9199       isn't there.  This may happen if cursor is at top of window, and       isn't there.  This may happen if cursor is at top of window, and
9200       we switch to a buffer with a header line in that window.  */       we switch to a buffer with a header line in that window.  */
9201    if (cursor_row->visible_height <= 0)    if (cursor_row->visible_height <= 0)
9202      goto mark_cursor_off;      goto mark_cursor_off;
9203      
9204    /* This can happen when the new row is shorter than the old one.    /* This can happen when the new row is shorter than the old one.
9205       In this case, either x_draw_glyphs or clear_end_of_line       In this case, either x_draw_glyphs or clear_end_of_line
9206       should have cleared the cursor.  Note that we wouldn't be       should have cleared the cursor.  Note that we wouldn't be
# Line 9208  x_erase_phys_cursor (w) Line 9208  x_erase_phys_cursor (w)
9208       cursor glyph at hand.  */       cursor glyph at hand.  */
9209    if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])    if (w->phys_cursor.hpos >= cursor_row->used[TEXT_AREA])
9210      goto mark_cursor_off;      goto mark_cursor_off;
9211            
9212    /* If the cursor is in the mouse face area, redisplay that when    /* If the cursor is in the mouse face area, redisplay that when
9213       we clear the cursor.  */       we clear the cursor.  */
9214    if (! NILP (dpyinfo->mouse_face_window)    if (! NILP (dpyinfo->mouse_face_window)
# Line 9236  x_erase_phys_cursor (w) Line 9236  x_erase_phys_cursor (w)
9236          goto mark_cursor_off;          goto mark_cursor_off;
9237    
9238        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),        x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
9239          
9240        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),        XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
9241                    x,                    x,
9242                    WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,                    WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height,
# Line 9245  x_erase_phys_cursor (w) Line 9245  x_erase_phys_cursor (w)
9245                    cursor_row->visible_height,                    cursor_row->visible_height,
9246                    0);                    0);
9247      }      }
9248      
9249    /* Erase the cursor by redrawing the character underneath it.  */    /* Erase the cursor by redrawing the character underneath it.  */
9250    if (mouse_face_here_p)    if (mouse_face_here_p)
9251      hl = DRAW_MOUSE_FACE;      hl = DRAW_MOUSE_FACE;
# Line 9268  cursor_in_mouse_face_p (w) Line 9268  cursor_in_mouse_face_p (w)
9268    struct mac_display_info *dpyinfo    struct mac_display_info *dpyinfo
9269      = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));      = FRAME_MAC_DISPLAY_INFO (XFRAME (w->frame));
9270    int in_mouse_face = 0;    int in_mouse_face = 0;
9271      
9272    if (WINDOWP (dpyinfo->mouse_face_window)    if (WINDOWP (dpyinfo->mouse_face_window)
9273        && XWINDOW (dpyinfo->mouse_face_window) == w)        && XWINDOW (dpyinfo->mouse_face_window) == w)
9274      {      {
# Line 9323  x_display_and_set_cursor (w, on, hpos, v Line 9323  x_display_and_set_cursor (w, on, hpos, v
9323    current_glyphs = w->current_matrix;    current_glyphs = w->current_matrix;
9324    glyph_row = MATRIX_ROW (current_glyphs, vpos);    glyph_row = MATRIX_ROW (current_glyphs, vpos);
9325    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;    glyph = glyph_row->glyphs[TEXT_AREA] + hpos;
9326      
9327    /* If cursor row is not enabled, we don't really know where to    /* If cursor row is not enabled, we don't really know where to
9328       display the cursor.  */       display the cursor.  */
9329    if (!glyph_row->enabled_p)    if (!glyph_row->enabled_p)
9330      {      {
# Line 9356  x_display_and_set_cursor (w, on, hpos, v Line 9356  x_display_and_set_cursor (w, on, hpos, v
9356      {      {
9357        w->phys_cursor_ascent = glyph_row->ascent;        w->phys_cursor_ascent = glyph_row->ascent;
9358        w->phys_cursor_height = glyph_row->height;        w->phys_cursor_height = glyph_row->height;
9359          
9360        /* Set phys_cursor_.* before x_draw_.* is called because some        /* Set phys_cursor_.* before x_draw_.* is called because some
9361           of them may need the information.  */           of them may need the information.  */
9362        w->phys_cursor.x = x;        w->phys_cursor.x = x;
# Line 9760  x_calc_absolute_position (f) Line 9760  x_calc_absolute_position (f)
9760  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
9761        {        {
9762          Rect r;          Rect r;
9763        
9764          GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);          GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
9765          SetPt(&pt, r.left,  r.top);          SetPt(&pt, r.left,  r.top);
9766        }        }
# Line 9841  x_set_window_size (f, change_gravity, co Line 9841  x_set_window_size (f, change_gravity, co
9841       int cols, rows;       int cols, rows;
9842  {  {
9843    int pixelwidth, pixelheight;    int pixelwidth, pixelheight;
9844      
9845    BLOCK_INPUT;    BLOCK_INPUT;
9846      
9847    check_frame_size (f, &rows, &cols);    check_frame_size (f, &rows, &cols);
9848    f->output_data.mac->vertical_scroll_bar_extra    f->output_data.mac->vertical_scroll_bar_extra
9849      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)      = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)
# Line 9864  x_set_window_size (f, change_gravity, co Line 9864  x_set_window_size (f, change_gravity, co
9864       but the window manager will get around to dealing with the size       but the window manager will get around to dealing with the size
9865       change request eventually, and we'll hear how it went when the       change request eventually, and we'll hear how it went when the
9866       ConfigureNotify event gets here.       ConfigureNotify event gets here.
9867        
9868       We could just not bother storing any of this information here,       We could just not bother storing any of this information here,
9869       and let the ConfigureNotify event set everything up, but that       and let the ConfigureNotify event set everything up, but that
9870       might be kind of confusing to the Lisp code, since size changes       might be kind of confusing to the Lisp code, since size changes
# Line 9889  x_set_window_size (f, change_gravity, co Line 9889  x_set_window_size (f, change_gravity, co
9889    mark_window_cursors_off (XWINDOW (f->root_window));    mark_window_cursors_off (XWINDOW (f->root_window));
9890    
9891    /* Clear out any recollection of where the mouse highlighting was,    /* Clear out any recollection of where the mouse highlighting was,
9892       since it might be in a place that's outside the new frame size.       since it might be in a place that's outside the new frame size.
9893       Actually checking whether it is outside is a pain in the neck,       Actually checking whether it is outside is a pain in the neck,
9894       so don't try--just let the highlighting be done afresh with new size.  */       so don't try--just let the highlighting be done afresh with new size.  */
9895    cancel_mouse_face (f);    cancel_mouse_face (f);
# Line 10018  x_make_frame_visible (f) Line 10018  x_make_frame_visible (f)
10018                        f->output_data.mac->top_pos, 0);                        f->output_data.mac->top_pos, 0);
10019    
10020        f->output_data.mac->asked_for_visible = 1;        f->output_data.mac->asked_for_visible = 1;
10021          
10022        ShowWindow (FRAME_MAC_WINDOW (f));        ShowWindow (FRAME_MAC_WINDOW (f));
10023      }      }
10024    
# Line 10082  x_make_frame_invisible (f) Line 10082  x_make_frame_invisible (f)
10082    /* Don't keep the highlight on an invisible frame.  */    /* Don't keep the highlight on an invisible frame.  */
10083    if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)    if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)
10084      FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;      FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;
10085      
10086    BLOCK_INPUT;    BLOCK_INPUT;
10087      
10088    HideWindow (FRAME_MAC_WINDOW (f));    HideWindow (FRAME_MAC_WINDOW (f));
10089      
10090    /* We can't distinguish this from iconification    /* We can't distinguish this from iconification
10091       just by the event that we get from the server.       just by the event that we get from the server.
10092       So we can't win using the usual strategy of letting       So we can't win using the usual strategy of letting
# Line 10096  x_make_frame_invisible (f) Line 10096  x_make_frame_invisible (f)
10096    FRAME_ICONIFIED_P (f) = 0;    FRAME_ICONIFIED_P (f) = 0;
10097    f->async_visible = 0;    f->async_visible = 0;
10098    f->async_iconified = 0;    f->async_iconified = 0;
10099      
10100    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10101  }  }
10102    
# Line 10119  x_iconify_frame (f) Line 10119  x_iconify_frame (f)
10119    BLOCK_INPUT;    BLOCK_INPUT;
10120    
10121    CollapseWindow (FRAME_MAC_WINDOW (f), true);    CollapseWindow (FRAME_MAC_WINDOW (f), true);
10122      
10123    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10124  }  }
10125    
# Line 10380  x_wm_set_icon_pixmap (f, pixmap_id) Line 10380  x_wm_set_icon_pixmap (f, pixmap_id)
10380    }    }
10381    
10382  #else /* not USE_X_TOOLKIT */  #else /* not USE_X_TOOLKIT */
10383      
10384    f->output_data.x->wm_hints.flags |= IconPixmapHint;    f->output_data.x->wm_hints.flags |= IconPixmapHint;
10385    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);    XSetWMHints (FRAME_X_DISPLAY (f), window, &f->output_data.x->wm_hints);
10386    
# Line 10450  wildstrieq (char *s1, char *s2) Line 10450  wildstrieq (char *s1, char *s2)
10450  }  }
10451    
10452  /* Assume parameter 1 is fully qualified, no wildcards. */  /* Assume parameter 1 is fully qualified, no wildcards. */
10453  static int  static int
10454  mac_font_pattern_match (fontname, pattern)  mac_font_pattern_match (fontname, pattern)
10455      char * fontname;      char * fontname;
10456      char * pattern;      char * pattern;
# Line 10487  mac_font_pattern_match (fontname, patter Line 10487  mac_font_pattern_match (fontname, patter
10487    
10488  /* Two font specs are considered to match if their foundry, family,  /* Two font specs are considered to match if their foundry, family,
10489     weight, slant, and charset match.  */     weight, slant, and charset match.  */
10490  static int  static int
10491  mac_font_match (char *mf, char *xf)  mac_font_match (char *mf, char *xf)
10492  {  {
10493    char m_foundry[50], m_family[50], m_weight[20], m_slant[2], m_charset[20];    char m_foundry[50], m_family[50], m_weight[20], m_slant[2], m_charset[20];
# Line 10543  mac_to_x_fontname (char *name, int size, Line 10543  mac_to_x_fontname (char *name, int size,
10543          break;          break;
10544        case smKorean:        case smKorean:
10545          strcpy(cs, "ksc5601.1989-0");          strcpy(cs, "ksc5601.1989-0");
10546          break;                  break;
10547        default:        default:
10548          strcpy(cs, "mac-roman");          strcpy(cs, "mac-roman");
10549          break;          break;
# Line 10553  mac_to_x_fontname (char *name, int size, Line 10553  mac_to_x_fontname (char *name, int size,
10553    sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",    sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",
10554            foundry, family, style & bold ? "bold" : "medium",            foundry, family, style & bold ? "bold" : "medium",
10555            style & italic ? 'i' : 'r', size, size * 10, size * 10, cs);            style & italic ? 'i' : 'r', size, size * 10, size * 10, cs);
10556      
10557    result = (char *) xmalloc (strlen (xf) + 1);    result = (char *) xmalloc (strlen (xf) + 1);
10558    strcpy (result, xf);    strcpy (result, xf);
10559    for (p = result; *p; p++)    for (p = result; *p; p++)
10560      *p = tolower(*p);      *p = tolower(*p);
10561    return result;    return result;
10562  }  }
10563                                                                            
10564    
10565  /* Convert an X font spec to the corresponding mac font name, which  /* Convert an X font spec to the corresponding mac font name, which
10566     can then be passed to GetFNum after conversion to a Pascal string.     can then be passed to GetFNum after conversion to a Pascal string.
# Line 10622  init_font_name_table () Line 10622  init_font_name_table ()
10622  {  {
10623  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
10624    SInt32 sv;    SInt32 sv;
10625      
10626    if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000)    if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000)
10627      {      {
10628        FMFontFamilyIterator ffi;        FMFontFamilyIterator ffi;
# Line 10648  init_font_name_table () Line 10648  init_font_name_table ()
10648            FMFontStyle style;            FMFontStyle style;
10649            FMFontSize size;            FMFontSize size;
10650            SInt16 sc;            SInt16 sc;
10651          
10652            if (FMGetFontFamilyName (ff, name) != noErr)            if (FMGetFontFamilyName (ff, name) != noErr)
10653              break;              break;
10654            p2cstr (name);            p2cstr (name);
10655          
10656            sc = FontToScript (ff);            sc = FontToScript (ff);
10657              
10658            /* Point the instance iterator at the current font family.  */            /* Point the instance iterator at the current font family.  */
10659            if (FMResetFontFamilyInstanceIterator(ff, &ffii) != noErr)            if (FMResetFontFamilyInstanceIterator(ff, &ffii) != noErr)
10660              break;              break;
10661          
10662            while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)            while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
10663                   == noErr)                   == noErr)
10664              if (size == 0)              if (size == 0)
# Line 10683  init_font_name_table () Line 10683  init_font_name_table ()
10683                                                                  -smJapanese));                                                                  -smJapanese));
10684                }                }
10685          }          }
10686      
10687        /* Dispose of the iterators.  */        /* Dispose of the iterators.  */
10688        FMDisposeFontFamilyIterator (&ffi);        FMDisposeFontFamilyIterator (&ffi);
10689        FMDisposeFontFamilyInstanceIterator (&ffii);        FMDisposeFontFamilyInstanceIterator (&ffii);
# Line 10701  init_font_name_table () Line 10701  init_font_name_table ()
10701        Str32 name;        Str32 name;
10702        struct FontAssoc *fat;        struct FontAssoc *fat;
10703        struct AsscEntry *assc_entry;        struct AsscEntry *assc_entry;
10704          
10705        GetPort (&port);  /* save the current font number used */        GetPort (&port);  /* save the current font number used */
10706  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
10707        old_fontnum = GetPortTextFont (port);        old_fontnum = GetPortTextFont (port);
# Line 10714  init_font_name_table () Line 10714  init_font_name_table ()
10714            font_handle = GetIndResource ('FOND', i);            font_handle = GetIndResource ('FOND', i);
10715            if (!font_handle)            if (!font_handle)
10716              continue;              continue;
10717              
10718            GetResInfo (font_handle, &id, &type, name);            GetResInfo (font_handle, &id, &type, name);
10719            GetFNum (name, &fontnum);            GetFNum (name, &fontnum);
10720            p2cstr (name);            p2cstr (name);
10721            if (fontnum == 0)            if (fontnum == 0)
10722              continue;              continue;
10723              
10724            TextFont (fontnum);            TextFont (fontnum);
10725            scriptcode = FontToScript (fontnum);            scriptcode = FontToScript (fontnum);
10726            do            do
10727              {              {
10728                HLock (font_handle);                HLock (font_handle);
10729                  
10730                if (GetResourceSizeOnDisk (font_handle)                if (GetResourceSizeOnDisk (font_handle)
10731                    >= sizeof (struct FamRec))                    >= sizeof (struct FamRec))
10732                  {                  {
# Line 10736  init_font_name_table () Line 10736  init_font_name_table ()
10736                      = (struct AsscEntry *) (*font_handle                      = (struct AsscEntry *) (*font_handle
10737                                              + sizeof (struct FamRec)                                              + sizeof (struct FamRec)
10738                                              + sizeof (struct FontAssoc));                                              + sizeof (struct FontAssoc));
10739                      
10740                    for (j = 0; j <= fat->numAssoc; j++, assc_entry++)                    for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
10741                      {                      {
10742                        if (font_name_table_size == 0)                        if (font_name_table_size == 0)
# Line 10770  init_font_name_table () Line 10770  init_font_name_table ()
10770                          }                          }
10771                      }                      }
10772                  }                  }
10773                  
10774                HUnlock (font_handle);                HUnlock (font_handle);
10775                font_handle_2 = GetNextFOND (font_handle);                font_handle_2 = GetNextFOND (font_handle);
10776                ReleaseResource (font_handle);                ReleaseResource (font_handle);
# Line 10778  init_font_name_table () Line 10778  init_font_name_table ()
10778              }              }
10779            while (ResError () == noErr && font_handle);            while (ResError () == noErr && font_handle);
10780          }          }
10781      
10782        TextFont (old_fontnum);        TextFont (old_fontnum);
10783  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
10784      }      }
# Line 10836  x_list_fonts (struct frame *f, Line 10836  x_list_fonts (struct frame *f,
10836              break;              break;
10837          }          }
10838      }      }
10839      
10840    /* MAC_TODO: add code for matching outline fonts here */    /* MAC_TODO: add code for matching outline fonts here */
10841    
10842    UNGCPRO;    UNGCPRO;
# Line 10848  x_list_fonts (struct frame *f, Line 10848  x_list_fonts (struct frame *f,
10848                        XCDR (dpyinfo->name_list_element)));                        XCDR (dpyinfo->name_list_element)));
10849      }      }
10850   label_cached:   label_cached:
10851      
10852    return newlist;    return newlist;
10853  }  }
10854    
# Line 10869  x_check_font (f, font) Line 10869  x_check_font (f, font)
10869    xassert (font != NULL);    xassert (font != NULL);
10870    
10871    for (i = 0; i < dpyinfo->n_fonts; i++)    for (i = 0; i < dpyinfo->n_fonts; i++)
10872      if (dpyinfo->font_table[i].name      if (dpyinfo->font_table[i].name
10873          && font == dpyinfo->font_table[i].font)          && font == dpyinfo->font_table[i].font)
10874        break;        break;
10875    
# Line 10913  x_compute_min_glyph_bounds (f) Line 10913  x_compute_min_glyph_bounds (f)
10913    MacFontStruct *font;    MacFontStruct *font;
10914    int old_width = dpyinfo->smallest_char_width;    int old_width = dpyinfo->smallest_char_width;
10915    int old_height = dpyinfo->smallest_font_height;    int old_height = dpyinfo->smallest_font_height;
10916      
10917    dpyinfo->smallest_font_height = 100000;    dpyinfo->smallest_font_height = 100000;
10918    dpyinfo->smallest_char_width = 100000;    dpyinfo->smallest_char_width = 100000;
10919      
10920    for (i = 0; i < dpyinfo->n_fonts; ++i)    for (i = 0; i < dpyinfo->n_fonts; ++i)
10921      if (dpyinfo->font_table[i].name)      if (dpyinfo->font_table[i].name)
10922        {        {
10923          struct font_info *fontp = dpyinfo->font_table + i;          struct font_info *fontp = dpyinfo->font_table + i;
10924          int w, h;          int w, h;
10925            
10926          font = (MacFontStruct *) fontp->font;          font = (MacFontStruct *) fontp->font;
10927          xassert (font != (MacFontStruct *) ~0);          xassert (font != (MacFontStruct *) ~0);
10928          x_font_min_bounds (font, &w, &h);          x_font_min_bounds (font, &w, &h);
10929            
10930          dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);          dpyinfo->smallest_font_height = min (dpyinfo->smallest_font_height, h);
10931          dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);          dpyinfo->smallest_char_width = min (dpyinfo->smallest_char_width, w);
10932        }        }
# Line 10951  is_fully_specified_xlfd (char *p) Line 10951  is_fully_specified_xlfd (char *p)
10951    
10952    if (*p != '-')    if (*p != '-')
10953      return 0;      return 0;
10954      
10955    for (i = 0; i < 13; i++)    for (i = 0; i < 13; i++)
10956      {      {
10957        q = strchr (p + 1, '-');        q = strchr (p + 1, '-');
# Line 10964  is_fully_specified_xlfd (char *p) Line 10964  is_fully_specified_xlfd (char *p)
10964    
10965    if (strchr (p + 1, '-') != NULL)    if (strchr (p + 1, '-') != NULL)
10966      return 0;      return 0;
10967      
10968    if (*(p + 1) == '*' && *(p + 2) == '\0')    if (*(p + 1) == '*' && *(p + 2) == '\0')
10969      return 0;      return 0;
10970    
# Line 11006  XLoadQueryFont (Display *dpy, char *font Line 11006  XLoadQueryFont (Display *dpy, char *font
11006    
11007        if (i >= font_name_count)        if (i >= font_name_count)
11008          return NULL;          return NULL;
11009      
11010        name = font_name_table[i];        name = font_name_table[i];
11011      }      }
11012    
# Line 11037  XLoadQueryFont (Display *dpy, char *font Line 11037  XLoadQueryFont (Display *dpy, char *font
11037    GetFNum (mfontname, &fontnum);    GetFNum (mfontname, &fontnum);
11038    if (fontnum == 0)    if (fontnum == 0)
11039      return NULL;      return NULL;
11040        
11041    font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));    font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
11042      
11043    font->fontname = (char *) xmalloc (strlen (name) + 1);    font->fontname = (char *) xmalloc (strlen (name) + 1);
11044    bcopy (name, font->fontname, strlen (name) + 1);    bcopy (name, font->fontname, strlen (name) + 1);
11045    
# Line 11055  XLoadQueryFont (Display *dpy, char *font Line 11055  XLoadQueryFont (Display *dpy, char *font
11055    {    {
11056      char cs[32];      char cs[32];
11057    
11058      if (sscanf (name,      if (sscanf (name,
11059                  "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",                  "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
11060                  cs) == 1                  cs) == 1
11061          && 0 == strcmp (cs, "jisx0201.1976-0"))            && 0 == strcmp (cs, "jisx0201.1976-0"))
11062        font->mac_scriptcode = smRoman;        font->mac_scriptcode = smRoman;
11063    }    }
11064      
11065    is_two_byte_font = font->mac_scriptcode == smJapanese ||    is_two_byte_font = font->mac_scriptcode == smJapanese ||
11066                       font->mac_scriptcode == smTradChinese ||                       font->mac_scriptcode == smTradChinese ||
11067                       font->mac_scriptcode == smSimpChinese ||                       font->mac_scriptcode == smSimpChinese ||
# Line 11070  XLoadQueryFont (Display *dpy, char *font Line 11070  XLoadQueryFont (Display *dpy, char *font
11070    TextFont (fontnum);    TextFont (fontnum);
11071    TextSize (size);    TextSize (size);
11072    TextFace (fontface);    TextFace (fontface);
11073      
11074    GetFontInfo (&the_fontinfo);    GetFontInfo (&the_fontinfo);
11075    
11076    font->ascent = the_fontinfo.ascent;    font->ascent = the_fontinfo.ascent;
# Line 11083  XLoadQueryFont (Display *dpy, char *font Line 11083  XLoadQueryFont (Display *dpy, char *font
11083      font->max_byte1 = 0;      font->max_byte1 = 0;
11084    font->min_char_or_byte2 = 0x20;    font->min_char_or_byte2 = 0x20;
11085    font->max_char_or_byte2 = 0xff;    font->max_char_or_byte2 = 0xff;
11086      
11087    if (is_two_byte_font)    if (is_two_byte_font)
11088      {      {
11089        /* Use the width of an "ideographic space" of that font because        /* Use the width of an "ideographic space" of that font because
# Line 11125  XLoadQueryFont (Display *dpy, char *font Line 11125  XLoadQueryFont (Display *dpy, char *font
11125          xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));          xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
11126        {        {
11127          int c;          int c;
11128        
11129          for (c = 0x20; c <= 0xff; c++)          for (c = 0x20; c <= 0xff; c++)
11130            {            {
11131              font->per_char[c - 0x20] = font->max_bounds;              font->per_char[c - 0x20] = font->max_bounds;
# Line 11133  XLoadQueryFont (Display *dpy, char *font Line 11133  XLoadQueryFont (Display *dpy, char *font
11133            }            }
11134        }        }
11135      }      }
11136      
11137    TextFont (old_fontnum);  /* restore previous font number, size and face */    TextFont (old_fontnum);  /* restore previous font number, size and face */
11138    TextSize (old_fontsize);    TextSize (old_fontsize);
11139    TextFace (old_fontface);    TextFace (old_fontface);
11140      
11141    return font;    return font;
11142  }  }
11143    
# Line 11531  static pascal OSErr do_ae_quit_applicati Line 11531  static pascal OSErr do_ae_quit_applicati
11531    
11532  /* Drag and Drop */  /* Drag and Drop */
11533  static OSErr init_mac_drag_n_drop ();  static OSErr init_mac_drag_n_drop ();
11534  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
11535    
11536  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
11537  /* Preliminary Support for the OSX Services Menu */  /* Preliminary Support for the OSX Services Menu */
# Line 11546  extern void check_alarm (); Line 11546  extern void check_alarm ();
11546  extern void initialize_applescript();  extern void initialize_applescript();
11547  extern void terminate_applescript();  extern void terminate_applescript();
11548    
11549  static unsigned int  static unsigned int
11550  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
11551  mac_to_emacs_modifiers (UInt32 mods)  mac_to_emacs_modifiers (UInt32 mods)
11552  #else  #else
# Line 11568  mac_to_emacs_modifiers (EventModifiers m Line 11568  mac_to_emacs_modifiers (EventModifiers m
11568  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
11569  /* Obtains the event modifiers from the event ref and then calls  /* Obtains the event modifiers from the event ref and then calls
11570     mac_to_emacs_modifiers.  */     mac_to_emacs_modifiers.  */
11571  static int  static int
11572  mac_event_to_emacs_modifiers (EventRef eventRef)  mac_event_to_emacs_modifiers (EventRef eventRef)
11573  {  {
11574    UInt32 mods = 0;    UInt32 mods = 0;
11575    GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,    GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
# Line 11580  mac_event_to_emacs_modifiers (EventRef e Line 11580  mac_event_to_emacs_modifiers (EventRef e
11580  /* Given an event ref, return the code to use for the mouse button  /* Given an event ref, return the code to use for the mouse button
11581     code in the emacs input_event.  */     code in the emacs input_event.  */
11582  static int  static int
11583  mac_get_mouse_btn (EventRef ref)  mac_get_mouse_btn (EventRef ref)
11584  {  {
11585    EventMouseButton result = kEventMouseButtonPrimary;    EventMouseButton result = kEventMouseButtonPrimary;
11586    GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,    GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,
11587                      sizeof (EventMouseButton), NULL, &result);                      sizeof (EventMouseButton), NULL, &result);
11588    switch (result)    switch (result)
11589      {      {
11590      case kEventMouseButtonPrimary:      case kEventMouseButtonPrimary:
11591        return 0;        return 0;
11592      case kEventMouseButtonSecondary:      case kEventMouseButtonSecondary:
11593        return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2;        return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2;
11594      case kEventMouseButtonTertiary:      case kEventMouseButtonTertiary:
11595      case 4:  /* 4 is the number for the mouse wheel button */      case 4:  /* 4 is the number for the mouse wheel button */
11596        return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1;        return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1;
11597      default:      default:
11598        return 0;        return 0;
11599      }      }
# Line 11605  mac_get_mouse_btn (EventRef ref) Line 11605  mac_get_mouse_btn (EventRef ref)
11605     checks to see if it is a mouse up or down carbon event that has not     checks to see if it is a mouse up or down carbon event that has not
11606     been converted, and if so, converts it by hand (to be picked up in     been converted, and if so, converts it by hand (to be picked up in
11607     the XTread_socket loop).  */     the XTread_socket loop).  */
11608  static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)  static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
11609  {  {
11610    Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);    Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);
11611    /* Do special case for mouse wheel button.  */    /* Do special case for mouse wheel button.  */
11612    if (!result && GetEventClass (eventRef) == kEventClassMouse)    if (!result && GetEventClass (eventRef) == kEventClassMouse)
11613      {      {
11614        UInt32 kind = GetEventKind (eventRef);        UInt32 kind = GetEventKind (eventRef);
11615        if (kind == kEventMouseDown && !(eventRec->what == mouseDown))        if (kind == kEventMouseDown && !(eventRec->what == mouseDown))
11616          {          {
11617            eventRec->what = mouseDown;            eventRec->what = mouseDown;
11618            result=1;            result=1;
11619          }          }
11620        if (kind == kEventMouseUp && !(eventRec->what == mouseUp))        if (kind == kEventMouseUp && !(eventRec->what == mouseUp))
11621          {          {
11622            eventRec->what = mouseUp;            eventRec->what = mouseUp;
11623            result=1;            result=1;
11624          }          }
11625        if (result)        if (result)
11626          {          {
11627            /* Need where and when.  */            /* Need where and when.  */
11628            UInt32 mods;            UInt32 mods;
# Line 11636  static Boolean mac_convert_event_ref (Ev Line 11636  static Boolean mac_convert_event_ref (Ev
11636                               typeUInt32, NULL, sizeof (UInt32),                               typeUInt32, NULL, sizeof (UInt32),
11637                               NULL, &mods);                               NULL, &mods);
11638            eventRec->modifiers = mods;            eventRec->modifiers = mods;
11639              
11640            eventRec->when = EventTimeToTicks (GetEventTime (eventRef));            eventRec->when = EventTimeToTicks (GetEventTime (eventRef));
11641          }          }
11642      }      }
# Line 11650  do_get_menus (void) Line 11650  do_get_menus (void)
11650  {  {
11651    Handle menubar_handle;    Handle menubar_handle;
11652    MenuHandle menu_handle;    MenuHandle menu_handle;
11653            
11654    menubar_handle = GetNewMBar (128);    menubar_handle = GetNewMBar (128);
11655    if(menubar_handle == NULL)    if(menubar_handle == NULL)
11656      abort ();      abort ();
# Line 11678  do_init_managers (void) Line 11678  do_init_managers (void)
11678    InitDialogs (NULL);    InitDialogs (NULL);
11679  #endif /* !TARGET_API_MAC_CARBON */  #endif /* !TARGET_API_MAC_CARBON */
11680    InitCursor ();    InitCursor ();
11681            
11682  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
11683    /* set up some extra stack space for use by emacs */    /* set up some extra stack space for use by emacs */
11684    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
# Line 11694  static void Line 11694  static void
11694  do_check_ram_size (void)  do_check_ram_size (void)
11695  {  {
11696    SInt32 physical_ram_size, logical_ram_size;    SInt32 physical_ram_size, logical_ram_size;
11697      
11698    if (Gestalt (gestaltPhysicalRAMSize, &physical_ram_size) != noErr    if (Gestalt (gestaltPhysicalRAMSize, &physical_ram_size) != noErr
11699        || Gestalt (gestaltLogicalRAMSize, &logical_ram_size) != noErr        || Gestalt (gestaltLogicalRAMSize, &logical_ram_size) != noErr
11700        || physical_ram_size > 256 * 1024 * 1024        || physical_ram_size > 256 * 1024 * 1024
# Line 11718  do_window_update (WindowPtr win) Line 11718  do_window_update (WindowPtr win)
11718            f->async_visible = 1;            f->async_visible = 1;
11719            f->async_iconified = 0;            f->async_iconified = 0;
11720            SET_FRAME_GARBAGED (f);            SET_FRAME_GARBAGED (f);
11721              
11722            /* An update event is equivalent to MapNotify on X, so report            /* An update event is equivalent to MapNotify on X, so report
11723               visibility changes properly.  */               visibility changes properly.  */
11724            if (! NILP(Vframe_list) && ! NILP (XCDR (Vframe_list)))            if (! NILP(Vframe_list) && ! NILP (XCDR (Vframe_list)))
# Line 11767  do_window_activate (WindowPtr win) Line 11767  do_window_activate (WindowPtr win)
11767      {      {
11768        mwp = (mac_output *) GetWRefCon (win);        mwp = (mac_output *) GetWRefCon (win);
11769        f = mwp->mFP;        f = mwp->mFP;
11770          
11771        if (f)        if (f)
11772          {          {
11773            x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);            x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
# Line 11786  do_window_deactivate (WindowPtr win) Line 11786  do_window_deactivate (WindowPtr win)
11786      {      {
11787        mwp = (mac_output *) GetWRefCon (win);        mwp = (mac_output *) GetWRefCon (win);
11788        f = mwp->mFP;        f = mwp->mFP;
11789          
11790        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
11791          {          {
11792            x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);            x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
# Line 11850  do_mouse_moved (Point mouse_pos) Line 11850  do_mouse_moved (Point mouse_pos)
11850    WindowPtr wp = FrontWindow ();    WindowPtr wp = FrontWindow ();
11851    struct frame *f;    struct frame *f;
11852    
11853    if (is_emacs_window (wp))    if (is_emacs_window (wp))
11854      {      {
11855        f = ((mac_output *) GetWRefCon (wp))->mFP;                    f = ((mac_output *) GetWRefCon (wp))->mFP;
11856          
11857  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
11858        SetPort (GetWindowPort (wp));        SetPort (GetWindowPort (wp));
11859  #else  #else
# Line 11861  do_mouse_moved (Point mouse_pos) Line 11861  do_mouse_moved (Point mouse_pos)
11861  #endif  #endif
11862    
11863        GlobalToLocal (&mouse_pos);        GlobalToLocal (&mouse_pos);
11864          
11865        note_mouse_movement (f, &mouse_pos);        note_mouse_movement (f, &mouse_pos);
11866      }      }
11867  }  }
# Line 11878  do_os_event (EventRecord *erp) Line 11878  do_os_event (EventRecord *erp)
11878        else        else
11879          do_app_suspend ();          do_app_suspend ();
11880        break;        break;
11881                                    
11882      case mouseMovedMessage:      case mouseMovedMessage:
11883        do_mouse_moved (erp->where);        do_mouse_moved (erp->where);
11884        break;        break;
# Line 11913  do_apple_menu (SInt16 menu_item) Line 11913  do_apple_menu (SInt16 menu_item)
11913  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
11914    Str255 item_name;    Str255 item_name;
11915    SInt16 da_driver_refnum;    SInt16 da_driver_refnum;
11916            
11917    if (menu_item == I_ABOUT)    if (menu_item == I_ABOUT)
11918      NoteAlert (ABOUT_ALERT_ID, NULL);      NoteAlert (ABOUT_ALERT_ID, NULL);
11919    else    else
# Line 11928  void Line 11928  void
11928  do_menu_choice (SInt32 menu_choice)  do_menu_choice (SInt32 menu_choice)
11929  {  {
11930    SInt16 menu_id, menu_item;    SInt16 menu_id, menu_item;
11931      
11932    menu_id = HiWord (menu_choice);    menu_id = HiWord (menu_choice);
11933    menu_item = LoWord (menu_choice);    menu_item = LoWord (menu_choice);
11934      
11935    if (menu_id == 0)    if (menu_id == 0)
11936      return;      return;
11937      
11938    switch (menu_id)    switch (menu_id)
11939      {      {
11940      case M_APPLE:      case M_APPLE:
# Line 11944  do_menu_choice (SInt32 menu_choice) Line 11944  do_menu_choice (SInt32 menu_choice)
11944      default:      default:
11945        {        {
11946          WindowPtr wp = FrontWindow ();          WindowPtr wp = FrontWindow ();
11947          struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;                      struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
11948          MenuHandle menu = GetMenuHandle (menu_id);          MenuHandle menu = GetMenuHandle (menu_id);
11949          if (menu)          if (menu)
11950            {            {
11951              UInt32 refcon;              UInt32 refcon;
11952                
11953              GetMenuItemRefCon (menu, menu_item, &refcon);              GetMenuItemRefCon (menu, menu_item, &refcon);
11954              menubar_selection_callback (f, refcon);              menubar_selection_callback (f, refcon);
11955            }            }
11956        }        }
11957      }      }
11958      
11959    HiliteMenu (0);    HiliteMenu (0);
11960  }  }
11961    
# Line 11971  do_grow_window (WindowPtr w, EventRecord Line 11971  do_grow_window (WindowPtr w, EventRecord
11971    int rows, columns;    int rows, columns;
11972    mac_output *mwp = (mac_output *) GetWRefCon (w);    mac_output *mwp = (mac_output *) GetWRefCon (w);
11973    struct frame *f = mwp->mFP;    struct frame *f = mwp->mFP;
11974      
11975    SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);    SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);
11976      
11977    grow_size = GrowWindow (w, e->where, &limit_rect);    grow_size = GrowWindow (w, e->where, &limit_rect);
11978      
11979    /* see if it really changed size */    /* see if it really changed size */
11980    if (grow_size != 0)    if (grow_size != 0)
11981      {      {
11982        rows = PIXEL_TO_CHAR_HEIGHT (f, HiWord (grow_size));        rows = PIXEL_TO_CHAR_HEIGHT (f, HiWord (grow_size));
11983        columns = PIXEL_TO_CHAR_WIDTH (f, LoWord (grow_size));        columns = PIXEL_TO_CHAR_WIDTH (f, LoWord (grow_size));
11984          
11985        x_set_window_size (f, 0, columns, rows);        x_set_window_size (f, 0, columns, rows);
11986      }      }
11987  }  }
# Line 12001  do_zoom_window (WindowPtr w, int zoom_in Line 12001  do_zoom_window (WindowPtr w, int zoom_in
12001    int w_title_height, columns, rows, width, height, dummy, x, y;    int w_title_height, columns, rows, width, height, dummy, x, y;
12002    mac_output *mwp = (mac_output *) GetWRefCon (w);    mac_output *mwp = (mac_output *) GetWRefCon (w);
12003    struct frame *f = mwp->mFP;    struct frame *f = mwp->mFP;
12004      
12005    GetPort (&save_port);    GetPort (&save_port);
12006    
12007  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 12015  do_zoom_window (WindowPtr w, int zoom_in Line 12015  do_zoom_window (WindowPtr w, int zoom_in
12015    {    {
12016      Rect r;      Rect r;
12017      BitMap bm;      BitMap bm;
12018        
12019      GetWindowPortBounds (w, &r);      GetWindowPortBounds (w, &r);
12020      EraseRect (&r);      EraseRect (&r);
12021    
# Line 12030  do_zoom_window (WindowPtr w, int zoom_in Line 12030  do_zoom_window (WindowPtr w, int zoom_in
12030          zoom_rect = bm.bounds;          zoom_rect = bm.bounds;
12031          zoom_rect.top += w_title_height;          zoom_rect.top += w_title_height;
12032          InsetRect (&zoom_rect, 8, 4);  /* not too tight */          InsetRect (&zoom_rect, 8, 4);  /* not too tight */
12033        
12034          zoom_rect.right = zoom_rect.left          zoom_rect.right = zoom_rect.left
12035            + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);            + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
12036    
# Line 12052  do_zoom_window (WindowPtr w, int zoom_in Line 12052  do_zoom_window (WindowPtr w, int zoom_in
12052        zoom_rect = qd.screenBits.bounds;        zoom_rect = qd.screenBits.bounds;
12053        zoom_rect.top += w_title_height;        zoom_rect.top += w_title_height;
12054        InsetRect (&zoom_rect, 8, 4);  /* not too tight */        InsetRect (&zoom_rect, 8, 4);  /* not too tight */
12055          
12056        zoom_rect.right = zoom_rect.left        zoom_rect.right = zoom_rect.left
12057          + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);          + CHAR_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
12058    
# Line 12098  init_required_apple_events () Line 12098  init_required_apple_events ()
12098    
12099    if (!(result & (1 << gestaltAppleEventsPresent)))    if (!(result & (1 << gestaltAppleEventsPresent)))
12100      abort ();      abort ();
12101      
12102  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
12103    err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,    err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
12104                                NewAEEventHandlerUPP                                NewAEEventHandlerUPP
# Line 12175  OSStatus Line 12175  OSStatus
12175  mac_handle_service_event (EventHandlerCallRef callRef,  mac_handle_service_event (EventHandlerCallRef callRef,
12176                            EventRef event, void *data)                            EventRef event, void *data)
12177  {  {
12178    OSStatus err = noErr;    OSStatus err = noErr;
12179    switch (GetEventKind (event))    switch (GetEventKind (event))
12180      {      {
12181      case kEventServiceGetTypes:      case kEventServiceGetTypes:
12182        {        {
12183          CFMutableArrayRef copyTypes, pasteTypes;          CFMutableArrayRef copyTypes, pasteTypes;
12184          CFStringRef type;          CFStringRef type;
# Line 12214  mac_handle_service_event (EventHandlerCa Line 12214  mac_handle_service_event (EventHandlerCa
12214                {                {
12215                  GetEventParameter (event, kEventParamScrapRef, typeScrapRef, NULL,                  GetEventParameter (event, kEventParamScrapRef, typeScrapRef, NULL,
12216                                     sizeof (ScrapRef), NULL, &specificScrap);                                     sizeof (ScrapRef), NULL, &specificScrap);
12217                  
12218                  err = GetScrapFlavorData (currentScrap, kScrapFlavorTypeText,                  err = GetScrapFlavorData (currentScrap, kScrapFlavorTypeText,
12219                                            &byteCount, buffer);                                            &byteCount, buffer);
12220                  if (err == noErr)                  if (err == noErr)
12221                    PutScrapFlavor (specificScrap, kScrapFlavorTypeText,                    PutScrapFlavor (specificScrap, kScrapFlavorTypeText,
12222                                    kScrapFlavorMaskNone, byteCount, buffer);                                    kScrapFlavorMaskNone, byteCount, buffer);
12223                  xfree (buffer);                  xfree (buffer);
12224                }                }
12225            }            }
12226          err = noErr;          err = noErr;
12227        }        }
# Line 12237  mac_handle_service_event (EventHandlerCa Line 12237  mac_handle_service_event (EventHandlerCa
12237          if (err == noErr) {          if (err == noErr) {
12238            void * buffer = xmalloc(byteCount);            void * buffer = xmalloc(byteCount);
12239            if (buffer != NULL ) {            if (buffer != NULL ) {
12240              err = GetScrapFlavorData(specificScrap, kScrapFlavorTypeText,              err = GetScrapFlavorData(specificScrap, kScrapFlavorTypeText,
12241                                       &byteCount, buffer);                                       &byteCount, buffer);
12242              if (err == noErr) {              if (err == noErr) {
12243                // Actually place in the buffer                // Actually place in the buffer
# Line 12249  mac_handle_service_event (EventHandlerCa Line 12249  mac_handle_service_event (EventHandlerCa
12249            xfree(buffer);            xfree(buffer);
12250          }          }
12251          */          */
12252        }          }
12253      }      }
12254    return err;    return err;
12255  }  }
# Line 12271  path_from_vol_dir_name (char *, int, sho Line 12271  path_from_vol_dir_name (char *, int, sho
12271  /* Called when we receive an AppleEvent with an ID of  /* Called when we receive an AppleEvent with an ID of
12272     "kAEOpenDocuments".  This routine gets the direct parameter,     "kAEOpenDocuments".  This routine gets the direct parameter,
12273     extracts the FSSpecs in it, and puts their names on a list.  */     extracts the FSSpecs in it, and puts their names on a list.  */
12274  static pascal OSErr      static pascal OSErr
12275  do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)  do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
12276  {  {
12277    OSErr err, err2;    OSErr err, err2;
# Line 12287  do_ae_open_documents(AppleEvent *message Line 12287  do_ae_open_documents(AppleEvent *message
12287    /* Check to see that we got all of the required parameters from the    /* Check to see that we got all of the required parameters from the
12288       event descriptor.  For an 'odoc' event this should just be the       event descriptor.  For an 'odoc' event this should just be the
12289       file list.  */       file list.  */
12290    err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard,    err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard,
12291                            &actual_type, (Ptr) &keyword,                            &actual_type, (Ptr) &keyword,
12292                            sizeof (keyword), &actual_size);                            sizeof (keyword), &actual_size);
12293    /* No error means that we found some unused parameters.    /* No error means that we found some unused parameters.
# Line 12309  do_ae_open_documents(AppleEvent *message Line 12309  do_ae_open_documents(AppleEvent *message
12309      if (err == noErr)      if (err == noErr)
12310        {        {
12311          int i;          int i;
12312            
12313          /* AE file list is one based so just use that for indexing here.  */          /* AE file list is one based so just use that for indexing here.  */
12314          for (i = 1; (err == noErr) && (i <= num_files_to_open); i++)          for (i = 1; (err == noErr) && (i <= num_files_to_open); i++)
12315            {            {
# Line 12366  mac_do_receive_drag (WindowPtr window, v Line 12366  mac_do_receive_drag (WindowPtr window, v
12366    drag_and_drop_file_list = Qnil;    drag_and_drop_file_list = Qnil;
12367    GetDragMouse (theDrag, &mouse, 0L);    GetDragMouse (theDrag, &mouse, 0L);
12368    CountDragItems (theDrag, &items);    CountDragItems (theDrag, &items);
12369    for (index = 1; index <= items; index++)    for (index = 1; index <= items; index++)
12370      {      {
12371        /* Only handle file references.  */        /* Only handle file references.  */
12372        GetDragItemReferenceNumber (theDrag, index, &theItem);        GetDragItemReferenceNumber (theDrag, index, &theItem);
# Line 12398  mac_do_receive_drag (WindowPtr window, v Line 12398  mac_do_receive_drag (WindowPtr window, v
12398      }      }
12399    /* If there are items in the list, construct an event and post it to    /* If there are items in the list, construct an event and post it to
12400       the queue like an interrupt using kbd_buffer_store_event.  */       the queue like an interrupt using kbd_buffer_store_event.  */
12401    if (!NILP (drag_and_drop_file_list))    if (!NILP (drag_and_drop_file_list))
12402      {      {
12403        struct input_event event;        struct input_event event;
12404        Lisp_Object frame;        Lisp_Object frame;
# Line 12479  profiler_exit_proc () Line 12479  profiler_exit_proc ()
12479    
12480  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
12481  #undef main  #undef main
12482  int  int
12483  main (void)  main (void)
12484  {  {
12485  #if __profile__  /* is the profiler on? */  #if __profile__  /* is the profiler on? */
# Line 12494  main (void) Line 12494  main (void)
12494  #endif  #endif
12495    
12496    do_init_managers ();    do_init_managers ();
12497            
12498    do_get_menus ();    do_get_menus ();
12499            
12500    do_check_ram_size ();    do_check_ram_size ();
12501    
12502    init_emacs_passwd_dir ();    init_emacs_passwd_dir ();
# Line 12506  main (void) Line 12506  main (void)
12506    initialize_applescript ();    initialize_applescript ();
12507    
12508    init_required_apple_events ();    init_required_apple_events ();
12509            
12510    {    {
12511      char **argv;      char **argv;
12512      int argc = 0;      int argc = 0;
# Line 12544  static unsigned char keycode_to_xkeysym_ Line 12544  static unsigned char keycode_to_xkeysym_
12544    /*0x38*/ 0, 0, 0, 0,    /*0x38*/ 0, 0, 0, 0,
12545    /*0x3C*/ 0, 0, 0, 0,    /*0x3C*/ 0, 0, 0, 0,
12546    
12547    /*0x40*/ 0, 0xae /*kp-.*/, 0, 0xaa /*kp-**/,    /*0x40*/ 0, 0xae /*kp-.*/, 0, 0xaa /*kp-**/,
12548    /*0x44*/ 0, 0xab /*kp-+*/, 0, 0x7f /*kp-clear*/,    /*0x44*/ 0, 0xab /*kp-+*/, 0, 0x7f /*kp-clear*/,
12549    /*0x48*/ 0, 0, 0, 0xaf /*kp-/*/,    /*0x48*/ 0, 0, 0, 0xaf /*kp-/*/,
12550    /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp--*/, 0,    /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp--*/, 0,
# Line 12555  static unsigned char keycode_to_xkeysym_ Line 12555  static unsigned char keycode_to_xkeysym_
12555    /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,    /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,
12556    
12557    /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,    /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,
12558    /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,    /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,
12559    /*0x68*/ 0, 0xca /*f13*/, 0, 0xcb /*f14*/,    /*0x68*/ 0, 0xca /*f13*/, 0, 0xcb /*f14*/,
12560    /*0x6C*/ 0, 0xc7 /*f10*/, 0, 0xc9 /*f12*/,    /*0x6C*/ 0, 0xc7 /*f10*/, 0, 0xc9 /*f12*/,
12561    
12562    /*0x70*/ 0, 0xcc /*f15*/, 0x9e /*insert (or 0x6a==help)*/, 0x95 /*home*/,    /*0x70*/ 0, 0xcc /*f15*/, 0x9e /*insert (or 0x6a==help)*/, 0x95 /*home*/,
# Line 12577  keycode_to_xkeysym (int keyCode, int *xK Line 12577  keycode_to_xkeysym (int keyCode, int *xK
12577  int  int
12578  XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)  XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
12579  {  {
12580    int count = 0;    int count = 0;
12581  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12582    OSStatus rneResult;    OSStatus rneResult;
12583    EventRef eventRef;    EventRef eventRef;
# Line 12629  XTread_socket (int sd, struct input_even Line 12629  XTread_socket (int sd, struct input_even
12629      event_mask -= highLevelEventMask;      event_mask -= highLevelEventMask;
12630    
12631  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12632    rneResult = ReceiveNextEvent (0, NULL,    rneResult = ReceiveNextEvent (0, NULL,
12633                                  expected                                  expected
12634                                  ? TicksToEventTime (app_sleep_time)                                  ? TicksToEventTime (app_sleep_time)
12635                                  : 0,                                  : 0,
# Line 12637  XTread_socket (int sd, struct input_even Line 12637  XTread_socket (int sd, struct input_even
12637    if (!rneResult)    if (!rneResult)
12638      {      {
12639        /* Handle new events */        /* Handle new events */
12640        if (!mac_convert_event_ref (eventRef, &er))        if (!mac_convert_event_ref (eventRef, &er))
12641          switch (GetEventClass (eventRef))          switch (GetEventClass (eventRef))
12642            {            {
12643            case kEventClassMouse:            case kEventClassMouse:
12644              if (GetEventKind (eventRef) == kEventMouseWheelMoved)              if (GetEventKind (eventRef) == kEventMouseWheelMoved)
12645                {                {
12646                  SInt32 delta;                  SInt32 delta;
12647                  Point point;                  Point point;
# Line 12671  XTread_socket (int sd, struct input_even Line 12671  XTread_socket (int sd, struct input_even
12671                  bufp->timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);                  bufp->timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
12672                  count++;                  count++;
12673                }                }
12674              else                          else
12675                SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());                SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
12676    
12677              break;              break;
# Line 12707  XTread_socket (int sd, struct input_even Line 12707  XTread_socket (int sd, struct input_even
12707              {              {
12708                struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);                struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);
12709                Point mouse_loc = er.where;                Point mouse_loc = er.where;
12710                  
12711                /* Convert to local coordinates of new window.  */                /* Convert to local coordinates of new window.  */
12712  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
12713                SetPort (GetWindowPort (window_ptr));                SetPort (GetWindowPort (window_ptr));
# Line 12716  XTread_socket (int sd, struct input_even Line 12716  XTread_socket (int sd, struct input_even
12716  #endif  #endif
12717    
12718                GlobalToLocal (&mouse_loc);                GlobalToLocal (&mouse_loc);
12719                      
12720  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12721                bufp->code = mac_get_mouse_btn (eventRef);                bufp->code = mac_get_mouse_btn (eventRef);
12722  #else  #else
# Line 12736  XTread_socket (int sd, struct input_even Line 12736  XTread_socket (int sd, struct input_even
12736    
12737                XSETINT (bufp->x, tracked_scroll_bar->left + 2);                XSETINT (bufp->x, tracked_scroll_bar->left + 2);
12738                XSETINT (bufp->y, mouse_loc.v - 24);                XSETINT (bufp->y, mouse_loc.v - 24);
12739                tracked_scroll_bar->dragging = Qnil;                                    tracked_scroll_bar->dragging = Qnil;
12740                mouse_tracking_in_progress = mouse_tracking_none;                mouse_tracking_in_progress = mouse_tracking_none;
12741                tracked_scroll_bar = NULL;                tracked_scroll_bar = NULL;
12742                count++;                count++;
# Line 12744  XTread_socket (int sd, struct input_even Line 12744  XTread_socket (int sd, struct input_even
12744              }              }
12745    
12746            part_code = FindWindow (er.where, &window_ptr);            part_code = FindWindow (er.where, &window_ptr);
12747                                            
12748            switch (part_code)            switch (part_code)
12749              {              {
12750              case inMenuBar:              case inMenuBar:
# Line 12768  XTread_socket (int sd, struct input_even Line 12768  XTread_socket (int sd, struct input_even
12768                    struct mac_output *mwp = (mac_output *)                    struct mac_output *mwp = (mac_output *)
12769                      GetWRefCon (window_ptr);                      GetWRefCon (window_ptr);
12770                    Point mouse_loc = er.where;                    Point mouse_loc = er.where;
12771                      
12772                    /* convert to local coordinates of new window */                    /* convert to local coordinates of new window */
12773  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
12774                    SetPort (GetWindowPort (window_ptr));                    SetPort (GetWindowPort (window_ptr));
# Line 12782  XTread_socket (int sd, struct input_even Line 12782  XTread_socket (int sd, struct input_even
12782                                                &control_part_code);                                                &control_part_code);
12783  #else  #else
12784                    control_part_code = FindControl (mouse_loc, window_ptr, &ch);                    control_part_code = FindControl (mouse_loc, window_ptr, &ch);
12785  #endif              #endif
12786    
12787  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12788                    bufp->code = mac_get_mouse_btn (eventRef);                    bufp->code = mac_get_mouse_btn (eventRef);
12789  #else              #else
12790                    bufp->code = 0;  /* only one mouse button */                    bufp->code = 0;  /* only one mouse button */
12791  #endif  #endif
12792                    XSETINT (bufp->x, mouse_loc.h);                    XSETINT (bufp->x, mouse_loc.h);
# Line 12794  XTread_socket (int sd, struct input_even Line 12794  XTread_socket (int sd, struct input_even
12794                    bufp->timestamp = er.when * (1000 / 60);                    bufp->timestamp = er.when * (1000 / 60);
12795                      /* ticks to milliseconds */                      /* ticks to milliseconds */
12796    
12797  #if TARGET_API_MAC_CARBON                  #if TARGET_API_MAC_CARBON
12798                    if (ch != 0)                    if (ch != 0)
12799  #else  #else
12800                    if (control_part_code != 0)                    if (control_part_code != 0)
# Line 12827  XTread_socket (int sd, struct input_even Line 12827  XTread_socket (int sd, struct input_even
12827                        else                        else
12828                          mouse_tracking_in_progress = mouse_tracking_none;                          mouse_tracking_in_progress = mouse_tracking_none;
12829                      }                      }
12830                                    
12831  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12832                    bufp->modifiers = mac_event_to_emacs_modifiers (eventRef);                    bufp->modifiers = mac_event_to_emacs_modifiers (eventRef);
12833  #else  #else
# Line 12843  XTread_socket (int sd, struct input_even Line 12843  XTread_socket (int sd, struct input_even
12843                        bufp->modifiers |= up_modifier;                        bufp->modifiers |= up_modifier;
12844                        break;                        break;
12845                      }                      }
12846                                                                    
12847                    count++;                    count++;
12848                  }                  }
12849                break;                break;
# Line 12852  XTread_socket (int sd, struct input_even Line 12852  XTread_socket (int sd, struct input_even
12852  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
12853                {                {
12854                  BitMap bm;                  BitMap bm;
12855                    
12856                  GetQDGlobalsScreenBits (&bm);                  GetQDGlobalsScreenBits (&bm);
12857                  DragWindow (window_ptr, er.where, &bm.bounds);                  DragWindow (window_ptr, er.where, &bm.bounds);
12858                }                }
# Line 12875  XTread_socket (int sd, struct input_even Line 12875  XTread_socket (int sd, struct input_even
12875              case inGrow:              case inGrow:
12876                do_grow_window(window_ptr, &er);                do_grow_window(window_ptr, &er);
12877                break;                break;
12878                
12879              /* window zoom handling added --ben */              /* window zoom handling added --ben */
12880              case inZoomIn:              case inZoomIn:
12881              case inZoomOut:              case inZoomOut:
# Line 12888  XTread_socket (int sd, struct input_even Line 12888  XTread_socket (int sd, struct input_even
12888              }              }
12889          }          }
12890          break;          break;
12891            
12892        case updateEvt:        case updateEvt:
12893        case osEvt:        case osEvt:
12894        case activateEvt:        case activateEvt:
12895  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12896          if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()))          if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()))
12897  #endif    #endif
12898          do_events (&er);          do_events (&er);
12899          break;          break;
12900            
12901        case keyDown:        case keyDown:
12902        case autoKey:        case autoKey:
12903          {          {
12904            int keycode = (er.message & keyCodeMask) >> 8;            int keycode = (er.message & keyCodeMask) >> 8;
12905            int xkeysym;            int xkeysym;
12906              
12907  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
12908            /* When using Carbon Events, we need to pass raw keyboard events            /* When using Carbon Events, we need to pass raw keyboard events
12909               to the TSM ourselves.  If TSM handles it, it will pass back               to the TSM ourselves.  If TSM handles it, it will pass back
# Line 12921  XTread_socket (int sd, struct input_even Line 12921  XTread_socket (int sd, struct input_even
12921                  break;                  break;
12922              }              }
12923  #endif  #endif
12924              
12925            if (!IsValidWindowPtr (FrontNonFloatingWindow ()))            if (!IsValidWindowPtr (FrontNonFloatingWindow ()))
12926              {              {
12927                SysBeep (1);                SysBeep (1);
12928                UNBLOCK_INPUT;                UNBLOCK_INPUT;
12929                return 0;                return 0;
12930              }              }
12931              
12932            ObscureCursor ();            ObscureCursor ();
12933              
12934            if (keycode_to_xkeysym (keycode, &xkeysym))            if (keycode_to_xkeysym (keycode, &xkeysym))
12935              {              {
12936                bufp->code = 0xff00 | xkeysym;                bufp->code = 0xff00 | xkeysym;
12937                bufp->kind = NON_ASCII_KEYSTROKE_EVENT;                bufp->kind = NON_ASCII_KEYSTROKE_EVENT;
12938              }                    }
12939            else            else
12940              {              {
12941                if (er.modifiers & (controlKey |                if (er.modifiers & (controlKey |
12942                                    (NILP (Vmac_command_key_is_meta) ? optionKey                                    (NILP (Vmac_command_key_is_meta) ? optionKey
12943                                     : cmdKey)))                                     : cmdKey)))
12944                  {                  {
12945                    /* This code comes from Keyboard Resource, Appendix                    /* This code comes from Keyboard Resource, Appendix
12946                       C of IM - Text.  This is necessary since shift is                       C of IM - Text.  This is necessary since shift is
12947                       ignored in KCHR table translation when option or                       ignored in KCHR table translation when option or
12948                       command is pressed.  It also does not translate                       command is pressed.  It also does not translate
12949                       correctly control-shift chars like C-% so mask off                       correctly control-shift chars like C-% so mask off
12950                       shift here also */                       shift here also */
12951                    int new_modifiers = er.modifiers & 0xe600;                    int new_modifiers = er.modifiers & 0xe600;
# Line 12961  XTread_socket (int sd, struct input_even Line 12961  XTread_socket (int sd, struct input_even
12961                bufp->kind = ASCII_KEYSTROKE_EVENT;                bufp->kind = ASCII_KEYSTROKE_EVENT;
12962              }              }
12963          }          }
12964            
12965          /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil,          /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil,
12966             convert non-ASCII characters typed at the Mac keyboard             convert non-ASCII characters typed at the Mac keyboard
12967             (presumed to be in the Mac Roman encoding) to iso-latin-1             (presumed to be in the Mac Roman encoding) to iso-latin-1
# Line 12974  XTread_socket (int sd, struct input_even Line 12974  XTread_socket (int sd, struct input_even
12974              static TECObjectRef converter = NULL;              static TECObjectRef converter = NULL;
12975              OSStatus the_err = noErr;              OSStatus the_err = noErr;
12976              OSStatus convert_status = noErr;              OSStatus convert_status = noErr;
12977                
12978              if (converter ==  NULL)              if (converter ==  NULL)
12979                {                {
12980                  the_err = TECCreateConverter (&converter,                  the_err = TECCreateConverter (&converter,
# Line 12994  XTread_socket (int sd, struct input_even Line 12994  XTread_socket (int sd, struct input_even
12994                                                mac_keyboard_text_encoding);                                                mac_keyboard_text_encoding);
12995                  current_mac_keyboard_text_encoding                  current_mac_keyboard_text_encoding
12996                    = mac_keyboard_text_encoding;                    = mac_keyboard_text_encoding;
12997                }                }
12998                
12999              if (the_err == noErr)              if (the_err == noErr)
13000                {                {
13001                  unsigned char ch = bufp->code;                  unsigned char ch = bufp->code;
13002                  ByteCount actual_input_length, actual_output_length;                  ByteCount actual_input_length, actual_output_length;
13003                  unsigned char outch;                  unsigned char outch;
13004                    
13005                  convert_status = TECConvertText (converter, &ch, 1,                  convert_status = TECConvertText (converter, &ch, 1,
13006                                                   &actual_input_length,                                                   &actual_input_length,
13007                                                   &outch, 1,                                                   &outch, 1,
# Line 13012  XTread_socket (int sd, struct input_even Line 13012  XTread_socket (int sd, struct input_even
13012                    bufp->code = outch;                    bufp->code = outch;
13013                }                }
13014            }            }
13015            
13016  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
13017          bufp->modifiers = mac_event_to_emacs_modifiers (eventRef);          bufp->modifiers = mac_event_to_emacs_modifiers (eventRef);
13018  #else  #else
13019          bufp->modifiers = mac_to_emacs_modifiers (er.modifiers);          bufp->modifiers = mac_to_emacs_modifiers (er.modifiers);
13020  #endif  #endif
13021            
13022          {          {
13023            mac_output *mwp            mac_output *mwp
13024              = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());              = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
13025            XSETFRAME (bufp->frame_or_window, mwp->mFP);            XSETFRAME (bufp->frame_or_window, mwp->mFP);
13026          }          }
13027            
13028          bufp->timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */          bufp->timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
13029    
13030          count++;          count++;
# Line 13034  XTread_socket (int sd, struct input_even Line 13034  XTread_socket (int sd, struct input_even
13034          drag_and_drop_file_list = Qnil;          drag_and_drop_file_list = Qnil;
13035    
13036          AEProcessAppleEvent(&er);          AEProcessAppleEvent(&er);
13037            
13038          /* Build a DRAG_N_DROP_EVENT type event as is done in          /* Build a DRAG_N_DROP_EVENT type event as is done in
13039             constuct_drag_n_drop in w32term.c.  */             constuct_drag_n_drop in w32term.c.  */
13040          if (!NILP (drag_and_drop_file_list))          if (!NILP (drag_and_drop_file_list))
# Line 13044  XTread_socket (int sd, struct input_even Line 13044  XTread_socket (int sd, struct input_even
13044              Lisp_Object frame;              Lisp_Object frame;
13045    
13046              wp = FrontNonFloatingWindow ();              wp = FrontNonFloatingWindow ();
13047                
13048              if (!wp)              if (!wp)
13049                {                {
13050                  struct frame *f = XFRAME (XCAR (Vframe_list));                  struct frame *f = XFRAME (XCAR (Vframe_list));
# Line 13053  XTread_socket (int sd, struct input_even Line 13053  XTread_socket (int sd, struct input_even
13053                }                }
13054    
13055              if (wp && is_emacs_window(wp))              if (wp && is_emacs_window(wp))
13056                  f = ((mac_output *) GetWRefCon (wp))->mFP;                              f = ((mac_output *) GetWRefCon (wp))->mFP;
13057    
13058              bufp->kind = DRAG_N_DROP_EVENT;              bufp->kind = DRAG_N_DROP_EVENT;
13059              bufp->code = 0;              bufp->code = 0;
# Line 13079  XTread_socket (int sd, struct input_even Line 13079  XTread_socket (int sd, struct input_even
13079  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
13080                {                {
13081                  Rect r;                  Rect r;
13082                    
13083                  GetWindowPortBounds (wp, &r);                  GetWindowPortBounds (wp, &r);
13084                  InvalWindowRect (wp, &r);                  InvalWindowRect (wp, &r);
13085                }                }
13086  #else /* not TARGET_API_MAC_CARBON */  #else /* not TARGET_API_MAC_CARBON */
13087                InvalRect (&(wp->portRect));                InvalRect (&(wp->portRect));
13088  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
13089                
13090              count++;              count++;
13091            }            }
13092        default:        default:
# Line 13112  XTread_socket (int sd, struct input_even Line 13112  XTread_socket (int sd, struct input_even
13112    
13113    {    {
13114      static Point old_mouse_pos = { -1, -1 };      static Point old_mouse_pos = { -1, -1 };
13115        
13116      if (app_is_suspended)      if (app_is_suspended)
13117        {        {
13118          old_mouse_pos.h = -1;          old_mouse_pos.h = -1;
# Line 13124  XTread_socket (int sd, struct input_even Line 13124  XTread_socket (int sd, struct input_even
13124          WindowPtr wp;          WindowPtr wp;
13125          struct frame *f;          struct frame *f;
13126          Lisp_Object bar;          Lisp_Object bar;
13127          struct scroll_bar *sb;                  struct scroll_bar *sb;
13128    
13129          wp = FrontWindow ();          wp = FrontWindow ();
13130          if (is_emacs_window (wp))          if (is_emacs_window (wp))
# Line 13149  XTread_socket (int sd, struct input_even Line 13149  XTread_socket (int sd, struct input_even
13149                                                TickCount() * (1000 / 60));                                                TickCount() * (1000 / 60));
13150                  else                  else
13151                    note_mouse_movement (f, &mouse_pos);                    note_mouse_movement (f, &mouse_pos);
13152                    
13153                  old_mouse_pos = mouse_pos;                              old_mouse_pos = mouse_pos;
13154                }                }
13155            }            }
13156        }        }
13157    }    }
13158      
13159    UNBLOCK_INPUT;    UNBLOCK_INPUT;
13160      
13161    return count;    return count;
13162  }  }
13163    
# Line 13206  NewMacWindow (FRAME_PTR fp) Line 13206  NewMacWindow (FRAME_PTR fp)
13206    else    else
13207      if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))      if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
13208        abort ();        abort ();
13209      
13210    SetWRefCon (mwp->mWP, (long) mwp);    SetWRefCon (mwp->mWP, (long) mwp);
13211      /* so that update events can find this mac_output struct */      /* so that update events can find this mac_output struct */
13212    mwp->mFP = fp;  /* point back to emacs frame */    mwp->mFP = fp;  /* point back to emacs frame */
# Line 13218  NewMacWindow (FRAME_PTR fp) Line 13218  NewMacWindow (FRAME_PTR fp)
13218  #endif  #endif
13219    
13220    mwp->fontset = -1;    mwp->fontset = -1;
13221            
13222    SizeWindow (mwp->mWP, mwp->pixel_width, mwp->pixel_height, false);    SizeWindow (mwp->mWP, mwp->pixel_width, mwp->pixel_height, false);
13223    ShowWindow (mwp->mWP);    ShowWindow (mwp->mWP);
13224            
13225  }  }
13226    
13227    
# Line 13232  make_mac_frame (struct frame *f) Line 13232  make_mac_frame (struct frame *f)
13232    FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;    FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
13233    
13234    FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;    FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
13235    
13236    NewMacWindow(f);    NewMacWindow(f);
13237    
13238    f->output_data.mac->cursor_pixel = 0;    f->output_data.mac->cursor_pixel = 0;
# Line 13247  make_mac_frame (struct frame *f) Line 13247  make_mac_frame (struct frame *f)
13247    f->output_data.mac->top_pos = 4;    f->output_data.mac->top_pos = 4;
13248    f->output_data.mac->border_width = 0;    f->output_data.mac->border_width = 0;
13249    f->output_data.mac->explicit_parent = 0;    f->output_data.mac->explicit_parent = 0;
13250      
13251    f->output_data.mac->internal_border_width = 0;    f->output_data.mac->internal_border_width = 0;
13252    
13253    f->output_method = output_mac;    f->output_method = output_mac;
13254    
13255    f->auto_raise = 1;    f->auto_raise = 1;
13256    f->auto_lower = 1;    f->auto_lower = 1;
13257      
13258    f->new_width = 0;    f->new_width = 0;
13259    f->new_height = 0;    f->new_height = 0;
13260  }  }
# Line 13273  make_mac_terminal_frame (struct frame *f Line 13273  make_mac_terminal_frame (struct frame *f
13273    f->output_data.mac->fontset = -1;    f->output_data.mac->fontset = -1;
13274    f->output_data.mac->scroll_bar_foreground_pixel = -1;    f->output_data.mac->scroll_bar_foreground_pixel = -1;
13275    f->output_data.mac->scroll_bar_background_pixel = -1;    f->output_data.mac->scroll_bar_background_pixel = -1;
13276      
13277    XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);    XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
13278    
13279    f->width = 96;    f->width = 96;
# Line 13282  make_mac_terminal_frame (struct frame *f Line 13282  make_mac_terminal_frame (struct frame *f
13282    make_mac_frame (f);    make_mac_frame (f);
13283    
13284    x_make_gc (f);    x_make_gc (f);
13285      
13286    /* Need to be initialized for unshow_buffer in window.c.  */    /* Need to be initialized for unshow_buffer in window.c.  */
13287    selected_window = f->selected_window;    selected_window = f->selected_window;
13288    
# Line 13384  mac_initialize_display_info () Line 13384  mac_initialize_display_info ()
13384    x_display_name_list = Fcons (Fcons (build_string ("Mac"), Qnil),    x_display_name_list = Fcons (Fcons (build_string ("Mac"), Qnil),
13385                                 x_display_name_list);                                 x_display_name_list);
13386    dpyinfo->name_list_element = XCAR (x_display_name_list);    dpyinfo->name_list_element = XCAR (x_display_name_list);
13387      
13388  #if 0  #if 0
13389    dpyinfo->mac_id_name    dpyinfo->mac_id_name
13390      = (char *) xmalloc (SCHARS (Vinvocation_name)      = (char *) xmalloc (SCHARS (Vinvocation_name)
# Line 13478  MakeMeTheFrontProcess () Line 13478  MakeMeTheFrontProcess ()
13478  {  {
13479    ProcessSerialNumber psn;    ProcessSerialNumber psn;
13480    OSErr err;    OSErr err;
13481      
13482    err = GetCurrentProcess (&psn);    err = GetCurrentProcess (&psn);
13483    if (err == noErr)    if (err == noErr)
13484      (void) SetFrontProcess (&psn);      (void) SetFrontProcess (&psn);
# Line 13512  init_quit_char_handler () Line 13512  init_quit_char_handler ()
13512    mac_quit_char_keycode = 5;    mac_quit_char_keycode = 5;
13513    /* Look at <architecture/adb_kb_map.h> for details */    /* Look at <architecture/adb_kb_map.h> for details */
13514    /* http://gemma.apple.com/techpubs/mac/Toolbox/Toolbox-40.html#MARKER-9-184*/    /* http://gemma.apple.com/techpubs/mac/Toolbox/Toolbox-40.html#MARKER-9-184*/
13515      
13516    mac_determine_quit_char_modifiers();    mac_determine_quit_char_modifiers();
13517  }  }
13518    
# Line 13526  quit_char_comp (EventRef inEvent, void * Line 13526  quit_char_comp (EventRef inEvent, void *
13526    {    {
13527      UInt32 keyCode;      UInt32 keyCode;
13528      UInt32 keyModifiers;      UInt32 keyModifiers;
13529      GetEventParameter(inEvent, kEventParamKeyCode,      GetEventParameter(inEvent, kEventParamKeyCode,
13530                        typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);                        typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
13531      if (keyCode != mac_quit_char_keycode)      if (keyCode != mac_quit_char_keycode)
13532        return false;        return false;
13533      GetEventParameter(inEvent, kEventParamKeyModifiers,      GetEventParameter(inEvent, kEventParamKeyModifiers,
13534                        typeUInt32, NULL, sizeof(UInt32), NULL, &keyModifiers);                        typeUInt32, NULL, sizeof(UInt32), NULL, &keyModifiers);
13535      if (keyModifiers != mac_quit_char_modifiers)      if (keyModifiers != mac_quit_char_modifiers)
13536        return false;        return false;
# Line 13552  mac_check_for_quit_char() Line 13552  mac_check_for_quit_char()
13552    /* Fill the queue with events */    /* Fill the queue with events */
13553    ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);    ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);
13554    event = FindSpecificEventInQueue (GetMainEventQueue(), quit_char_comp, NULL);    event = FindSpecificEventInQueue (GetMainEventQueue(), quit_char_comp, NULL);
13555    if (event)    if (event)
13556      {      {
13557        struct input_event e;        struct input_event e;
13558        struct mac_output *mwp = (mac_output*) GetWRefCon (FrontNonFloatingWindow ());        struct mac_output *mwp = (mac_output*) GetWRefCon (FrontNonFloatingWindow ());
# Line 13629  mac_initialize () Line 13629  mac_initialize ()
13629    x_noop_count = 0;    x_noop_count = 0;
13630    last_tool_bar_item = -1;    last_tool_bar_item = -1;
13631    any_help_event_p = 0;    any_help_event_p = 0;
13632      
13633    /* Try to use interrupt input; if we can't, then start polling.  */    /* Try to use interrupt input; if we can't, then start polling.  */
13634    Fset_input_mode (Qt, Qnil, Qt, Qnil);    Fset_input_mode (Qt, Qnil, Qt, Qnil);
13635    
# Line 13649  mac_initialize () Line 13649  mac_initialize ()
13649      start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);      start_atimer (ATIMER_CONTINUOUS, interval, x_process_timeouts, 0);
13650    }    }
13651  #endif  #endif
13652      
13653  #if USE_TOOLKIT_SCROLL_BARS  #if USE_TOOLKIT_SCROLL_BARS
13654    xaw3d_arrow_scroll = False;    xaw3d_arrow_scroll = False;
13655    xaw3d_pick_top = True;    xaw3d_pick_top = True;
# Line 13751  to 4.1, set this to nil.  */); Line 13751  to 4.1, set this to nil.  */);
13751    
13752    staticpro (&last_mouse_motion_frame);    staticpro (&last_mouse_motion_frame);
13753    last_mouse_motion_frame = Qnil;    last_mouse_motion_frame = Qnil;
13754      
13755    DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,    DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,
13756      doc: /* Non-nil means that the command key is used as the Emacs meta key.      doc: /* Non-nil means that the command key is used as the Emacs meta key.
13757  Otherwise the option key is used.  */);  Otherwise the option key is used.  */);

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26