comparison src/macterm.c @ 90261:7beb78bc1f8e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-97 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 616-696) - Add lisp/mh-e/.arch-inventory - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. - lisp/gnus/ChangeLog: Remove duplicate entry * gnus--rel--5.10 (patch 147-181) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: lisp/mml.el (mml-preview): Doc fix. - Update from CVS: texi/message.texi: Fix default values. - Update from CVS: texi/gnus.texi (RSS): Addition.
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 08:37:27 +0000
parents 0ca0d9181b5e d88b44855af3
children c5406394f567
comparison
equal deleted inserted replaced
90260:0ca0d9181b5e 90261:7beb78bc1f8e
66 66
67 #include <ctype.h> 67 #include <ctype.h>
68 #include <errno.h> 68 #include <errno.h>
69 #include <setjmp.h> 69 #include <setjmp.h>
70 #include <sys/stat.h> 70 #include <sys/stat.h>
71 #include <sys/param.h>
72 71
73 #include "charset.h" 72 #include "charset.h"
74 #include "coding.h" 73 #include "coding.h"
75 #include "frame.h" 74 #include "frame.h"
76 #include "dispextern.h" 75 #include "dispextern.h"
87 #include "atimer.h" 86 #include "atimer.h"
88 #include "keymap.h" 87 #include "keymap.h"
89 #include "character.h" 88 #include "character.h"
90 #include "ccl.h" 89 #include "ccl.h"
91 90
92 /* Set of macros that handle mapping of Mac modifier keys to emacs. */
93 #define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \
94 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey))
95 #define macShiftKey (shiftKey)
96 #define macMetaKey (NILP (Vmac_reverse_ctrl_meta) ? \
97 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \
98 : controlKey)
99 #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
100 91
101 92
102 /* Non-nil means Emacs uses toolkit scroll bars. */ 93 /* Non-nil means Emacs uses toolkit scroll bars. */
103 94
104 Lisp_Object Vx_toolkit_scroll_bars; 95 Lisp_Object Vx_toolkit_scroll_bars;
105 96
106 /* If Non-nil, the text will be rendered using Core Graphics text rendering which may anti-alias the text. */ 97 /* If non-zero, the text will be rendered using Core Graphics text
107 Lisp_Object Vmac_use_core_graphics; 98 rendering which may anti-alias the text. */
99 int mac_use_core_graphics;
108 100
109 101
110 /* Non-zero means that a HELP_EVENT has been generated since Emacs 102 /* Non-zero means that a HELP_EVENT has been generated since Emacs
111 start. */ 103 start. */
112 104
113 static int any_help_event_p; 105 static int any_help_event_p;
114 106
115 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */ 107 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */
116 static Lisp_Object last_window; 108 static Lisp_Object last_window;
109
110 /* Non-zero means make use of UNDERLINE_POSITION font properties.
111 (Not yet supported.) */
112 int x_use_underline_position_properties;
117 113
118 /* This is a chain of structures for all the X displays currently in 114 /* This is a chain of structures for all the X displays currently in
119 use. */ 115 use. */
120 116
121 struct x_display_info *x_display_list; 117 struct x_display_info *x_display_list;
165 is off. */ 161 is off. */
166 162
167 /* Where the mouse was last time we reported a mouse event. */ 163 /* Where the mouse was last time we reported a mouse event. */
168 164
169 static Rect last_mouse_glyph; 165 static Rect last_mouse_glyph;
166 static FRAME_PTR last_mouse_glyph_frame;
170 167
171 /* The scroll bar in which the last X motion event occurred. 168 /* The scroll bar in which the last X motion event occurred.
172 169
173 If the last X motion event occurred in a scroll bar, we set this so 170 If the last X motion event occurred in a scroll bar, we set this so
174 XTmouse_position can know whether to report a scroll bar motion or 171 XTmouse_position can know whether to report a scroll bar motion or
206 203
207 extern EMACS_INT extra_keyboard_modifiers; 204 extern EMACS_INT extra_keyboard_modifiers;
208 205
209 /* The keysyms to use for the various modifiers. */ 206 /* The keysyms to use for the various modifiers. */
210 207
211 static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; 208 static Lisp_Object Qalt, Qhyper, Qsuper, Qcontrol, Qmeta, Qmodifier_value;
212 209
213 extern int inhibit_window_system; 210 extern int inhibit_window_system;
214 211
215 #if __MRC__ && !TARGET_API_MAC_CARBON 212 #if __MRC__ && !TARGET_API_MAC_CARBON
216 QDGlobals qd; /* QuickDraw global information structure. */ 213 QDGlobals qd; /* QuickDraw global information structure. */
261 enum scroll_bar_part *, 258 enum scroll_bar_part *,
262 Lisp_Object *, Lisp_Object *, 259 Lisp_Object *, Lisp_Object *,
263 unsigned long *)); 260 unsigned long *));
264 261
265 static int is_emacs_window P_ ((WindowPtr)); 262 static int is_emacs_window P_ ((WindowPtr));
266 263 static XCharStruct *mac_per_char_metric P_ ((XFontStruct *, XChar2b *, int));
267 static void XSetFont P_ ((Display *, GC, XFontStruct *)); 264 static void XSetFont P_ ((Display *, GC, XFontStruct *));
268 265
269 /* Defined in macmenu.h. */ 266 /* Defined in macmenu.h. */
270 extern void menubar_selection_callback (FRAME_PTR, int); 267 extern void menubar_selection_callback (FRAME_PTR, int);
271 268
628 UniCharCount lengths[] = {kATSUToTextEnd}; 625 UniCharCount lengths[] = {kATSUToTextEnd};
629 ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag}; 626 ATSUAttributeTag tags[] = {kATSULineLayoutOptionsTag};
630 ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; 627 ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)};
631 static ATSLineLayoutOptions line_layout = 628 static ATSLineLayoutOptions line_layout =
632 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 629 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
633 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics 630 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics
631 | kATSLineUseQDRendering
634 #else 632 #else
635 kATSLineIsDisplayOnly | kATSLineFractDisable 633 kATSLineIsDisplayOnly | kATSLineFractDisable
636 #endif 634 #endif
637 ; 635 ;
638 ATSUAttributeValuePtr values[] = {&line_layout}; 636 ATSUAttributeValuePtr values[] = {&line_layout};
693 char *buf; 691 char *buf;
694 int nchars, mode, bytes_per_char; 692 int nchars, mode, bytes_per_char;
695 { 693 {
696 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 694 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
697 UInt32 textFlags, savedFlags; 695 UInt32 textFlags, savedFlags;
698 if (!NILP(Vmac_use_core_graphics)) { 696 if (mac_use_core_graphics) {
699 textFlags = kQDUseCGTextRendering; 697 textFlags = kQDUseCGTextRendering;
700 savedFlags = SwapQDTextFlags(textFlags); 698 savedFlags = SwapQDTextFlags(textFlags);
701 } 699 }
702 #endif 700 #endif
703 701
716 xassert (bytes_per_char == 2); 714 xassert (bytes_per_char == 2);
717 715
718 #ifndef WORDS_BIG_ENDIAN 716 #ifndef WORDS_BIG_ENDIAN
719 { 717 {
720 int i; 718 int i;
721 Unichar *text = (Unichar *)buf; 719 UniChar *text = (UniChar *)buf;
722 720
723 for (i = 0; i < nchars; i++) 721 for (i = 0; i < nchars; i++)
724 text[i] = buf[2*i] << 8 | buf[2*i+1]; 722 text[i] = EndianU16_BtoN (text[i]);
725 } 723 }
726 #endif 724 #endif
727 err = atsu_get_text_layout_with_text_ptr ((ConstUniCharArrayPtr)buf, 725 err = atsu_get_text_layout_with_text_ptr ((ConstUniCharArrayPtr)buf,
728 nchars, 726 nchars,
729 GC_FONT (gc)->mac_style, 727 GC_FONT (gc)->mac_style,
730 &text_layout); 728 &text_layout);
731 if (err == noErr) 729 if (err == noErr)
732 { 730 {
733 #ifdef MAC_OSX 731 #ifdef MAC_OSX
734 if (NILP (Vmac_use_core_graphics)) 732 if (!mac_use_core_graphics)
735 { 733 {
736 #endif 734 #endif
737 mac_begin_clip (GC_CLIP_REGION (gc)); 735 mac_begin_clip (GC_CLIP_REGION (gc));
738 MoveTo (x, y); 736 MoveTo (x, y);
739 ATSUDrawText (text_layout, 737 ATSUDrawText (text_layout,
773 tags, sizes, values); 771 tags, sizes, values);
774 if (err == noErr) 772 if (err == noErr)
775 ATSUDrawText (text_layout, 773 ATSUDrawText (text_layout,
776 kATSUFromTextBeginning, kATSUToTextEnd, 774 kATSUFromTextBeginning, kATSUToTextEnd,
777 Long2Fix (x), Long2Fix (port_height - y)); 775 Long2Fix (x), Long2Fix (port_height - y));
776 CGContextSynchronize (context);
777 QDEndCGContext (port, &context);
778 #if 0
779 /* This doesn't work on Mac OS X 10.1. */
778 ATSUClearLayoutControls (text_layout, 780 ATSUClearLayoutControls (text_layout,
779 sizeof (tags) / sizeof (tags[0]), 781 sizeof (tags) / sizeof (tags[0]),
780 tags); 782 tags);
781 CGContextSynchronize (context); 783 #else
782 QDEndCGContext (port, &context); 784 ATSUSetLayoutControls (text_layout,
785 sizeof (tags) / sizeof (tags[0]),
786 tags, sizes, values);
787 #endif
783 } 788 }
784 #endif 789 #endif
785 } 790 }
786 } 791 }
787 else 792 else
801 #endif 806 #endif
802 807
803 if (mode != srcOr) 808 if (mode != srcOr)
804 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); 809 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
805 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 810 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
806 if (!NILP(Vmac_use_core_graphics)) 811 if (mac_use_core_graphics)
807 SwapQDTextFlags(savedFlags); 812 SwapQDTextFlags(savedFlags);
808 #endif 813 #endif
809 } 814 }
810 815
811 816
861 XChar2b *buf; 866 XChar2b *buf;
862 int nchars; 867 int nchars;
863 { 868 {
864 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2); 869 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
865 } 870 }
871
872
873 /* Mac replacement for XQueryTextExtents, but takes a character. If
874 STYLE is NULL, measurement is done by QuickDraw Text routines for
875 the font of the current graphics port. If CG_GLYPH is not NULL,
876 *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */
877
878 static OSErr
879 mac_query_char_extents (style, c,
880 font_ascent_return, font_descent_return,
881 overall_return, cg_glyph)
882 #if USE_ATSUI
883 ATSUStyle style;
884 #else
885 void *style;
886 #endif
887 int c;
888 int *font_ascent_return, *font_descent_return;
889 XCharStruct *overall_return;
890 #if USE_CG_TEXT_DRAWING
891 CGGlyph *cg_glyph;
892 #else
893 void *cg_glyph;
894 #endif
895 {
896 OSErr err = noErr;
897 int width;
898 Rect char_bounds;
899
900 #if USE_ATSUI
901 if (style)
902 {
903 ATSUTextLayout text_layout;
904 UniChar ch = c;
905
906 err = atsu_get_text_layout_with_text_ptr (&ch, 1, style, &text_layout);
907 if (err == noErr)
908 {
909 ATSTrapezoid glyph_bounds;
910
911 err = ATSUGetGlyphBounds (text_layout, 0, 0,
912 kATSUFromTextBeginning, kATSUToTextEnd,
913 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
914 kATSUseFractionalOrigins,
915 #else
916 kATSUseDeviceOrigins,
917 #endif
918 1, &glyph_bounds, NULL);
919 if (err == noErr)
920 {
921 xassert (glyph_bounds.lowerRight.x - glyph_bounds.lowerLeft.x
922 == glyph_bounds.upperRight.x - glyph_bounds.upperLeft.x);
923
924 width = Fix2Long (glyph_bounds.upperRight.x
925 - glyph_bounds.upperLeft.x);
926 if (font_ascent_return)
927 *font_ascent_return = -Fix2Long (glyph_bounds.upperLeft.y);
928 if (font_descent_return)
929 *font_descent_return = Fix2Long (glyph_bounds.lowerLeft.y);
930 }
931 }
932 if (err == noErr && overall_return)
933 {
934 err = ATSUMeasureTextImage (text_layout,
935 kATSUFromTextBeginning, kATSUToTextEnd,
936 0, 0, &char_bounds);
937 if (err == noErr)
938 STORE_XCHARSTRUCT (*overall_return, width, char_bounds);
939 #if USE_CG_TEXT_DRAWING
940 if (err == noErr && cg_glyph)
941 {
942 OSErr err1;
943 ATSUGlyphInfoArray glyph_info_array;
944 ByteCount count = sizeof (ATSUGlyphInfoArray);
945
946 err1 = ATSUMatchFontsToText (text_layout, kATSUFromTextBeginning,
947 kATSUToTextEnd, NULL, NULL, NULL);
948 if (err1 == noErr)
949 err1 = ATSUGetGlyphInfo (text_layout, kATSUFromTextBeginning,
950 kATSUToTextEnd, &count,
951 &glyph_info_array);
952 if (err1 == noErr)
953 {
954 xassert (glyph_info_array.glyphs[0].glyphID);
955 *cg_glyph = glyph_info_array.glyphs[0].glyphID;
956 }
957 else
958 *cg_glyph = 0;
959 }
960 #endif
961 }
962 }
963 else
964 #endif
965 {
966 if (font_ascent_return || font_descent_return)
967 {
968 FontInfo font_info;
969
970 GetFontInfo (&font_info);
971 if (font_ascent_return)
972 *font_ascent_return = font_info.ascent;
973 if (font_descent_return)
974 *font_descent_return = font_info.descent;
975 }
976 if (overall_return)
977 {
978 char ch = c;
979
980 width = CharWidth (ch);
981 QDTextBounds (1, &ch, &char_bounds);
982 STORE_XCHARSTRUCT (*overall_return, width, char_bounds);
983 }
984 }
985
986 return err;
987 }
988
989
990 /* Mac replacement for XTextExtents16. Only sets horizontal metrics. */
991
992 static int
993 mac_text_extents_16 (font_struct, string, nchars, overall_return)
994 XFontStruct *font_struct;
995 XChar2b *string;
996 int nchars;
997 XCharStruct *overall_return;
998 {
999 int i;
1000 short width = 0, lbearing = 0, rbearing = 0;
1001 XCharStruct *pcm;
1002
1003 for (i = 0; i < nchars; i++)
1004 {
1005 pcm = mac_per_char_metric (font_struct, string, 0);
1006 if (pcm == NULL)
1007 width += FONT_WIDTH (font_struct);
1008 else
1009 {
1010 lbearing = min (lbearing, width + pcm->lbearing);
1011 rbearing = max (rbearing, width + pcm->rbearing);
1012 width += pcm->width;
1013 }
1014 string++;
1015 }
1016
1017 overall_return->lbearing = lbearing;
1018 overall_return->rbearing = rbearing;
1019 overall_return->width = width;
1020
1021 /* What's the meaning of the return value of XTextExtents16? */
1022 }
1023
1024
1025 #if USE_CG_TEXT_DRAWING
1026 static int cg_text_anti_aliasing_threshold = 8;
1027
1028 static void
1029 init_cg_text_anti_aliasing_threshold ()
1030 {
1031 Lisp_Object val =
1032 Fmac_get_preference (build_string ("AppleAntiAliasingThreshold"),
1033 Qnil, Qnil, Qnil);
1034
1035 if (INTEGERP (val))
1036 cg_text_anti_aliasing_threshold = XINT (val);
1037 }
1038
1039 static int
1040 mac_draw_string_cg (f, gc, x, y, buf, nchars)
1041 struct frame *f;
1042 GC gc;
1043 int x, y;
1044 XChar2b *buf;
1045 int nchars;
1046 {
1047 CGrafPtr port;
1048 float port_height, gx, gy;
1049 int i;
1050 CGContextRef context;
1051 CGGlyph *glyphs;
1052 CGSize *advances;
1053
1054 if (!mac_use_core_graphics || GC_FONT (gc)->cg_font == NULL)
1055 return 0;
1056
1057 port = GetWindowPort (FRAME_MAC_WINDOW (f));
1058 port_height = FRAME_PIXEL_HEIGHT (f);
1059 gx = x;
1060 gy = port_height - y;
1061 glyphs = (CGGlyph *)buf;
1062 advances = xmalloc (sizeof (CGSize) * nchars);
1063 for (i = 0; i < nchars; i++)
1064 {
1065 XCharStruct *pcm = mac_per_char_metric (GC_FONT (gc), buf, 0);
1066
1067 advances[i].width = pcm->width;
1068 advances[i].height = 0;
1069 glyphs[i] = GC_FONT (gc)->cg_glyphs[buf->byte2];
1070 buf++;
1071 }
1072
1073 QDBeginCGContext (port, &context);
1074 if (gc->n_clip_rects)
1075 {
1076 CGContextTranslateCTM (context, 0, port_height);
1077 CGContextScaleCTM (context, 1, -1);
1078 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
1079 CGContextScaleCTM (context, 1, -1);
1080 CGContextTranslateCTM (context, 0, -port_height);
1081 }
1082 CGContextSetRGBFillColor (context,
1083 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
1084 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
1085 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
1086 1.0);
1087 CGContextSetFont (context, GC_FONT (gc)->cg_font);
1088 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
1089 if (GC_FONT (gc)->mac_fontsize <= cg_text_anti_aliasing_threshold)
1090 CGContextSetShouldAntialias (context, false);
1091 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
1092 CGContextSetTextPosition (context, gx, gy);
1093 CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars);
1094 #else
1095 for (i = 0; i < nchars; i++)
1096 {
1097 CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1);
1098 gx += advances[i].width;
1099 }
1100 #endif
1101 CGContextSynchronize (context);
1102 QDEndCGContext (port, &context);
1103
1104 xfree (advances);
1105
1106 return 1;
1107 }
1108 #endif
866 1109
867 1110
868 /* Mac replacement for XCopyArea: dest must be window. */ 1111 /* Mac replacement for XCopyArea: dest must be window. */
869 1112
870 static void 1113 static void
1634 xassert (font && char2b); 1877 xassert (font && char2b);
1635 1878
1636 #if USE_ATSUI 1879 #if USE_ATSUI
1637 if (font->mac_style) 1880 if (font->mac_style)
1638 { 1881 {
1639 if (char2b->byte1 >= font->min_byte1 1882 XCharStructRow **row = font->bounds.rows + char2b->byte1;
1640 && char2b->byte1 <= font->max_byte1 1883
1641 && char2b->byte2 >= font->min_char_or_byte2 1884 if (*row == NULL)
1642 && char2b->byte2 <= font->max_char_or_byte2)
1643 { 1885 {
1644 pcm = (font->per_char 1886 *row = xmalloc (sizeof (XCharStructRow));
1645 + ((font->max_char_or_byte2 - font->min_char_or_byte2 + 1) 1887 if (*row)
1646 * (char2b->byte1 - font->min_byte1)) 1888 bzero (*row, sizeof (XCharStructRow));
1647 + (char2b->byte2 - font->min_char_or_byte2));
1648 } 1889 }
1649 1890 if (*row)
1650 if (pcm && !pcm->valid_p)
1651 { 1891 {
1652 OSErr err; 1892 pcm = (*row)->per_char + char2b->byte2;
1653 ATSUTextLayout text_layout; 1893 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2))
1654 UniChar c;
1655 int char_width;
1656 ATSTrapezoid glyph_bounds;
1657 Rect char_bounds;
1658
1659 c = (char2b->byte1 << 8) + char2b->byte2;
1660 BLOCK_INPUT;
1661 err = atsu_get_text_layout_with_text_ptr (&c, 1,
1662 font->mac_style,
1663 &text_layout);
1664 if (err == noErr)
1665 err = ATSUMeasureTextImage (text_layout,
1666 kATSUFromTextBeginning, kATSUToTextEnd,
1667 0, 0, &char_bounds);
1668
1669 if (err == noErr)
1670 err = ATSUGetGlyphBounds (text_layout, 0, 0,
1671 kATSUFromTextBeginning, kATSUToTextEnd,
1672 kATSUseFractionalOrigins, 1,
1673 &glyph_bounds, NULL);
1674 UNBLOCK_INPUT;
1675 if (err != noErr)
1676 pcm = NULL;
1677 else
1678 { 1894 {
1679 xassert (glyph_bounds.lowerRight.x - glyph_bounds.lowerLeft.x 1895 BLOCK_INPUT;
1680 == glyph_bounds.upperRight.x - glyph_bounds.upperLeft.x); 1896 mac_query_char_extents (font->mac_style,
1681 1897 (char2b->byte1 << 8) + char2b->byte2,
1682 char_width = Fix2Long (glyph_bounds.upperRight.x 1898 NULL, NULL, pcm, NULL);
1683 - glyph_bounds.upperLeft.x); 1899 UNBLOCK_INPUT;
1684 STORE_XCHARSTRUCT (*pcm, char_width, char_bounds); 1900 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
1685 } 1901 }
1686 } 1902 }
1687 } 1903 }
1688 else 1904 else
1689 { 1905 {
1690 #endif 1906 #endif
1691 if (font->per_char != NULL) 1907 if (font->bounds.per_char != NULL)
1692 { 1908 {
1693 if (font->min_byte1 == 0 && font->max_byte1 == 0) 1909 if (font->min_byte1 == 0 && font->max_byte1 == 0)
1694 { 1910 {
1695 /* min_char_or_byte2 specifies the linear character index 1911 /* min_char_or_byte2 specifies the linear character index
1696 corresponding to the first element of the per_char array, 1912 corresponding to the first element of the per_char array,
1699 A character with byte2 less than min_char_or_byte2 or 1915 A character with byte2 less than min_char_or_byte2 or
1700 greater max_char_or_byte2 is not in the font. */ 1916 greater max_char_or_byte2 is not in the font. */
1701 if (char2b->byte1 == 0 1917 if (char2b->byte1 == 0
1702 && char2b->byte2 >= font->min_char_or_byte2 1918 && char2b->byte2 >= font->min_char_or_byte2
1703 && char2b->byte2 <= font->max_char_or_byte2) 1919 && char2b->byte2 <= font->max_char_or_byte2)
1704 pcm = font->per_char + char2b->byte2 - font->min_char_or_byte2; 1920 pcm = font->bounds.per_char
1921 + (char2b->byte2 - font->min_char_or_byte2);
1705 } 1922 }
1706 else 1923 else
1707 { 1924 {
1708 /* If either min_byte1 or max_byte1 are nonzero, both 1925 /* If either min_byte1 or max_byte1 are nonzero, both
1709 min_char_or_byte2 and max_char_or_byte2 are less than 1926 min_char_or_byte2 and max_char_or_byte2 are less than
1721 if (char2b->byte1 >= font->min_byte1 1938 if (char2b->byte1 >= font->min_byte1
1722 && char2b->byte1 <= font->max_byte1 1939 && char2b->byte1 <= font->max_byte1
1723 && char2b->byte2 >= font->min_char_or_byte2 1940 && char2b->byte2 >= font->min_char_or_byte2
1724 && char2b->byte2 <= font->max_char_or_byte2) 1941 && char2b->byte2 <= font->max_char_or_byte2)
1725 { 1942 {
1726 pcm = (font->per_char 1943 pcm = (font->bounds.per_char
1727 + ((font->max_char_or_byte2 - font->min_char_or_byte2 + 1) 1944 + ((font->max_char_or_byte2 - font->min_char_or_byte2 + 1)
1728 * (char2b->byte1 - font->min_byte1)) 1945 * (char2b->byte1 - font->min_byte1))
1729 + (char2b->byte2 - font->min_char_or_byte2)); 1946 + (char2b->byte2 - font->min_char_or_byte2));
1730 } 1947 }
1731 } 1948 }
2062 mac_compute_glyph_string_overhangs (s) 2279 mac_compute_glyph_string_overhangs (s)
2063 struct glyph_string *s; 2280 struct glyph_string *s;
2064 { 2281 {
2065 if (s->cmp == NULL 2282 if (s->cmp == NULL
2066 && s->first_glyph->type == CHAR_GLYPH) 2283 && s->first_glyph->type == CHAR_GLYPH)
2067 { 2284 if (!s->two_byte_p
2068 Rect r;
2069 MacFontStruct *font = s->font;
2070
2071 #if USE_ATSUI 2285 #if USE_ATSUI
2072 if (font->mac_style) 2286 || s->font->mac_style
2073 { 2287 #endif
2074 OSErr err; 2288 )
2075 ATSUTextLayout text_layout; 2289 {
2076 UniChar *buf; 2290 XCharStruct cs;
2077 int i; 2291
2078 2292 mac_text_extents_16 (s->font, s->char2b, s->nchars, &cs);
2079 SetRect (&r, 0, 0, 0, 0); 2293 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0;
2080 buf = xmalloc (sizeof (UniChar) * s->nchars); 2294 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0;
2081 if (buf) 2295 }
2082 { 2296 else
2083 for (i = 0; i < s->nchars; i++) 2297 {
2084 buf[i] = (s->char2b[i].byte1 << 8) + s->char2b[i].byte2; 2298 Rect r;
2085 2299 MacFontStruct *font = s->font;
2086 err = atsu_get_text_layout_with_text_ptr (buf, s->nchars, 2300
2087 font->mac_style, 2301 TextFont (font->mac_fontnum);
2088 &text_layout); 2302 TextSize (font->mac_fontsize);
2089 if (err == noErr) 2303 TextFace (font->mac_fontface);
2090 err = ATSUMeasureTextImage (text_layout, 2304
2091 kATSUFromTextBeginning,
2092 kATSUToTextEnd,
2093 0, 0, &r);
2094 xfree (buf);
2095 }
2096 }
2097 else
2098 {
2099 #endif
2100 TextFont (font->mac_fontnum);
2101 TextSize (font->mac_fontsize);
2102 TextFace (font->mac_fontface);
2103
2104 if (s->two_byte_p)
2105 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r); 2305 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
2106 else 2306
2107 { 2307 s->right_overhang = r.right > s->width ? r.right - s->width : 0;
2108 int i; 2308 s->left_overhang = r.left < 0 ? -r.left : 0;
2109 char *buf = xmalloc (s->nchars); 2309 }
2110
2111 if (buf == NULL)
2112 SetRect (&r, 0, 0, 0, 0);
2113 else
2114 {
2115 for (i = 0; i < s->nchars; ++i)
2116 buf[i] = s->char2b[i].byte2;
2117 QDTextBounds (s->nchars, buf, &r);
2118 xfree (buf);
2119 }
2120 }
2121 #if USE_ATSUI
2122 }
2123 #endif
2124
2125 s->right_overhang = r.right > s->width ? r.right - s->width : 0;
2126 s->left_overhang = r.left < 0 ? -r.left : 0;
2127 }
2128 } 2310 }
2129 2311
2130 2312
2131 /* Fill rectangle X, Y, W, H with background color of glyph string S. */ 2313 /* Fill rectangle X, Y, W, H with background color of glyph string S. */
2132 2314
2253 if (s->two_byte_p 2435 if (s->two_byte_p
2254 #if USE_ATSUI 2436 #if USE_ATSUI
2255 || GC_FONT (s->gc)->mac_style 2437 || GC_FONT (s->gc)->mac_style
2256 #endif 2438 #endif
2257 ) 2439 )
2440 #if USE_CG_TEXT_DRAWING
2441 if (!s->two_byte_p
2442 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff,
2443 s->char2b, s->nchars))
2444 ;
2445 else
2446 #endif
2258 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, 2447 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2259 s->char2b, s->nchars); 2448 s->char2b, s->nchars);
2260 else 2449 else
2261 mac_draw_string (s->f, s->gc, x, s->ybase - boff, 2450 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2262 char1b, s->nchars); 2451 char1b, s->nchars);
3910 frame->output_data.mac->nontext_cursor); 4099 frame->output_data.mac->nontext_cursor);
3911 } 4100 }
3912 return 1; 4101 return 1;
3913 } 4102 }
3914 /* Has the mouse moved off the glyph it was on at the last sighting? */ 4103 /* Has the mouse moved off the glyph it was on at the last sighting? */
3915 if (!PtInRect (*pos, &last_mouse_glyph)) 4104 if (frame != last_mouse_glyph_frame
4105 || !PtInRect (*pos, &last_mouse_glyph))
3916 { 4106 {
3917 frame->mouse_moved = 1; 4107 frame->mouse_moved = 1;
3918 last_mouse_scroll_bar = Qnil; 4108 last_mouse_scroll_bar = Qnil;
3919 note_mouse_highlight (frame, pos->h, pos->v); 4109 note_mouse_highlight (frame, pos->h, pos->v);
3920 /* Remember which glyph we're now on. */ 4110 /* Remember which glyph we're now on. */
3921 remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph); 4111 remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph);
4112 last_mouse_glyph_frame = frame;
3922 return 1; 4113 return 1;
3923 } 4114 }
3924 4115
3925 return 0; 4116 return 0;
3926 } 4117 }
4021 4212
4022 SetPortWindowPort (FRAME_MAC_WINDOW (f1)); 4213 SetPortWindowPort (FRAME_MAC_WINDOW (f1));
4023 GetMouse (&mouse_pos); 4214 GetMouse (&mouse_pos);
4024 remember_mouse_glyph (f1, mouse_pos.h, mouse_pos.v, 4215 remember_mouse_glyph (f1, mouse_pos.h, mouse_pos.v,
4025 &last_mouse_glyph); 4216 &last_mouse_glyph);
4217 last_mouse_glyph_frame = f1;
4026 4218
4027 *bar_window = Qnil; 4219 *bar_window = Qnil;
4028 *part = 0; 4220 *part = 0;
4029 *fp = f1; 4221 *fp = f1;
4030 XSETINT (*x, mouse_pos.h); 4222 XSETINT (*x, mouse_pos.h);
6589 strcpy(family, name); 6781 strcpy(family, name);
6590 } 6782 }
6591 6783
6592 sprintf (xf, "%s-%c-normal--%d-%d-%d-%d-m-%d-%s", 6784 sprintf (xf, "%s-%c-normal--%d-%d-%d-%d-m-%d-%s",
6593 style & bold ? "bold" : "medium", style & italic ? 'i' : 'r', 6785 style & bold ? "bold" : "medium", style & italic ? 'i' : 'r',
6594 size, size * 10, size ? 75 : 0, size ? 75 : 0, size * 10, charset); 6786 size, size * 10, size ? 72 : 0, size ? 72 : 0, size * 10, charset);
6595 6787
6596 result = xmalloc (strlen (foundry) + strlen (family) + strlen (xf) + 3 + 1); 6788 result = xmalloc (strlen (foundry) + strlen (family) + strlen (xf) + 3 + 1);
6597 sprintf (result, "-%s-%s-%s", foundry, family, xf); 6789 sprintf (result, "-%s-%s-%s", foundry, family, xf);
6598 for (p = result; *p; p++) 6790 for (p = result; *p; p++)
6599 /* On Mac OS X 10.3, tolower also converts non-ASCII characters 6791 /* On Mac OS X 10.3, tolower also converts non-ASCII characters
6715 struct gcpro gcpro1; 6907 struct gcpro gcpro1;
6716 6908
6717 text_encoding_info_alist = create_text_encoding_info_alist (); 6909 text_encoding_info_alist = create_text_encoding_info_alist ();
6718 6910
6719 #if USE_ATSUI 6911 #if USE_ATSUI
6912 #if USE_CG_TEXT_DRAWING
6913 init_cg_text_anti_aliasing_threshold ();
6914 #endif
6720 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode), 6915 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode),
6721 text_encoding_info_alist))) 6916 text_encoding_info_alist)))
6722 { 6917 {
6723 OSErr err; 6918 OSErr err;
6724 ItemCount nfonts, i; 6919 ItemCount nfonts, i;
7078 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1); 7273 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1);
7079 if (scaled == NULL) 7274 if (scaled == NULL)
7080 continue; 7275 continue;
7081 memcpy (scaled, font_name_table[i], former_len); 7276 memcpy (scaled, font_name_table[i], former_len);
7082 sprintf (scaled + former_len, 7277 sprintf (scaled + former_len,
7083 "-%d-%d-75-75-m-%d-%s", 7278 "-%d-%d-72-72-m-%d-%s",
7084 scl_val[XLFD_SCL_PIXEL_SIZE], 7279 scl_val[XLFD_SCL_PIXEL_SIZE],
7085 scl_val[XLFD_SCL_POINT_SIZE], 7280 scl_val[XLFD_SCL_POINT_SIZE],
7086 scl_val[XLFD_SCL_AVGWIDTH], 7281 scl_val[XLFD_SCL_AVGWIDTH],
7087 ptr + sizeof ("-0-0-0-0-m-0-") - 1); 7282 ptr + sizeof ("-0-0-0-0-m-0-") - 1);
7088 7283
7284 and store them in the returned MacFontStruct. */ 7479 and store them in the returned MacFontStruct. */
7285 7480
7286 static MacFontStruct * 7481 static MacFontStruct *
7287 XLoadQueryFont (Display *dpy, char *fontname) 7482 XLoadQueryFont (Display *dpy, char *fontname)
7288 { 7483 {
7289 int i, size, char_width; 7484 int size;
7290 char *name; 7485 char *name;
7291 Str255 family; 7486 Str255 family;
7292 Str31 charset; 7487 Str31 charset;
7293 SInt16 fontnum; 7488 SInt16 fontnum;
7294 #if USE_ATSUI 7489 #if USE_ATSUI
7490 static ATSUFontID font_id;
7295 ATSUStyle mac_style = NULL; 7491 ATSUStyle mac_style = NULL;
7296 #endif 7492 #endif
7297 Style fontface; 7493 Style fontface;
7298 #if TARGET_API_MAC_CARBON 7494 #if TARGET_API_MAC_CARBON
7299 TextEncoding encoding; 7495 TextEncoding encoding;
7300 int scriptcode; 7496 int scriptcode;
7301 #else 7497 #else
7302 short scriptcode; 7498 short scriptcode;
7303 #endif 7499 #endif
7304 MacFontStruct *font; 7500 MacFontStruct *font;
7501 XCharStruct *space_bounds = NULL, *pcm;
7305 7502
7306 if (is_fully_specified_xlfd (fontname)) 7503 if (is_fully_specified_xlfd (fontname))
7307 name = fontname; 7504 name = fontname;
7308 else 7505 else
7309 { 7506 {
7324 OSErr err; 7521 OSErr err;
7325 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag, 7522 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag,
7326 kATSUQDBoldfaceTag, kATSUQDItalicTag}; 7523 kATSUQDBoldfaceTag, kATSUQDItalicTag};
7327 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), 7524 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
7328 sizeof (Boolean), sizeof (Boolean)}; 7525 sizeof (Boolean), sizeof (Boolean)};
7329 static ATSUFontID font_id;
7330 static Fixed size_fixed; 7526 static Fixed size_fixed;
7331 static Boolean bold_p, italic_p; 7527 static Boolean bold_p, italic_p;
7332 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed, 7528 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed,
7333 &bold_p, &italic_p}; 7529 &bold_p, &italic_p};
7334 ATSUFontFeatureType types[] = {kAllTypographicFeaturesType}; 7530 ATSUFontFeatureType types[] = {kAllTypographicFeaturesType,
7335 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector}; 7531 kDiacriticsType};
7532 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector,
7533 kDecomposeDiacriticsSelector};
7336 Lisp_Object font_id_cons; 7534 Lisp_Object font_id_cons;
7337 7535
7338 font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)), 7536 font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)),
7339 atsu_font_id_hash, Qnil); 7537 atsu_font_id_hash, Qnil);
7340 if (NILP (font_id_cons)) 7538 if (NILP (font_id_cons))
7378 font->mac_fontsize = size; 7576 font->mac_fontsize = size;
7379 font->mac_fontface = fontface; 7577 font->mac_fontface = fontface;
7380 font->mac_scriptcode = scriptcode; 7578 font->mac_scriptcode = scriptcode;
7381 #if USE_ATSUI 7579 #if USE_ATSUI
7382 font->mac_style = mac_style; 7580 font->mac_style = mac_style;
7581 #if USE_CG_TEXT_DRAWING
7582 font->cg_font = NULL;
7583 font->cg_glyphs = NULL;
7584 #endif
7383 #endif 7585 #endif
7384 7586
7385 /* Apple Japanese (SJIS) font is listed as both 7587 /* Apple Japanese (SJIS) font is listed as both
7386 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0" 7588 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
7387 (Roman script) in init_font_name_table (). The latter should be 7589 (Roman script) in init_font_name_table (). The latter should be
7393 7595
7394 #if USE_ATSUI 7596 #if USE_ATSUI
7395 if (font->mac_style) 7597 if (font->mac_style)
7396 { 7598 {
7397 OSErr err; 7599 OSErr err;
7398 ATSUTextLayout text_layout; 7600 UniChar c;
7399 UniChar c = 0x20; 7601
7400 Rect char_bounds, min_bounds, max_bounds; 7602 font->min_byte1 = 0;
7401 int min_width, max_width; 7603 font->max_byte1 = 0xff;
7402 ATSTrapezoid glyph_bounds; 7604 font->min_char_or_byte2 = 0;
7403 7605 font->max_char_or_byte2 = 0xff;
7404 font->per_char = xmalloc (sizeof (XCharStruct) * 0x10000); 7606
7405 if (font->per_char == NULL) 7607 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100);
7608 if (font->bounds.rows == NULL)
7406 { 7609 {
7407 mac_unload_font (&one_mac_display_info, font); 7610 mac_unload_font (&one_mac_display_info, font);
7408 return NULL; 7611 return NULL;
7409 } 7612 }
7410 bzero (font->per_char, sizeof (XCharStruct) * 0x10000); 7613 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100);
7411 7614 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow));
7412 err = atsu_get_text_layout_with_text_ptr (&c, 1, 7615 if (font->bounds.rows[0] == NULL)
7413 font->mac_style, 7616 {
7414 &text_layout); 7617 mac_unload_font (&one_mac_display_info, font);
7618 return NULL;
7619 }
7620 bzero (font->bounds.rows[0], sizeof (XCharStructRow));
7621
7622 #if USE_CG_TEXT_DRAWING
7623 {
7624 FMFontFamily font_family;
7625 FMFontStyle style;
7626 ATSFontRef ats_font;
7627
7628 err = FMGetFontFamilyInstanceFromFont (font_id, &font_family, &style);
7629 if (err == noErr)
7630 err = FMGetFontFromFontFamilyInstance (font_family, fontface,
7631 &font_id, &style);
7632 /* Use CG text drawing if italic/bold is not synthesized. */
7633 if (err == noErr && style == fontface)
7634 {
7635 ats_font = FMGetATSFontRefFromFont (font_id);
7636 font->cg_font = CGFontCreateWithPlatformFont (&ats_font);
7637 }
7638 }
7639
7640 if (font->cg_font)
7641 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7642 if (font->cg_glyphs)
7643 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7644 #endif
7645 space_bounds = font->bounds.rows[0]->per_char + 0x20;
7646 err = mac_query_char_extents (font->mac_style, 0x20,
7647 &font->ascent, &font->descent,
7648 space_bounds,
7649 #if USE_CG_TEXT_DRAWING
7650 (font->cg_glyphs ? font->cg_glyphs + 0x20
7651 : NULL)
7652 #else
7653 NULL
7654 #endif
7655 );
7415 if (err != noErr) 7656 if (err != noErr)
7416 { 7657 {
7417 mac_unload_font (&one_mac_display_info, font); 7658 mac_unload_font (&one_mac_display_info, font);
7418 return NULL; 7659 return NULL;
7419 } 7660 }
7420 7661 XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], 0x20);
7421 for (c = 0x20; c <= 0x7e; c++) 7662
7663 pcm = font->bounds.rows[0]->per_char;
7664 for (c = 0x21; c <= 0xff; c++)
7422 { 7665 {
7423 err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning); 7666 if (c == 0xad)
7424 if (err == noErr) 7667 /* Soft hyphen is not supported in ATSUI. */
7425 err = ATSUMeasureTextImage (text_layout, 7668 continue;
7426 kATSUFromTextBeginning, kATSUToTextEnd, 7669 else if (c == 0x7f)
7427 0, 0, &char_bounds);
7428 if (err == noErr)
7429 err = ATSUGetGlyphBounds (text_layout, 0, 0,
7430 kATSUFromTextBeginning, kATSUToTextEnd,
7431 kATSUseFractionalOrigins, 1,
7432 &glyph_bounds, NULL);
7433 if (err == noErr)
7434 { 7670 {
7435 xassert (glyph_bounds.lowerRight.x - glyph_bounds.lowerLeft.x 7671 c = 0x9f;
7436 == glyph_bounds.upperRight.x - glyph_bounds.upperLeft.x); 7672 continue;
7437
7438 char_width = Fix2Long (glyph_bounds.upperRight.x
7439 - glyph_bounds.upperLeft.x);
7440 STORE_XCHARSTRUCT (font->per_char[c],
7441 char_width, char_bounds);
7442 if (c == 0x20)
7443 {
7444 min_width = max_width = char_width;
7445 min_bounds = max_bounds = char_bounds;
7446 font->ascent = -Fix2Long (glyph_bounds.upperLeft.y);
7447 font->descent = Fix2Long (glyph_bounds.lowerLeft.y);
7448 }
7449 else
7450 {
7451 if (char_width > 0)
7452 {
7453 min_width = min (min_width, char_width);
7454 max_width = max (max_width, char_width);
7455 }
7456 if (!EmptyRect (&char_bounds))
7457 {
7458 SetRect (&min_bounds,
7459 max (min_bounds.left, char_bounds.left),
7460 max (min_bounds.top, char_bounds.top),
7461 min (min_bounds.right, char_bounds.right),
7462 min (min_bounds.bottom, char_bounds.bottom));
7463 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7464 }
7465 }
7466 } 7673 }
7674
7675 mac_query_char_extents (font->mac_style, c, NULL, NULL, pcm + c,
7676 #if USE_CG_TEXT_DRAWING
7677 (font->cg_glyphs ? font->cg_glyphs + c
7678 : NULL)
7679 #else
7680 NULL
7681 #endif
7682 );
7683 XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], c);
7684
7685 #if USE_CG_TEXT_DRAWING
7686 if (font->cg_glyphs && font->cg_glyphs[c] == 0)
7687 {
7688 /* Don't use CG text drawing if font substitution occurs in
7689 ASCII or Latin-1 characters. */
7690 CGFontRelease (font->cg_font);
7691 font->cg_font = NULL;
7692 xfree (font->cg_glyphs);
7693 font->cg_glyphs = NULL;
7694 }
7695 #endif
7467 } 7696 }
7468 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7469 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7470
7471 font->min_byte1 = 0;
7472 font->max_byte1 = 0xff;
7473 font->min_char_or_byte2 = 0;
7474 font->max_char_or_byte2 = 0xff;
7475 } 7697 }
7476 else 7698 else
7477 #endif 7699 #endif
7478 { 7700 {
7479 GrafPtr port; 7701 GrafPtr port;
7508 || font->mac_scriptcode == smSimpChinese 7730 || font->mac_scriptcode == smSimpChinese
7509 || font->mac_scriptcode == smKorean); 7731 || font->mac_scriptcode == smKorean);
7510 7732
7511 if (is_two_byte_font) 7733 if (is_two_byte_font)
7512 { 7734 {
7735 int char_width;
7736
7513 font->min_byte1 = 0xa1; 7737 font->min_byte1 = 0xa1;
7514 font->max_byte1 = 0xfe; 7738 font->max_byte1 = 0xfe;
7515 font->min_char_or_byte2 = 0xa1; 7739 font->min_char_or_byte2 = 0xa1;
7516 font->max_char_or_byte2 = 0xfe; 7740 font->max_char_or_byte2 = 0xfe;
7517 7741
7536 break; 7760 break;
7537 case smKorean: 7761 case smKorean:
7538 char_width = StringWidth("\p\xa1\xa1"); 7762 char_width = StringWidth("\p\xa1\xa1");
7539 break; 7763 break;
7540 } 7764 }
7541 } 7765
7542 else 7766 font->bounds.per_char = NULL;
7543 {
7544 font->min_byte1 = font->max_byte1 = 0;
7545 font->min_char_or_byte2 = 0x20;
7546 font->max_char_or_byte2 = 0xff;
7547
7548 /* Do this instead of use the_fontinfo.widMax, which
7549 incorrectly returns 15 for 12-point Monaco! */
7550 char_width = CharWidth ('m');
7551 }
7552
7553 if (is_two_byte_font)
7554 {
7555 font->per_char = NULL;
7556 7767
7557 if (fontface & italic) 7768 if (fontface & italic)
7558 font->max_bounds.rbearing = char_width + 1; 7769 font->max_bounds.rbearing = char_width + 1;
7559 else 7770 else
7560 font->max_bounds.rbearing = char_width; 7771 font->max_bounds.rbearing = char_width;
7565 7776
7566 font->min_bounds = font->max_bounds; 7777 font->min_bounds = font->max_bounds;
7567 } 7778 }
7568 else 7779 else
7569 { 7780 {
7570 int c, min_width, max_width; 7781 int c;
7571 Rect char_bounds, min_bounds, max_bounds; 7782
7572 char ch; 7783 font->min_byte1 = font->max_byte1 = 0;
7573 7784 font->min_char_or_byte2 = 0x20;
7574 font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7785 font->max_char_or_byte2 = 0xff;
7575 bzero (font->per_char, sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7786
7576 7787 font->bounds.per_char =
7577 min_width = max_width = char_width; 7788 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
7578 SetRect (&min_bounds, -32767, -32767, 32767, 32767); 7789 if (font->bounds.per_char == NULL)
7579 SetRect (&max_bounds, 0, 0, 0, 0);
7580 for (c = 0x20; c <= 0xff; c++)
7581 { 7790 {
7582 ch = c; 7791 mac_unload_font (&one_mac_display_info, font);
7583 char_width = CharWidth (ch); 7792 return NULL;
7584 QDTextBounds (1, &ch, &char_bounds);
7585 STORE_XCHARSTRUCT (font->per_char[c - 0x20],
7586 char_width, char_bounds);
7587 /* Some Japanese fonts (in SJIS encoding) return 0 as
7588 the character width of 0x7f. */
7589 if (char_width > 0)
7590 {
7591 min_width = min (min_width, char_width);
7592 max_width = max (max_width, char_width);
7593 }
7594 if (!EmptyRect (&char_bounds))
7595 {
7596 SetRect (&min_bounds,
7597 max (min_bounds.left, char_bounds.left),
7598 max (min_bounds.top, char_bounds.top),
7599 min (min_bounds.right, char_bounds.right),
7600 min (min_bounds.bottom, char_bounds.bottom));
7601 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7602 }
7603 } 7793 }
7604 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds); 7794 bzero (font->bounds.per_char,
7605 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds); 7795 sizeof (XCharStruct) * (0xff - 0x20 + 1));
7606 if (min_width == max_width 7796
7607 && max_bounds.left >= 0 && max_bounds.right <= max_width) 7797 space_bounds = font->bounds.per_char;
7608 { 7798 mac_query_char_extents (NULL, 0x20, &font->ascent, &font->descent,
7609 /* Fixed width and no overhangs. */ 7799 space_bounds, NULL);
7610 xfree (font->per_char); 7800
7611 font->per_char = NULL; 7801 for (c = 0x21, pcm = space_bounds + 1; c <= 0xff; c++, pcm++)
7612 } 7802 mac_query_char_extents (NULL, c, NULL, NULL, pcm, NULL);
7613 } 7803 }
7614 7804
7615 /* Restore previous font number, size and face. */ 7805 /* Restore previous font number, size and face. */
7616 TextFont (old_fontnum); 7806 TextFont (old_fontnum);
7617 TextSize (old_fontsize); 7807 TextSize (old_fontsize);
7618 TextFace (old_fontface); 7808 TextFace (old_fontface);
7619 } 7809 }
7620 7810
7811 if (space_bounds)
7812 {
7813 int c;
7814
7815 font->min_bounds = font->max_bounds = *space_bounds;
7816 for (c = 0x21, pcm = space_bounds + 1; c <= 0x7f; c++, pcm++)
7817 if (pcm->width > 0)
7818 {
7819 font->min_bounds.lbearing = min (font->min_bounds.lbearing,
7820 pcm->lbearing);
7821 font->min_bounds.rbearing = min (font->min_bounds.rbearing,
7822 pcm->rbearing);
7823 font->min_bounds.width = min (font->min_bounds.width,
7824 pcm->width);
7825 font->min_bounds.ascent = min (font->min_bounds.ascent,
7826 pcm->ascent);
7827
7828 font->max_bounds.lbearing = max (font->max_bounds.lbearing,
7829 pcm->lbearing);
7830 font->max_bounds.rbearing = max (font->max_bounds.rbearing,
7831 pcm->rbearing);
7832 font->max_bounds.width = max (font->max_bounds.width,
7833 pcm->width);
7834 font->max_bounds.ascent = max (font->max_bounds.ascent,
7835 pcm->ascent);
7836 }
7837 if (
7838 #if USE_ATSUI
7839 font->mac_style == NULL &&
7840 #endif
7841 font->max_bounds.width == font->min_bounds.width
7842 && font->min_bounds.lbearing >= 0
7843 && font->max_bounds.rbearing <= font->max_bounds.width)
7844 {
7845 /* Fixed width and no overhangs. */
7846 xfree (font->bounds.per_char);
7847 font->bounds.per_char = NULL;
7848 }
7849 }
7850
7851 #if !defined (MAC_OS8) || USE_ATSUI
7852 /* AppKit and WebKit do some adjustment to the heights of Courier,
7853 Helvetica, and Times. This only works on the environments where
7854 the XDrawImageString counterpart is never used. */
7855 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
7856 || strcmp (family, "times") == 0)
7857 font->ascent += (font->ascent + font->descent) * .15 + 0.5;
7858 #endif
7859
7621 return font; 7860 return font;
7622 } 7861 }
7623 7862
7624 7863
7625 void 7864 void
7626 mac_unload_font (dpyinfo, font) 7865 mac_unload_font (dpyinfo, font)
7627 struct mac_display_info *dpyinfo; 7866 struct mac_display_info *dpyinfo;
7628 XFontStruct *font; 7867 XFontStruct *font;
7629 { 7868 {
7630 xfree (font->full_name); 7869 xfree (font->full_name);
7631 if (font->per_char)
7632 xfree (font->per_char);
7633 #if USE_ATSUI 7870 #if USE_ATSUI
7634 if (font->mac_style) 7871 if (font->mac_style)
7635 ATSUDisposeStyle (font->mac_style); 7872 {
7873 int i;
7874
7875 for (i = font->min_byte1; i <= font->max_byte1; i++)
7876 if (font->bounds.rows[i])
7877 xfree (font->bounds.rows[i]);
7878 xfree (font->bounds.rows);
7879 ATSUDisposeStyle (font->mac_style);
7880 }
7881 else
7882 #endif
7883 if (font->bounds.per_char)
7884 xfree (font->bounds.per_char);
7885 #if USE_CG_TEXT_DRAWING
7886 if (font->cg_font)
7887 CGFontRelease (font->cg_font);
7888 if (font->cg_glyphs)
7889 xfree (font->cg_glyphs);
7636 #endif 7890 #endif
7637 xfree (font); 7891 xfree (font);
7638 } 7892 }
7639 7893
7640 7894
7920 #define RAM_TOO_LARGE_ALERT_ID 129 8174 #define RAM_TOO_LARGE_ALERT_ID 129
7921 8175
7922 /* Contains the string "reverse", which is a constant for mouse button emu.*/ 8176 /* Contains the string "reverse", which is a constant for mouse button emu.*/
7923 Lisp_Object Qreverse; 8177 Lisp_Object Qreverse;
7924 8178
7925 /* True if using command key as meta key. */ 8179
7926 Lisp_Object Vmac_command_key_is_meta; 8180 /* Modifier associated with the control key, or nil to ignore. */
7927 8181 Lisp_Object Vmac_control_modifier;
7928 /* Modifier associated with the option key, or nil for normal behavior. */ 8182
8183 /* Modifier associated with the option key, or nil to ignore. */
7929 Lisp_Object Vmac_option_modifier; 8184 Lisp_Object Vmac_option_modifier;
7930 8185
7931 /* True if the ctrl and meta keys should be reversed. */ 8186 /* Modifier associated with the command key, or nil to ignore. */
7932 Lisp_Object Vmac_reverse_ctrl_meta; 8187 Lisp_Object Vmac_command_modifier;
8188
8189 /* Modifier associated with the function key, or nil to ignore. */
8190 Lisp_Object Vmac_function_modifier;
7933 8191
7934 /* True if the option and command modifiers should be used to emulate 8192 /* True if the option and command modifiers should be used to emulate
7935 a three button mouse */ 8193 a three button mouse */
7936 Lisp_Object Vmac_emulate_three_button_mouse; 8194 Lisp_Object Vmac_emulate_three_button_mouse;
7937 8195
7938 #if USE_CARBON_EVENTS 8196 #if USE_CARBON_EVENTS
7939 /* True if the mouse wheel button (i.e. button 4) should map to 8197 /* Non-zero if the mouse wheel button (i.e. button 4) should map to
7940 mouse-2, instead of mouse-3. */ 8198 mouse-2, instead of mouse-3. */
7941 Lisp_Object Vmac_wheel_button_is_mouse_2; 8199 int mac_wheel_button_is_mouse_2;
7942 8200
7943 /* If Non-nil, the Mac "Command" key is passed on to the Mac Toolbox 8201 /* If non-zero, the Mac "Command" key is passed on to the Mac Toolbox
7944 for processing before Emacs sees it. */ 8202 for processing before Emacs sees it. */
7945 Lisp_Object Vmac_pass_command_to_system; 8203 int mac_pass_command_to_system;
7946 8204
7947 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox 8205 /* If non-zero, the Mac "Control" key is passed on to the Mac Toolbox
7948 for processing before Emacs sees it. */ 8206 for processing before Emacs sees it. */
7949 Lisp_Object Vmac_pass_control_to_system; 8207 int mac_pass_control_to_system;
7950 #endif 8208 #endif
7951 8209
7952 /* Points to the variable `inev' in the function XTread_socket. It is 8210 /* Points to the variable `inev' in the function XTread_socket. It is
7953 used for passing an input event to the function back from 8211 used for passing an input event to the function back from
7954 Carbon/Apple event handlers. */ 8212 Carbon/Apple event handlers. */
7955 static struct input_event *read_socket_inev = NULL; 8213 static struct input_event *read_socket_inev = NULL;
7956 8214
7957 /* Set in term/mac-win.el to indicate that event loop can now generate
7958 drag and drop events. */
7959 Lisp_Object Qmac_ready_for_drag_n_drop;
7960
7961 Point saved_menu_event_location; 8215 Point saved_menu_event_location;
7962 8216
7963 /* Apple Events */ 8217 /* Apple Events */
7964 static void init_required_apple_events (void); 8218 #if USE_CARBON_EVENTS
7965 static pascal OSErr 8219 static Lisp_Object Qhicommand;
7966 do_ae_open_application (const AppleEvent *, AppleEvent *, long); 8220 #endif
7967 static pascal OSErr 8221 extern int mac_ready_for_apple_events;
7968 do_ae_print_documents (const AppleEvent *, AppleEvent *, long); 8222 extern Lisp_Object Qundefined;
7969 static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); 8223 extern void init_apple_event_handler P_ ((void));
7970 static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); 8224 extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID,
8225 Lisp_Object *, Lisp_Object *,
8226 Lisp_Object *));
8227 extern OSErr init_coercion_handler P_ ((void));
7971 8228
7972 #if TARGET_API_MAC_CARBON 8229 #if TARGET_API_MAC_CARBON
7973 /* Drag and Drop */ 8230 /* Drag and Drop */
7974 static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); 8231 static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference);
7975 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); 8232 static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
7976 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; 8233 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
7977 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; 8234 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
7978 #endif 8235 #endif
7979 8236
7980 static Lisp_Object Qapplication, Qabout;
7981 #if USE_CARBON_EVENTS 8237 #if USE_CARBON_EVENTS
7982 #ifdef MAC_OSX 8238 #ifdef MAC_OSX
7983 extern void init_service_handler (); 8239 extern void init_service_handler ();
7984 static Lisp_Object Qpreferences, Qservices, Qpaste, Qperform; 8240 static Lisp_Object Qservices, Qpaste, Qperform;
7985 #endif 8241 #endif
7986 /* Window Event Handler */ 8242 /* Window Event Handler */
7987 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, 8243 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
7988 EventRef, void *); 8244 EventRef, void *);
7989 #endif 8245 #endif
8001 #else 8257 #else
8002 mac_to_emacs_modifiers (EventModifiers mods) 8258 mac_to_emacs_modifiers (EventModifiers mods)
8003 #endif 8259 #endif
8004 { 8260 {
8005 unsigned int result = 0; 8261 unsigned int result = 0;
8006 if (mods & macShiftKey) 8262 if (mods & shiftKey)
8007 result |= shift_modifier; 8263 result |= shift_modifier;
8008 if (mods & macCtrlKey) 8264
8009 result |= ctrl_modifier; 8265 /* Deactivated to simplify configuration:
8010 if (mods & macMetaKey) 8266 if Vmac_option_modifier is non-NIL, we fully process the Option
8011 result |= meta_modifier; 8267 key. Otherwise, we only process it if an additional Ctrl or Command
8012 if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) 8268 is pressed. That way the system may convert the character to a
8013 result |= alt_modifier; 8269 composed one.
8270 if ((mods & optionKey) &&
8271 (( !NILP(Vmac_option_modifier) ||
8272 ((mods & cmdKey) || (mods & controlKey))))) */
8273
8014 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { 8274 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
8015 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value); 8275 Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value);
8016 if (!NILP(val)) 8276 if (INTEGERP(val))
8017 result |= XUINT(val); 8277 result |= XUINT(val);
8018 } 8278 }
8279 if (!NILP (Vmac_command_modifier) && (mods & cmdKey)) {
8280 Lisp_Object val = Fget(Vmac_command_modifier, Qmodifier_value);
8281 if (INTEGERP(val))
8282 result |= XUINT(val);
8283 }
8284 if (!NILP (Vmac_control_modifier) && (mods & controlKey)) {
8285 Lisp_Object val = Fget(Vmac_control_modifier, Qmodifier_value);
8286 if (INTEGERP(val))
8287 result |= XUINT(val);
8288 }
8289
8290 #ifdef MAC_OSX
8291 if (!NILP (Vmac_function_modifier) && (mods & kEventKeyModifierFnMask)) {
8292 Lisp_Object val = Fget(Vmac_function_modifier, Qmodifier_value);
8293 if (INTEGERP(val))
8294 result |= XUINT(val);
8295 }
8296 #endif
8019 8297
8020 return result; 8298 return result;
8021 } 8299 }
8022 8300
8023 static int 8301 static int
8035 } 8313 }
8036 8314
8037 #if USE_CARBON_EVENTS 8315 #if USE_CARBON_EVENTS
8038 /* Obtains the event modifiers from the event ref and then calls 8316 /* Obtains the event modifiers from the event ref and then calls
8039 mac_to_emacs_modifiers. */ 8317 mac_to_emacs_modifiers. */
8040 static int 8318 static UInt32
8041 mac_event_to_emacs_modifiers (EventRef eventRef) 8319 mac_event_to_emacs_modifiers (EventRef eventRef)
8042 { 8320 {
8043 UInt32 mods = 0; 8321 UInt32 mods = 0;
8044 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 8322 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
8045 sizeof (UInt32), NULL, &mods); 8323 sizeof (UInt32), NULL, &mods);
8069 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL, 8347 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
8070 sizeof (UInt32), NULL, &mods); 8348 sizeof (UInt32), NULL, &mods);
8071 return mac_get_emulated_btn(mods); 8349 return mac_get_emulated_btn(mods);
8072 } 8350 }
8073 case kEventMouseButtonSecondary: 8351 case kEventMouseButtonSecondary:
8074 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2; 8352 return mac_wheel_button_is_mouse_2 ? 2 : 1;
8075 case kEventMouseButtonTertiary: 8353 case kEventMouseButtonTertiary:
8076 case 4: /* 4 is the number for the mouse wheel button */ 8354 case 4: /* 4 is the number for the mouse wheel button */
8077 return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1; 8355 return mac_wheel_button_is_mouse_2 ? 1 : 2;
8078 default: 8356 default:
8079 return 0; 8357 return 0;
8080 } 8358 }
8081 } 8359 }
8082 8360
8500 FRAME_PIXEL_HEIGHT (f) = height; 8778 FRAME_PIXEL_HEIGHT (f) = height;
8501 } 8779 }
8502 x_real_positions (f, &f->left_pos, &f->top_pos); 8780 x_real_positions (f, &f->left_pos, &f->top_pos);
8503 } 8781 }
8504 8782
8505 /* Intialize AppleEvent dispatcher table for the required events. */ 8783 OSErr
8506 void 8784 mac_store_apple_event (class, id, desc)
8507 init_required_apple_events () 8785 Lisp_Object class, id;
8508 { 8786 const AEDesc *desc;
8509 OSErr err; 8787 {
8510 long result; 8788 OSErr err = noErr;
8511
8512 /* Make sure we have apple events before starting. */
8513 err = Gestalt (gestaltAppleEventsAttr, &result);
8514 if (err != noErr)
8515 abort ();
8516
8517 if (!(result & (1 << gestaltAppleEventsPresent)))
8518 abort ();
8519
8520 #if TARGET_API_MAC_CARBON
8521 err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
8522 NewAEEventHandlerUPP
8523 ((AEEventHandlerProcPtr) do_ae_open_application),
8524 0L, false);
8525 #else
8526 err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
8527 NewAEEventHandlerProc
8528 ((AEEventHandlerProcPtr) do_ae_open_application),
8529 0L, false);
8530 #endif
8531 if (err != noErr)
8532 abort ();
8533
8534 #if TARGET_API_MAC_CARBON
8535 err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
8536 NewAEEventHandlerUPP
8537 ((AEEventHandlerProcPtr) do_ae_open_documents),
8538 0L, false);
8539 #else
8540 err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
8541 NewAEEventHandlerProc
8542 ((AEEventHandlerProcPtr) do_ae_open_documents),
8543 0L, false);
8544 #endif
8545 if (err != noErr)
8546 abort ();
8547
8548 #if TARGET_API_MAC_CARBON
8549 err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
8550 NewAEEventHandlerUPP
8551 ((AEEventHandlerProcPtr) do_ae_print_documents),
8552 0L, false);
8553 #else
8554 err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
8555 NewAEEventHandlerProc
8556 ((AEEventHandlerProcPtr) do_ae_print_documents),
8557 0L, false);
8558 #endif
8559 if (err != noErr)
8560 abort ();
8561
8562 #if TARGET_API_MAC_CARBON
8563 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
8564 NewAEEventHandlerUPP
8565 ((AEEventHandlerProcPtr) do_ae_quit_application),
8566 0L, false);
8567 #else
8568 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
8569 NewAEEventHandlerProc
8570 ((AEEventHandlerProcPtr) do_ae_quit_application),
8571 0L, false);
8572 #endif
8573 if (err != noErr)
8574 abort ();
8575 }
8576
8577 void
8578 mac_store_application_menu_event (event)
8579 #if USE_CARBON_EVENTS
8580 EventRef event;
8581 #else
8582 UInt32 event;
8583 #endif
8584 {
8585 struct input_event buf; 8789 struct input_event buf;
8586 Lisp_Object frame, entry; 8790 AEDesc *desc_copy;
8587 8791
8588 EVENT_INIT (buf); 8792 desc_copy = xmalloc (sizeof (AEDesc));
8589 8793 if (desc_copy == NULL)
8590 XSETFRAME (frame, mac_focus_frame (&one_mac_display_info)); 8794 err = memFullErr;
8591 buf.kind = MENU_BAR_EVENT; 8795 else
8592 buf.frame_or_window = frame; 8796 err = AEDuplicateDesc (desc, desc_copy);
8593 buf.arg = frame; 8797 if (err == noErr)
8594 kbd_buffer_store_event (&buf); 8798 {
8595 8799 EVENT_INIT (buf);
8596 buf.arg = Qapplication; 8800
8597 kbd_buffer_store_event (&buf); 8801 buf.kind = MAC_APPLE_EVENT;
8598 8802 buf.x = class;
8599 #if USE_CARBON_EVENTS 8803 buf.y = id;
8600 switch (GetEventClass (event)) 8804 buf.code = (int)desc_copy;
8601 { 8805 XSETFRAME (buf.frame_or_window,
8602 #ifdef MAC_OSX 8806 mac_focus_frame (&one_mac_display_info));
8603 case kEventClassService: 8807 buf.arg = Qnil;
8604 buf.arg = Qservices;
8605 kbd_buffer_store_event (&buf); 8808 kbd_buffer_store_event (&buf);
8606 switch (GetEventKind (event)) 8809 }
8607 { 8810
8608 case kEventServicePaste: 8811 return err;
8609 entry = Qpaste; 8812 }
8610 break; 8813
8611 8814 Lisp_Object
8612 case kEventServicePerform: 8815 mac_make_lispy_event_code (code)
8613 { 8816 int code;
8614 OSErr err; 8817 {
8615 CFStringRef message; 8818 AEDesc *desc = (AEDesc *)code;
8616 8819 Lisp_Object obj;
8617 err = GetEventParameter (event, kEventParamServiceMessageName, 8820
8618 typeCFStringRef, NULL, 8821 obj = mac_aedesc_to_lisp (desc);
8619 sizeof (CFStringRef), NULL, &message); 8822 AEDisposeDesc (desc);
8620 buf.arg = Qperform; 8823 xfree (desc);
8621 kbd_buffer_store_event (&buf); 8824
8622 if (err == noErr && message) 8825 return obj;
8623 entry = intern (SDATA (cfstring_to_lisp (message)));
8624 else
8625 entry = Qnil;
8626 }
8627 break;
8628
8629 default:
8630 abort ();
8631 }
8632 break;
8633 #endif /* MAC_OSX */
8634 case kEventClassCommand:
8635 {
8636 HICommand command;
8637
8638 GetEventParameter(event, kEventParamDirectObject, typeHICommand,
8639 NULL, sizeof (HICommand), NULL, &command);
8640 switch (command.commandID)
8641 {
8642 case kHICommandAbout:
8643 entry = Qabout;
8644 break;
8645 #ifdef MAC_OSX
8646 case kHICommandPreferences:
8647 entry = Qpreferences;
8648 break;
8649 #endif /* MAC_OSX */
8650 case kHICommandQuit:
8651 entry = Qquit;
8652 break;
8653 default:
8654 abort ();
8655 }
8656 }
8657 break;
8658
8659 default:
8660 abort ();
8661 }
8662 #else /* USE_CARBON_EVENTS */
8663 switch (event)
8664 {
8665 case kHICommandAbout:
8666 entry = Qabout;
8667 break;
8668 case kHICommandQuit:
8669 entry = Qquit;
8670 break;
8671 default:
8672 abort ();
8673 }
8674 #endif
8675
8676 buf.arg = entry;
8677 kbd_buffer_store_event (&buf);
8678 } 8826 }
8679 8827
8680 #if USE_CARBON_EVENTS 8828 #if USE_CARBON_EVENTS
8681 static pascal OSStatus 8829 static pascal OSStatus
8682 mac_handle_command_event (next_handler, event, data) 8830 mac_handle_command_event (next_handler, event, data)
8683 EventHandlerCallRef next_handler; 8831 EventHandlerCallRef next_handler;
8684 EventRef event; 8832 EventRef event;
8685 void *data; 8833 void *data;
8686 { 8834 {
8835 OSStatus result;
8836 OSErr err;
8687 HICommand command; 8837 HICommand command;
8688 OSErr result; 8838 Lisp_Object class_key, id_key, binding;
8689 8839
8690 GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, 8840 result = CallNextEventHandler (next_handler, event);
8691 sizeof (HICommand), NULL, &command); 8841 if (result != eventNotHandledErr)
8692 8842 return result;
8693 switch (command.commandID) 8843
8694 { 8844 GetEventParameter (event, kEventParamDirectObject, typeHICommand, NULL,
8695 case kHICommandAbout: 8845 sizeof (HICommand), NULL, &command);
8696 #ifdef MAC_OSX 8846
8697 case kHICommandPreferences: 8847 if (command.commandID == 0)
8698 #endif /* MAC_OSX */ 8848 return eventNotHandledErr;
8699 result = CallNextEventHandler (next_handler, event); 8849
8700 if (result != eventNotHandledErr) 8850 /* A HICommand event is mapped to an Apple event whose event class
8701 return result; 8851 symbol is `hicommand' and event ID is its command ID. */
8702 8852 class_key = Qhicommand;
8703 mac_store_application_menu_event (event); 8853 mac_find_apple_event_spec (0, command.commandID,
8704 return noErr; 8854 &class_key, &id_key, &binding);
8705 8855 if (!NILP (binding) && !EQ (binding, Qundefined))
8706 default: 8856 if (INTEGERP (binding))
8707 break; 8857 return XINT (binding);
8708 } 8858 else
8859 {
8860 AppleEvent apple_event;
8861 UInt32 modifiers;
8862 static EventParamName names[] = {kEventParamDirectObject,
8863 kEventParamKeyModifiers};
8864 static EventParamType types[] = {typeHICommand,
8865 typeUInt32};
8866 err = create_apple_event_from_event_ref (event, 2, names, types,
8867 &apple_event);
8868 if (err == noErr)
8869 {
8870 err = mac_store_apple_event (class_key, id_key, &apple_event);
8871 AEDisposeDesc (&apple_event);
8872 }
8873 if (err == noErr)
8874 return noErr;
8875 }
8709 8876
8710 return eventNotHandledErr; 8877 return eventNotHandledErr;
8711 } 8878 }
8712 8879
8713 static OSErr 8880 static OSErr
8865 break; 9032 break;
8866 } 9033 }
8867 9034
8868 return eventNotHandledErr; 9035 return eventNotHandledErr;
8869 } 9036 }
9037
9038 #ifdef MAC_OSX
9039 OSErr
9040 mac_store_services_event (event)
9041 EventRef event;
9042 {
9043 OSErr err;
9044 AppleEvent apple_event;
9045 Lisp_Object id_key;
9046
9047 switch (GetEventKind (event))
9048 {
9049 case kEventServicePaste:
9050 id_key = Qpaste;
9051 err = create_apple_event_from_event_ref (event, 0, NULL, NULL,
9052 &apple_event);
9053 break;
9054
9055 case kEventServicePerform:
9056 {
9057 static EventParamName names[] = {kEventParamServiceMessageName,
9058 kEventParamServiceUserData};
9059 static EventParamType types[] = {typeCFStringRef,
9060 typeCFStringRef};
9061
9062 id_key = Qperform;
9063 err = create_apple_event_from_event_ref (event, 2, names, types,
9064 &apple_event);
9065 }
9066 break;
9067
9068 default:
9069 abort ();
9070 }
9071
9072 if (err == noErr)
9073 {
9074 err = mac_store_apple_event (Qservices, id_key, &apple_event);
9075 AEDisposeDesc (&apple_event);
9076 }
9077
9078 return err;
9079 }
9080 #endif /* MAC_OSX */
8870 #endif /* USE_CARBON_EVENTS */ 9081 #endif /* USE_CARBON_EVENTS */
8871 9082
8872 9083
8873 OSErr 9084 OSErr
8874 install_window_handler (window) 9085 install_window_handler (window)
8922 RemoveTrackingHandler (mac_do_track_dragUPP, window); 9133 RemoveTrackingHandler (mac_do_track_dragUPP, window);
8923 if (mac_do_receive_dragUPP) 9134 if (mac_do_receive_dragUPP)
8924 RemoveReceiveHandler (mac_do_receive_dragUPP, window); 9135 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
8925 #endif 9136 #endif
8926 } 9137 }
8927
8928 /* Open Application Apple Event */
8929 static pascal OSErr
8930 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon)
8931 {
8932 return noErr;
8933 }
8934
8935
8936 /* Called when we receive an AppleEvent with an ID of
8937 "kAEOpenDocuments". This routine gets the direct parameter,
8938 extracts the FSSpecs in it, and puts their names on a list. */
8939 #pragma options align=mac68k
8940 typedef struct SelectionRange {
8941 short unused1; // 0 (not used)
8942 short lineNum; // line to select (<0 to specify range)
8943 long startRange; // start of selection range (if line < 0)
8944 long endRange; // end of selection range (if line < 0)
8945 long unused2; // 0 (not used)
8946 long theDate; // modification date/time
8947 } SelectionRange;
8948 #pragma options align=reset
8949
8950 static pascal OSErr
8951 do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
8952 {
8953 OSErr err, err2;
8954 AEDesc the_desc;
8955 AEKeyword keyword;
8956 DescType actual_type;
8957 Size actual_size;
8958 SelectionRange position;
8959 Lisp_Object file_list = Qnil;
8960
8961 xassert (read_socket_inev);
8962
8963 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc);
8964 if (err != noErr)
8965 goto descriptor_error_exit;
8966
8967 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size);
8968 if (err == noErr)
8969 file_list = Fcons (list3 (make_number (position.lineNum + 1),
8970 make_number (position.startRange + 1),
8971 make_number (position.endRange + 1)),
8972 file_list);
8973
8974 /* Check to see that we got all of the required parameters from the
8975 event descriptor. For an 'odoc' event this should just be the
8976 file list. */
8977 err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard,
8978 &actual_type, (Ptr) &keyword,
8979 sizeof (keyword), &actual_size);
8980 /* No error means that we found some unused parameters.
8981 errAEDescNotFound means that there are no more parameters. If we
8982 get an error code other than that, flag it. */
8983 if ((err == noErr) || (err != errAEDescNotFound))
8984 {
8985 err = errAEEventNotHandled;
8986 goto error_exit;
8987 }
8988 err = noErr;
8989
8990 /* Got all the parameters we need. Now, go through the direct
8991 object list and parse it up. */
8992 {
8993 long num_files_to_open;
8994
8995 err = AECountItems (&the_desc, &num_files_to_open);
8996 if (err == noErr)
8997 {
8998 int i;
8999
9000 /* AE file list is one based so just use that for indexing here. */
9001 for (i = 1; i <= num_files_to_open; i++)
9002 {
9003 char unix_path_name[MAXPATHLEN];
9004 #ifdef MAC_OSX
9005 FSRef fref;
9006
9007 err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword,
9008 &actual_type, &fref, sizeof (FSRef),
9009 &actual_size);
9010 if (err != noErr || actual_type != typeFSRef)
9011 continue;
9012
9013 if (FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))
9014 == noErr)
9015 #else
9016 FSSpec fs;
9017
9018 err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type,
9019 (Ptr) &fs, sizeof (fs), &actual_size);
9020 if (err != noErr) continue;
9021
9022 if (fsspec_to_posix_pathname (&fs, unix_path_name,
9023 sizeof (unix_path_name) - 1) == noErr)
9024 #endif
9025 /* x-dnd functions expect undecoded filenames. */
9026 file_list = Fcons (make_unibyte_string (unix_path_name,
9027 strlen (unix_path_name)),
9028 file_list);
9029 }
9030 }
9031
9032 /* Build a DRAG_N_DROP_EVENT type event as is done in
9033 constuct_drag_n_drop in w32term.c. */
9034 if (!NILP (file_list))
9035 {
9036 struct frame *f = mac_focus_frame (&one_mac_display_info);
9037 WindowPtr wp;
9038 Lisp_Object frame;
9039
9040 read_socket_inev->kind = DRAG_N_DROP_EVENT;
9041 read_socket_inev->code = 0;
9042 read_socket_inev->modifiers = 0;
9043
9044 XSETINT (read_socket_inev->x, 0);
9045 XSETINT (read_socket_inev->y, 0);
9046
9047 XSETFRAME (frame, f);
9048 read_socket_inev->frame_or_window = Fcons (frame, file_list);
9049
9050 #if 0
9051 /* Regardless of whether Emacs was suspended or in the
9052 foreground, ask it to redraw its entire screen. Otherwise
9053 parts of the screen can be left in an inconsistent
9054 state. */
9055 wp = FRAME_MAC_WINDOW (f);
9056 if (wp)
9057 #if TARGET_API_MAC_CARBON
9058 {
9059 Rect r;
9060
9061 GetWindowPortBounds (wp, &r);
9062 InvalWindowRect (wp, &r);
9063 }
9064 #else /* not TARGET_API_MAC_CARBON */
9065 InvalRect (&(wp->portRect));
9066 #endif /* not TARGET_API_MAC_CARBON */
9067 #endif
9068 }
9069 }
9070
9071 error_exit:
9072 /* Nuke the coerced file list in any case */
9073 err2 = AEDisposeDesc(&the_desc);
9074
9075 descriptor_error_exit:
9076 /* InvalRect(&(gFrontMacWindowP->mWP->portRect)); */
9077 return err;
9078 }
9079
9080 9138
9081 #if TARGET_API_MAC_CARBON 9139 #if TARGET_API_MAC_CARBON
9082 static pascal OSErr 9140 static pascal OSErr
9083 mac_do_track_drag (DragTrackingMessage message, WindowPtr window, 9141 mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
9084 void *handlerRefCon, DragReference theDrag) 9142 void *handlerRefCon, DragReference theDrag)
9171 /* Only handle file references. */ 9229 /* Only handle file references. */
9172 GetDragItemReferenceNumber (theDrag, index, &theItem); 9230 GetDragItemReferenceNumber (theDrag, index, &theItem);
9173 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); 9231 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
9174 if (result == noErr) 9232 if (result == noErr)
9175 { 9233 {
9176 #ifdef MAC_OSX 9234 OSErr err;
9177 FSRef fref; 9235 AEDesc desc;
9178 #endif 9236
9179 char unix_path_name[MAXPATHLEN]; 9237 err = GetFlavorData (theDrag, theItem, flavorTypeHFS,
9180 9238 &data, &size, 0L);
9181 GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); 9239 if (err == noErr)
9182 #ifdef MAC_OSX 9240 err = AECoercePtr (typeFSS, &data.fileSpec, sizeof (FSSpec),
9183 /* Use Carbon routines, otherwise it converts the file name 9241 TYPE_FILE_NAME, &desc);
9184 to /Macintosh HD/..., which is not correct. */ 9242 if (err == noErr)
9185 FSpMakeFSRef (&data.fileSpec, &fref); 9243 {
9186 if (! FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))); 9244 Lisp_Object file;
9187 #else 9245
9188 if (fsspec_to_posix_pathname (&data.fileSpec, unix_path_name, 9246 /* x-dnd functions expect undecoded filenames. */
9189 sizeof (unix_path_name) - 1) == noErr) 9247 file = make_uninit_string (AEGetDescDataSize (&desc));
9190 #endif 9248 err = AEGetDescData (&desc, SDATA (file), SBYTES (file));
9191 /* x-dnd functions expect undecoded filenames. */ 9249 if (err == noErr)
9192 file_list = Fcons (make_unibyte_string (unix_path_name, 9250 file_list = Fcons (file, file_list);
9193 strlen (unix_path_name)), 9251 AEDisposeDesc (&desc);
9194 file_list); 9252 }
9195 } 9253 }
9196 } 9254 }
9197 /* If there are items in the list, construct an event and post it to 9255 /* If there are items in the list, construct an event and post it to
9198 the queue like an interrupt using kbd_buffer_store_event. */ 9256 the queue like an interrupt using kbd_buffer_store_event. */
9199 if (!NILP (file_list)) 9257 if (!NILP (file_list))
9211 event.modifiers = mac_to_emacs_modifiers (modifiers); 9269 event.modifiers = mac_to_emacs_modifiers (modifiers);
9212 event.timestamp = TickCount () * (1000 / 60); 9270 event.timestamp = TickCount () * (1000 / 60);
9213 XSETINT (event.x, mouse.h); 9271 XSETINT (event.x, mouse.h);
9214 XSETINT (event.y, mouse.v); 9272 XSETINT (event.y, mouse.v);
9215 XSETFRAME (frame, f); 9273 XSETFRAME (frame, f);
9216 event.frame_or_window = Fcons (frame, file_list); 9274 event.frame_or_window = frame;
9217 event.arg = Qnil; 9275 event.arg = file_list;
9218 /* Post to the interrupt queue */ 9276 /* Post to the interrupt queue */
9219 kbd_buffer_store_event (&event); 9277 kbd_buffer_store_event (&event);
9220 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */ 9278 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */
9221 { 9279 {
9222 ProcessSerialNumber psn; 9280 ProcessSerialNumber psn;
9228 } 9286 }
9229 else 9287 else
9230 return dragNotAcceptedErr; 9288 return dragNotAcceptedErr;
9231 } 9289 }
9232 #endif 9290 #endif
9233
9234
9235 /* Print Document Apple Event */
9236 static pascal OSErr
9237 do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon)
9238 {
9239 return errAEEventNotHandled;
9240 }
9241
9242
9243 static pascal OSErr
9244 do_ae_quit_application (AppleEvent* message, AppleEvent *reply, long refcon)
9245 {
9246 #if USE_CARBON_EVENTS
9247 OSErr err;
9248 EventRef event = NULL;
9249 static const HICommand quit_command = {kEventAttributeNone, kHICommandQuit};
9250
9251 err = CreateEvent (NULL, kEventClassCommand, kEventCommandProcess, 0,
9252 kEventAttributeUserEvent, &event);
9253 if (err == noErr)
9254 err = SetEventParameter (event, kEventParamDirectObject, typeHICommand,
9255 sizeof (HICommand), &quit_command);
9256 if (err == noErr)
9257 mac_store_application_menu_event (event);
9258 if (event)
9259 ReleaseEvent (event);
9260
9261 if (err == noErr)
9262 return noErr;
9263 else
9264 return errAEEventNotHandled;
9265 #else
9266 mac_store_application_menu_event (kHICommandQuit);
9267
9268 return noErr;
9269 #endif
9270 }
9271 9291
9272 9292
9273 #if __profile__ 9293 #if __profile__
9274 void 9294 void
9275 profiler_exit_proc () 9295 profiler_exit_proc ()
9319 9339
9320 init_emacs_passwd_dir (); 9340 init_emacs_passwd_dir ();
9321 9341
9322 init_environ (); 9342 init_environ ();
9323 9343
9344 init_coercion_handler ();
9345
9324 initialize_applescript (); 9346 initialize_applescript ();
9325 9347
9326 init_required_apple_events (); 9348 init_apple_event_handler ();
9327 9349
9328 { 9350 {
9329 char **argv; 9351 char **argv;
9330 int argc = 0; 9352 int argc = 0;
9331 9353
9385 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/, 9407 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/,
9386 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/, 9408 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/,
9387 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0 9409 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
9388 }; 9410 };
9389 9411
9412
9390 static int 9413 static int
9391 keycode_to_xkeysym (int keyCode, int *xKeySym) 9414 keycode_to_xkeysym (int keyCode, int *xKeySym)
9392 { 9415 {
9393 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f]; 9416 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f];
9394 return *xKeySym != 0; 9417 return *xKeySym != 0;
9395 } 9418 }
9419
9420 static unsigned char fn_keycode_to_xkeysym_table[] = {
9421 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9422 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9423 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9424
9425 /*0x30*/ 0, 0, 0, 0,
9426 /*0x34*/ 0, 0, 0, 0,
9427 /*0x38*/ 0, 0, 0, 0,
9428 /*0x3C*/ 0, 0, 0, 0,
9429
9430 /*0x40*/ 0, 0x2e /*kp-. = .*/, 0, 0x50 /*kp-* = 'p'*/,
9431 /*0x44*/ 0, '/' /*kp-+*/, 0, 0,
9432 /*0x48*/ 0, 0, 0, 0x30 /*kp-/ = '0'*/,
9433 /*0x4C*/ 0, 0, 0x3b /*kp-- = ';'*/, 0,
9434
9435 /*0x50*/ 0, 0x2d /*kp-= = '-'*/, 0x6d /*kp-0 = 'm'*/, 0x6a /*kp-1 = 'j'*/,
9436 /*0x54*/ 0x6b /*kp-2 = 'k'*/, 0x6c /*kp-3 = 'l'*/, 'u' /*kp-4*/, 'i' /*kp-5*/,
9437 /*0x58*/ 'o' /*kp-6*/, '7' /*kp-7*/, 0, '8' /*kp-8*/,
9438 /*0x5C*/ '9' /*kp-9*/, 0, 0, 0,
9439
9440 /*0x60*/ 0, 0, 0, 0,
9441 /*0x64*/ 0, 0, 0, 0,
9442 /*0x68*/ 0, 0, 0, 0,
9443 /*0x6C*/ 0, 0, 0, 0,
9444
9445 /*0x70*/ 0, 0, 0, 0,
9446 /*0x74*/ 0, 0, 0, 0,
9447 /*0x78*/ 0, 0, 0, 0,
9448 /*0x7C*/ 0, 0, 0, 0
9449 };
9450 static int
9451 convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9452 {
9453 #ifdef MAC_OSX
9454 /* Use the special map to translate keys when function modifier is
9455 to be caught. KeyTranslate can't be used in that case.
9456 We can't detect the function key using the input_event.modifiers,
9457 because this uses the high word of an UInt32. Therefore,
9458 we'll just read it out of the original eventRef.
9459 */
9460
9461
9462 /* TODO / known issues
9463
9464 - Fn-Shift-j is regonized as Fn-j and not Fn-J.
9465 The above table always translates to lower characters. We need to use
9466 the KCHR keyboard resource (KeyTranslate() ) to map k->K and 8->*.
9467
9468 - The table is meant for English language keyboards, and it will work
9469 for many others with the exception of key combinations like Fn-ö on
9470 a German keyboard, which is currently mapped to Fn-;.
9471 How to solve this without keeping separate tables for all keyboards
9472 around? KeyTranslate isn't of much help here, as it only takes a 16-bit
9473 value for keycode with the modifiers in he high byte, i.e. no room for the
9474 Fn modifier. That's why we need the table.
9475
9476 */
9477
9478 UInt32 mods = 0;
9479 if (!NILP(Vmac_function_modifier))
9480 {
9481 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
9482 sizeof (UInt32), NULL, &mods);
9483 if (mods & kEventKeyModifierFnMask)
9484 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f];
9485
9486 return (*newCode != 0);
9487 }
9488 }
9489 #endif
9490 return false;
9491 }
9492
9493 static int
9494 backtranslate_modified_keycode(int mods, int keycode, int def)
9495 {
9496 EventModifiers mapped_modifiers =
9497 (NILP (Vmac_control_modifier) ? 0 : controlKey)
9498 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
9499 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
9500
9501 if (mods & mapped_modifiers)
9502 {
9503 /* This code comes from Keyboard Resource,
9504 Appendix C of IM - Text. This is necessary
9505 since shift is ignored in KCHR table
9506 translation when option or command is pressed.
9507 It also does not translate correctly
9508 control-shift chars like C-% so mask off shift
9509 here also.
9510
9511 Not done for combinations with the option key (alt)
9512 unless it is to be caught by Emacs: this is
9513 to preserve key combinations translated by the OS
9514 such as Alt-3.
9515 */
9516 /* Mask off modifier keys that are mapped to some Emacs
9517 modifiers. */
9518 int new_modifiers = mods & ~mapped_modifiers;
9519 /* set high byte of keycode to modifier high byte*/
9520 int new_keycode = keycode | new_modifiers;
9521 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9522 unsigned long some_state = 0;
9523 return (int) KeyTranslate (kchr_ptr, new_keycode,
9524 &some_state) & 0xff;
9525 /* TO DO: Recognize two separate resulting characters, "for
9526 example, when the user presses Option-E followed by N, you
9527 can map this through the KeyTranslate function using the
9528 U.S. 'KCHR' resource to produce ´n, which KeyTranslate
9529 returns as two characters in the bytes labeled Character code
9530 1 and Character code 2." (from Carbon API doc) */
9531
9532 }
9533 else
9534 return def;
9535 }
9536
9396 9537
9397 #if !USE_CARBON_EVENTS 9538 #if !USE_CARBON_EVENTS
9398 static RgnHandle mouse_region = NULL; 9539 static RgnHandle mouse_region = NULL;
9399 9540
9400 Boolean 9541 Boolean
9409 9550
9410 if (mouse_region == NULL) 9551 if (mouse_region == NULL)
9411 mouse_region = NewRgn (); 9552 mouse_region = NewRgn ();
9412 9553
9413 event_mask = everyEvent; 9554 event_mask = everyEvent;
9414 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) 9555 if (!mac_ready_for_apple_events)
9415 event_mask -= highLevelEventMask; 9556 event_mask -= highLevelEventMask;
9416 9557
9417 current_tick = TickCount (); 9558 current_tick = TickCount ();
9418 target_tick = current_tick + sleep_time; 9559 target_tick = current_tick + sleep_time;
9419 9560
9520 buttons to the correct handler. */ 9661 buttons to the correct handler. */
9521 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 9662 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9522 != eventNotHandledErr) 9663 != eventNotHandledErr)
9523 break; 9664 break;
9524 #endif 9665 #endif
9666 last_mouse_glyph_frame = 0;
9525 9667
9526 if (dpyinfo->grabbed && last_mouse_frame 9668 if (dpyinfo->grabbed && last_mouse_frame
9527 && FRAME_LIVE_P (last_mouse_frame)) 9669 && FRAME_LIVE_P (last_mouse_frame))
9528 { 9670 {
9529 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame); 9671 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
9931 /* When using Carbon Events, we need to pass raw keyboard 10073 /* When using Carbon Events, we need to pass raw keyboard
9932 events to the TSM ourselves. If TSM handles it, it 10074 events to the TSM ourselves. If TSM handles it, it
9933 will pass back noErr, otherwise it will pass back 10075 will pass back noErr, otherwise it will pass back
9934 "eventNotHandledErr" and we can process it 10076 "eventNotHandledErr" and we can process it
9935 normally. */ 10077 normally. */
9936 if ((!NILP (Vmac_pass_command_to_system) 10078 if ((mac_pass_command_to_system
9937 || !(er.modifiers & cmdKey)) 10079 || !(er.modifiers & cmdKey))
9938 && (!NILP (Vmac_pass_control_to_system) 10080 && (mac_pass_control_to_system
9939 || !(er.modifiers & controlKey)) 10081 || !(er.modifiers & controlKey))
9940 && (!NILP (Vmac_command_key_is_meta) 10082 && (NILP (Vmac_option_modifier)
9941 && NILP (Vmac_option_modifier)
9942 || !(er.modifiers & optionKey))) 10083 || !(er.modifiers & optionKey)))
9943 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 10084 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9944 != eventNotHandledErr) 10085 != eventNotHandledErr)
9945 break; 10086 break;
9946 #endif 10087 #endif
9980 { 10121 {
9981 clear_mouse_face (dpyinfo); 10122 clear_mouse_face (dpyinfo);
9982 dpyinfo->mouse_face_hidden = 1; 10123 dpyinfo->mouse_face_hidden = 1;
9983 } 10124 }
9984 10125
9985 if (keycode_to_xkeysym (keycode, &xkeysym)) 10126 /* translate the keycode back to determine the original key */
10127 /* Convert key code if function key is pressed.
10128 Otherwise, if non-ASCII-event, take care of that
10129 without re-translating the key code. */
10130 #if USE_CARBON_EVENTS
10131 if (convert_fn_keycode (eventRef, keycode, &xkeysym))
9986 { 10132 {
9987 inev.code = 0xff00 | xkeysym; 10133 inev.code = xkeysym;
9988 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10134 /* this doesn't work - tried to add shift modifiers */
10135 inev.code =
10136 backtranslate_modified_keycode(er.modifiers & (~0x2200),
10137 xkeysym | 0x80, xkeysym);
10138 inev.kind = ASCII_KEYSTROKE_EVENT;
9989 } 10139 }
9990 else 10140 else
9991 { 10141 #endif
9992 if (er.modifiers & (controlKey | 10142 if (keycode_to_xkeysym (keycode, &xkeysym))
9993 (NILP (Vmac_command_key_is_meta) ? optionKey 10143 {
9994 : cmdKey))) 10144 inev.code = 0xff00 | xkeysym;
9995 { 10145 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
9996 /* This code comes from Keyboard Resource, 10146 }
9997 Appendix C of IM - Text. This is necessary 10147 else
9998 since shift is ignored in KCHR table 10148 {
9999 translation when option or command is pressed. 10149 inev.code =
10000 It also does not translate correctly 10150 backtranslate_modified_keycode(er.modifiers, keycode,
10001 control-shift chars like C-% so mask off shift 10151 er.message & charCodeMask);
10002 here also */ 10152 inev.kind = ASCII_KEYSTROKE_EVENT;
10003 int new_modifiers = er.modifiers & 0xe600; 10153 }
10004 /* mask off option and command */
10005 int new_keycode = keycode | new_modifiers;
10006 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
10007 unsigned long some_state = 0;
10008 inev.code = KeyTranslate (kchr_ptr, new_keycode,
10009 &some_state) & 0xff;
10010 }
10011 else if (!NILP (Vmac_option_modifier)
10012 && (er.modifiers & optionKey))
10013 {
10014 /* When using the option key as an emacs modifier,
10015 convert the pressed key code back to one
10016 without the Mac option modifier applied. */
10017 int new_modifiers = er.modifiers & ~optionKey;
10018 int new_keycode = keycode | new_modifiers;
10019 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
10020 unsigned long some_state = 0;
10021 inev.code = KeyTranslate (kchr_ptr, new_keycode,
10022 &some_state) & 0xff;
10023 }
10024 else
10025 inev.code = er.message & charCodeMask;
10026 inev.kind = ASCII_KEYSTROKE_EVENT;
10027 }
10028 } 10154 }
10029 10155
10030 #if USE_CARBON_EVENTS 10156 #if USE_CARBON_EVENTS
10031 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 10157 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
10032 #else 10158 #else
10249 #endif 10375 #endif
10250 10376
10251 main_device_handle = LMGetMainDevice(); 10377 main_device_handle = LMGetMainDevice();
10252 10378
10253 dpyinfo->reference_count = 0; 10379 dpyinfo->reference_count = 0;
10254 dpyinfo->resx = 75.0; 10380 dpyinfo->resx = 72.0;
10255 dpyinfo->resy = 75.0; 10381 dpyinfo->resy = 72.0;
10256 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); 10382 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType);
10257 #ifdef MAC_OSX 10383 #ifdef MAC_OSX
10258 /* HasDepth returns true if it is possible to have a 32 bit display, 10384 /* HasDepth returns true if it is possible to have a 32 bit display,
10259 but this may not be what is actually used. Mac OSX can do better. 10385 but this may not be what is actually used. Mac OSX can do better.
10260 CGMainDisplayID is only available on OSX 10.2 and higher, but the 10386 CGMainDisplayID is only available on OSX 10.2 and higher, but the
10462 /* Todo: Determine modifiers from quit_char. */ 10588 /* Todo: Determine modifiers from quit_char. */
10463 UInt32 qc_modifiers = ctrl_modifier; 10589 UInt32 qc_modifiers = ctrl_modifier;
10464 10590
10465 /* Map modifiers */ 10591 /* Map modifiers */
10466 mac_quit_char_modifiers = 0; 10592 mac_quit_char_modifiers = 0;
10467 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= macCtrlKey; 10593 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey;
10468 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= macShiftKey; 10594 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey;
10469 if (qc_modifiers & meta_modifier) mac_quit_char_modifiers |= macMetaKey; 10595 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey;
10470 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= macAltKey;
10471 } 10596 }
10472 10597
10473 static void 10598 static void
10474 init_quit_char_handler () 10599 init_quit_char_handler ()
10475 { 10600 {
10590 Fset_input_mode (Qt, Qnil, Qt, Qnil); 10715 Fset_input_mode (Qt, Qnil, Qt, Qnil);
10591 10716
10592 BLOCK_INPUT; 10717 BLOCK_INPUT;
10593 10718
10594 #if TARGET_API_MAC_CARBON 10719 #if TARGET_API_MAC_CARBON
10595 init_required_apple_events ();
10596 10720
10597 #if USE_CARBON_EVENTS 10721 #if USE_CARBON_EVENTS
10598 #ifdef MAC_OSX 10722 #ifdef MAC_OSX
10599 init_service_handler (); 10723 init_service_handler ();
10600 10724
10605 10729
10606 init_menu_bar (); 10730 init_menu_bar ();
10607 #endif /* USE_CARBON_EVENTS */ 10731 #endif /* USE_CARBON_EVENTS */
10608 10732
10609 #ifdef MAC_OSX 10733 #ifdef MAC_OSX
10734 init_coercion_handler ();
10735
10736 init_apple_event_handler ();
10737
10610 if (!inhibit_window_system) 10738 if (!inhibit_window_system)
10611 MakeMeTheFrontProcess (); 10739 MakeMeTheFrontProcess ();
10612 #endif 10740 #endif
10613 #endif 10741 #endif
10614 UNBLOCK_INPUT; 10742 UNBLOCK_INPUT;
10621 #if 0 10749 #if 0
10622 staticpro (&x_error_message_string); 10750 staticpro (&x_error_message_string);
10623 x_error_message_string = Qnil; 10751 x_error_message_string = Qnil;
10624 #endif 10752 #endif
10625 10753
10754 Qcontrol = intern ("control"); staticpro (&Qcontrol);
10755 Qmeta = intern ("meta"); staticpro (&Qmeta);
10756 Qalt = intern ("alt"); staticpro (&Qalt);
10757 Qhyper = intern ("hyper"); staticpro (&Qhyper);
10758 Qsuper = intern ("super"); staticpro (&Qsuper);
10626 Qmodifier_value = intern ("modifier-value"); 10759 Qmodifier_value = intern ("modifier-value");
10627 Qalt = intern ("alt"); 10760 staticpro (&Qmodifier_value);
10628 Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); 10761
10629 Qhyper = intern ("hyper"); 10762 Fput (Qcontrol, Qmodifier_value, make_number (ctrl_modifier));
10630 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); 10763 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
10631 Qsuper = intern ("super"); 10764 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
10632 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); 10765 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
10633 10766 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
10634 Qapplication = intern ("application"); staticpro (&Qapplication); 10767
10635 Qabout = intern ("about"); staticpro (&Qabout); 10768 #if USE_CARBON_EVENTS
10636 10769 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand);
10637 #if USE_CARBON_EVENTS && defined (MAC_OSX) 10770 #ifdef MAC_OSX
10638 Qpreferences = intern ("preferences"); staticpro (&Qpreferences);
10639 Qservices = intern ("services"); staticpro (&Qservices); 10771 Qservices = intern ("services"); staticpro (&Qservices);
10640 Qpaste = intern ("paste"); staticpro (&Qpaste); 10772 Qpaste = intern ("paste"); staticpro (&Qpaste);
10641 Qperform = intern ("perform"); staticpro (&Qperform); 10773 Qperform = intern ("perform"); staticpro (&Qperform);
10642 #endif 10774 #endif
10775 #endif
10643 10776
10644 #ifdef MAC_OSX 10777 #ifdef MAC_OSX
10645 Fprovide (intern ("mac-carbon"), Qnil); 10778 Fprovide (intern ("mac-carbon"), Qnil);
10646 #endif 10779 #endif
10647 10780
10648 staticpro (&Qreverse); 10781 staticpro (&Qreverse);
10649 Qreverse = intern ("reverse"); 10782 Qreverse = intern ("reverse");
10650
10651 staticpro (&Qmac_ready_for_drag_n_drop);
10652 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
10653 10783
10654 staticpro (&x_display_name_list); 10784 staticpro (&x_display_name_list);
10655 x_display_name_list = Qnil; 10785 x_display_name_list = Qnil;
10656 10786
10657 staticpro (&last_mouse_scroll_bar); 10787 staticpro (&last_mouse_scroll_bar);
10662 10792
10663 #if USE_ATSUI 10793 #if USE_ATSUI
10664 staticpro (&atsu_font_id_hash); 10794 staticpro (&atsu_font_id_hash);
10665 atsu_font_id_hash = Qnil; 10795 atsu_font_id_hash = Qnil;
10666 #endif 10796 #endif
10797
10798 /* We don't yet support this, but defining this here avoids whining
10799 from cus-start.el and other places, like "M-x set-variable". */
10800 DEFVAR_BOOL ("x-use-underline-position-properties",
10801 &x_use_underline_position_properties,
10802 doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
10803 nil means ignore them. If you encounter fonts with bogus
10804 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10805 to 4.1, set this to nil.
10806
10807 NOTE: Not supported on Mac yet. */);
10808 x_use_underline_position_properties = 0;
10667 10809
10668 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 10810 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
10669 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 10811 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
10670 #ifdef USE_TOOLKIT_SCROLL_BARS 10812 #ifdef USE_TOOLKIT_SCROLL_BARS
10671 Vx_toolkit_scroll_bars = Qt; 10813 Vx_toolkit_scroll_bars = Qt;
10674 #endif 10816 #endif
10675 10817
10676 staticpro (&last_mouse_motion_frame); 10818 staticpro (&last_mouse_motion_frame);
10677 last_mouse_motion_frame = Qnil; 10819 last_mouse_motion_frame = Qnil;
10678 10820
10679 DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta, 10821 /* Variables to configure modifier key assignment. */
10680 doc: /* Non-nil means that the command key is used as the Emacs meta key. 10822
10681 Otherwise the option key is used. */); 10823 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier,
10682 Vmac_command_key_is_meta = Qt; 10824 doc: /* *Modifier key assumed when the Mac control key is pressed.
10825 The value can be `control', `meta', `alt', `hyper', or `super' for the
10826 respective modifier. The default is `control'. */);
10827 Vmac_control_modifier = Qcontrol;
10683 10828
10684 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, 10829 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
10685 doc: /* Modifier to use for the Mac alt/option key. The value can 10830 doc: /* *Modifier key assumed when the Mac alt/option key is pressed.
10686 be alt, hyper, or super for the respective modifier. If the value is 10831 The value can be `control', `meta', `alt', `hyper', or `super' for the
10687 nil then the key will act as the normal Mac option modifier. */); 10832 respective modifier. If the value is nil then the key will act as the
10833 normal Mac control modifier, and the option key can be used to compose
10834 characters depending on the chosen Mac keyboard setting. */);
10688 Vmac_option_modifier = Qnil; 10835 Vmac_option_modifier = Qnil;
10689 10836
10690 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 10837 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier,
10691 doc: /* Non-nil means that the control and meta keys are reversed. This is 10838 doc: /* *Modifier key assumed when the Mac command key is pressed.
10692 useful for non-standard keyboard layouts. */); 10839 The value can be `control', `meta', `alt', `hyper', or `super' for the
10693 Vmac_reverse_ctrl_meta = Qnil; 10840 respective modifier. The default is `meta'. */);
10841 Vmac_command_modifier = Qmeta;
10842
10843 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier,
10844 doc: /* *Modifier key assumed when the Mac function key is pressed.
10845 The value can be `control', `meta', `alt', `hyper', or `super' for the
10846 respective modifier. Note that remapping the function key may lead to
10847 unexpected results for some keys on non-US/GB keyboards. */);
10848 Vmac_function_modifier = Qnil;
10694 10849
10695 DEFVAR_LISP ("mac-emulate-three-button-mouse", 10850 DEFVAR_LISP ("mac-emulate-three-button-mouse",
10696 &Vmac_emulate_three_button_mouse, 10851 &Vmac_emulate_three_button_mouse,
10697 doc: /* t means that when the option-key is held down while pressing the 10852 doc: /* *Specify a way of three button mouse emulation.
10698 mouse button, the click will register as mouse-2 and while the 10853 The value can be nil, t, or the symbol `reverse'.
10699 command-key is held down, the click will register as mouse-3. 10854 nil means that no emulation should be done and the modifiers should be
10700 'reverse means that the option-key will register for mouse-3 10855 placed on the mouse-1 event.
10701 and the command-key will register for mouse-2. nil means that 10856 t means that when the option-key is held down while pressing the mouse
10702 no emulation should be done and the modifiers should be placed 10857 button, the click will register as mouse-2 and while the command-key
10703 on the mouse-1 event. */); 10858 is held down, the click will register as mouse-3.
10859 The symbol `reverse' means that the option-key will register for
10860 mouse-3 and the command-key will register for mouse-2. */);
10704 Vmac_emulate_three_button_mouse = Qnil; 10861 Vmac_emulate_three_button_mouse = Qnil;
10705 10862
10706 #if USE_CARBON_EVENTS 10863 #if USE_CARBON_EVENTS
10707 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, 10864 DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2,
10708 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and 10865 doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3.
10709 the right click will be mouse-3. 10866 Otherwise, the right click will be treated as mouse-2 and the wheel
10710 Otherwise, the right click will be mouse-2 and the wheel button mouse-3.*/); 10867 button will be mouse-3. */);
10711 Vmac_wheel_button_is_mouse_2 = Qt; 10868 mac_wheel_button_is_mouse_2 = 1;
10712 10869
10713 DEFVAR_LISP ("mac-pass-command-to-system", &Vmac_pass_command_to_system, 10870 DEFVAR_BOOL ("mac-pass-command-to-system", &mac_pass_command_to_system,
10714 doc: /* If non-nil, the Mac \"Command\" key is passed on to the Mac 10871 doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */);
10715 Toolbox for processing before Emacs sees it. */); 10872 mac_pass_command_to_system = 1;
10716 Vmac_pass_command_to_system = Qt; 10873
10717 10874 DEFVAR_BOOL ("mac-pass-control-to-system", &mac_pass_control_to_system,
10718 DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system, 10875 doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */);
10719 doc: /* If non-nil, the Mac \"Control\" key is passed on to the Mac 10876 mac_pass_control_to_system = 1;
10720 Toolbox for processing before Emacs sees it. */); 10877
10721 Vmac_pass_control_to_system = Qt; 10878 #endif
10722 10879
10723 #endif 10880 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics,
10724 10881 doc: /* *If non-nil, allow anti-aliasing.
10725 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,
10726 doc: /* If non-nil, allow anti-aliasing.
10727 The text will be rendered using Core Graphics text rendering which 10882 The text will be rendered using Core Graphics text rendering which
10728 may anti-alias the text. */); 10883 may anti-alias the text. */);
10729 Vmac_use_core_graphics = Qnil; 10884 mac_use_core_graphics = 0;
10730 10885
10731 /* Register an entry for `mac-roman' so that it can be used when 10886 /* Register an entry for `mac-roman' so that it can be used when
10732 creating the terminal frame on Mac OS 9 before loading 10887 creating the terminal frame on Mac OS 9 before loading
10733 term/mac-win.elc. */ 10888 term/mac-win.elc. */
10734 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist, 10889 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,
10735 doc: /* Alist linking Emacs character sets to Mac text encoding and Emacs coding system. 10890 doc: /* Alist of Emacs character sets vs text encodings and coding systems.
10736 Each entry should be of the form: 10891 Each entry should be of the form:
10737 10892
10738 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM) 10893 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM)
10739 10894
10740 where CHARSET-NAME is a string used in font names to identify the 10895 where CHARSET-NAME is a string used in font names to identify the
10741 charset, TEXT-ENCODING is a TextEncodingBase value, and CODING_SYSTEM 10896 charset, TEXT-ENCODING is a TextEncodingBase value in Mac, and
10742 is a coding system corresponding to TEXT-ENCODING. */); 10897 CODING_SYSTEM is a coding system corresponding to TEXT-ENCODING. */);
10743 Vmac_charset_info_alist = 10898 Vmac_charset_info_alist =
10744 Fcons (list3 (build_string ("mac-roman"), 10899 Fcons (list3 (build_string ("mac-roman"),
10745 make_number (smRoman), Qnil), Qnil); 10900 make_number (smRoman), Qnil), Qnil);
10746 } 10901 }
10747 10902