aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-11-13 05:46:52 +0000
committerYAMAMOTO Mitsuharu2005-11-13 05:46:52 +0000
commit16805b2eef3e21ef98353c2eee6e28519f2dd245 (patch)
tree23050cc7bef66904ea181f20c1aa5de87545b887 /src
parent26d2699b2204785b9955d0b0fa685674ac6cc501 (diff)
downloademacs-16805b2eef3e21ef98353c2eee6e28519f2dd245.tar.gz
emacs-16805b2eef3e21ef98353c2eee6e28519f2dd245.zip
[USE_CG_TEXT_DRAWING] (mac_draw_string_cg): New function.
(x_draw_glyph_string_foreground) [USE_CG_TEXT_DRAWING]: Use it. (XLoadQueryFont) [USE_CG_TEXT_DRAWING]: Set members cg_font and cg_glyphs in struct MacFontStruct if synthesized bold or italic is not used and font substitution never occurs for ASCII and Latin-1 characters. (XLoadQueryFont): Maximum and minimum metrics are now those among ASCII characters. (XLoadQueryFont) [!MAC_OS8 || USE_ATSUI]: Apply WebKit-style height adjustments for Courier, Helvetica, and Times.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c252
1 files changed, 206 insertions, 46 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 95d6dfa9fff..5ac3255daca 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -86,7 +86,7 @@ Boston, MA 02110-1301, USA. */
86#include "intervals.h" 86#include "intervals.h"
87#include "atimer.h" 87#include "atimer.h"
88#include "keymap.h" 88#include "keymap.h"
89 89
90 90
91 91
92/* Non-nil means Emacs uses toolkit scroll bars. */ 92/* Non-nil means Emacs uses toolkit scroll bars. */
@@ -771,7 +771,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
771 QDEndCGContext (port, &context); 771 QDEndCGContext (port, &context);
772#if 0 772#if 0
773 /* This doesn't work on Mac OS X 10.1. */ 773 /* This doesn't work on Mac OS X 10.1. */
774 ATSUClearLayoutControls (text_layout, 774 ATSUClearLayoutControls (text_layout,
775 sizeof (tags) / sizeof (tags[0]), 775 sizeof (tags) / sizeof (tags[0]),
776 tags); 776 tags);
777#else 777#else
@@ -864,6 +864,77 @@ mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
864} 864}
865 865
866 866
867#if USE_CG_TEXT_DRAWING
868static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *));
869
870static int
871mac_draw_string_cg (f, gc, x, y, buf, nchars)
872 struct frame *f;
873 GC gc;
874 int x, y;
875 XChar2b *buf;
876 int nchars;
877{
878 CGrafPtr port;
879 float port_height, gx, gy;
880 int i;
881 CGContextRef context;
882 CGGlyph *glyphs;
883 CGSize *advances;
884
885 if (NILP (Vmac_use_core_graphics) || GC_FONT (gc)->cg_font == NULL)
886 return 0;
887
888 port = GetWindowPort (FRAME_MAC_WINDOW (f));
889 port_height = FRAME_PIXEL_HEIGHT (f);
890 gx = x;
891 gy = port_height - y;
892 glyphs = (CGGlyph *)buf;
893 advances = xmalloc (sizeof (CGSize) * nchars);
894 for (i = 0; i < nchars; i++)
895 {
896 advances[i].width = x_per_char_metric (GC_FONT (gc), buf)->width;
897 advances[i].height = 0;
898 glyphs[i] = GC_FONT (gc)->cg_glyphs[buf->byte2];
899 buf++;
900 }
901
902 QDBeginCGContext (port, &context);
903 if (gc->n_clip_rects)
904 {
905 CGContextTranslateCTM (context, 0, port_height);
906 CGContextScaleCTM (context, 1, -1);
907 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
908 CGContextScaleCTM (context, 1, -1);
909 CGContextTranslateCTM (context, 0, -port_height);
910 }
911 CGContextSetRGBFillColor (context,
912 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
913 GREEN_FROM_ULONG (gc->xgcv.foreground) / 255.0,
914 BLUE_FROM_ULONG (gc->xgcv.foreground) / 255.0,
915 1.0);
916 CGContextSetFont (context, GC_FONT (gc)->cg_font);
917 CGContextSetFontSize (context, GC_FONT (gc)->mac_fontsize);
918#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
919 CGContextSetTextPosition (context, gx, gy);
920 CGContextShowGlyphsWithAdvances (context, glyphs, advances, nchars);
921#else
922 for (i = 0; i < nchars; i++)
923 {
924 CGContextShowGlyphsAtPoint (context, gx, gy, glyphs + i, 1);
925 gx += advances[i].width;
926 }
927#endif
928 CGContextSynchronize (context);
929 QDEndCGContext (port, &context);
930
931 xfree (advances);
932
933 return 1;
934}
935#endif
936
937
867/* Mac replacement for XCopyArea: dest must be window. */ 938/* Mac replacement for XCopyArea: dest must be window. */
868 939
869static void 940static void
@@ -2258,6 +2329,13 @@ x_draw_glyph_string_foreground (s)
2258 || GC_FONT (s->gc)->mac_style 2329 || GC_FONT (s->gc)->mac_style
2259#endif 2330#endif
2260 ) 2331 )
2332#if USE_CG_TEXT_DRAWING
2333 if (!s->two_byte_p
2334 && mac_draw_string_cg (s->f, s->gc, x, s->ybase - boff,
2335 s->char2b, s->nchars))
2336 ;
2337 else
2338#endif
2261 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff, 2339 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2262 s->char2b, s->nchars); 2340 s->char2b, s->nchars);
2263 else 2341 else
@@ -7281,6 +7359,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7281 Str31 charset; 7359 Str31 charset;
7282 SInt16 fontnum; 7360 SInt16 fontnum;
7283#if USE_ATSUI 7361#if USE_ATSUI
7362 static ATSUFontID font_id;
7284 ATSUStyle mac_style = NULL; 7363 ATSUStyle mac_style = NULL;
7285#endif 7364#endif
7286 Style fontface; 7365 Style fontface;
@@ -7315,7 +7394,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7315 kATSUQDBoldfaceTag, kATSUQDItalicTag}; 7394 kATSUQDBoldfaceTag, kATSUQDItalicTag};
7316 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), 7395 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
7317 sizeof (Boolean), sizeof (Boolean)}; 7396 sizeof (Boolean), sizeof (Boolean)};
7318 static ATSUFontID font_id;
7319 static Fixed size_fixed; 7397 static Fixed size_fixed;
7320 static Boolean bold_p, italic_p; 7398 static Boolean bold_p, italic_p;
7321 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed, 7399 ATSUAttributeValuePtr values[] = {&font_id, &size_fixed,
@@ -7369,6 +7447,10 @@ XLoadQueryFont (Display *dpy, char *fontname)
7369 font->mac_scriptcode = scriptcode; 7447 font->mac_scriptcode = scriptcode;
7370#if USE_ATSUI 7448#if USE_ATSUI
7371 font->mac_style = mac_style; 7449 font->mac_style = mac_style;
7450#if USE_CG_TEXT_DRAWING
7451 font->cg_font = NULL;
7452 font->cg_glyphs = NULL;
7453#endif
7372#endif 7454#endif
7373 7455
7374 /* Apple Japanese (SJIS) font is listed as both 7456 /* Apple Japanese (SJIS) font is listed as both
@@ -7398,6 +7480,30 @@ XLoadQueryFont (Display *dpy, char *fontname)
7398 } 7480 }
7399 bzero (font->per_char, sizeof (XCharStruct) * 0x10000); 7481 bzero (font->per_char, sizeof (XCharStruct) * 0x10000);
7400 7482
7483#if USE_CG_TEXT_DRAWING
7484 {
7485 FMFontFamily font_family;
7486 FMFontStyle style;
7487 ATSFontRef ats_font;
7488
7489 err = FMGetFontFamilyInstanceFromFont (font_id, &font_family, &style);
7490 if (err == noErr)
7491 err = FMGetFontFromFontFamilyInstance (font_family, fontface,
7492 &font_id, &style);
7493 /* Use CG text drawing if italic/bold is not synthesized. */
7494 if (err == noErr && style == fontface)
7495 {
7496 ats_font = FMGetATSFontRefFromFont (font_id);
7497 font->cg_font = CGFontCreateWithPlatformFont (&ats_font);
7498 }
7499 }
7500
7501 if (font->cg_font)
7502 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7503 if (font->cg_glyphs)
7504 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7505#endif
7506
7401 err = atsu_get_text_layout_with_text_ptr (&c, 1, 7507 err = atsu_get_text_layout_with_text_ptr (&c, 1,
7402 font->mac_style, 7508 font->mac_style,
7403 &text_layout); 7509 &text_layout);
@@ -7407,8 +7513,19 @@ XLoadQueryFont (Display *dpy, char *fontname)
7407 return NULL; 7513 return NULL;
7408 } 7514 }
7409 7515
7410 for (c = 0x20; c <= 0x7e; c++) 7516 for (c = 0x20; c <= 0xff; c++)
7411 { 7517 {
7518 if (c == 0xad)
7519 /* Soft hyphen is not supported in ATSUI. */
7520 continue;
7521 else if (c == 0x7f)
7522 {
7523 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7524 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7525 c = 0x9f;
7526 continue;
7527 }
7528
7412 err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning); 7529 err = ATSUClearLayoutCache (text_layout, kATSUFromTextBeginning);
7413 if (err == noErr) 7530 if (err == noErr)
7414 err = ATSUMeasureTextImage (text_layout, 7531 err = ATSUMeasureTextImage (text_layout,
@@ -7457,9 +7574,32 @@ XLoadQueryFont (Display *dpy, char *fontname)
7457 } 7574 }
7458 } 7575 }
7459 } 7576 }
7577#if USE_CG_TEXT_DRAWING
7578 if (err == noErr && char_width > 0 && font->cg_font)
7579 {
7580 ATSUGlyphInfoArray glyph_info_array;
7581 ByteCount count = sizeof (ATSUGlyphInfoArray);
7582
7583 err = ATSUMatchFontsToText (text_layout, kATSUFromTextBeginning,
7584 kATSUToTextEnd, NULL, NULL, NULL);
7585 if (err == noErr)
7586 err = ATSUGetGlyphInfo (text_layout, kATSUFromTextBeginning,
7587 kATSUToTextEnd, &count,
7588 &glyph_info_array);
7589 if (err == noErr)
7590 font->cg_glyphs[c] = glyph_info_array.glyphs[0].glyphID;
7591 else
7592 {
7593 /* Don't use CG text drawing if font substitution
7594 occurs in ASCII or Latin-1 characters. */
7595 CGFontRelease (font->cg_font);
7596 font->cg_font = NULL;
7597 xfree (font->cg_glyphs);
7598 font->cg_glyphs = NULL;
7599 }
7600 }
7601#endif
7460 } 7602 }
7461 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7462 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7463 7603
7464 font->min_byte1 = 0; 7604 font->min_byte1 = 0;
7465 font->max_byte1 = 0xff; 7605 font->max_byte1 = 0xff;
@@ -7572,6 +7712,13 @@ XLoadQueryFont (Display *dpy, char *fontname)
7572 SetRect (&max_bounds, 0, 0, 0, 0); 7712 SetRect (&max_bounds, 0, 0, 0, 0);
7573 for (c = 0x20; c <= 0xff; c++) 7713 for (c = 0x20; c <= 0xff; c++)
7574 { 7714 {
7715 if (c == 0x7f)
7716 {
7717 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7718 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7719 continue;
7720 }
7721
7575 ch = c; 7722 ch = c;
7576 char_width = CharWidth (ch); 7723 char_width = CharWidth (ch);
7577 QDTextBounds (1, &ch, &char_bounds); 7724 QDTextBounds (1, &ch, &char_bounds);
@@ -7594,8 +7741,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7594 UnionRect (&max_bounds, &char_bounds, &max_bounds); 7741 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7595 } 7742 }
7596 } 7743 }
7597 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7598 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7599 if (min_width == max_width 7744 if (min_width == max_width
7600 && max_bounds.left >= 0 && max_bounds.right <= max_width) 7745 && max_bounds.left >= 0 && max_bounds.right <= max_width)
7601 { 7746 {
@@ -7611,6 +7756,15 @@ XLoadQueryFont (Display *dpy, char *fontname)
7611 TextFace (old_fontface); 7756 TextFace (old_fontface);
7612 } 7757 }
7613 7758
7759#if !defined (MAC_OS8) || USE_ATSUI
7760 /* AppKit and WebKit do some adjustment to the heights of Courier,
7761 Helvetica, and Times. This only works on the environments where
7762 the XDrawImageString counterpart is never used. */
7763 if (strcmp (family, "courier") == 0 || strcmp (family, "helvetica") == 0
7764 || strcmp (family, "times") == 0)
7765 font->ascent += (font->ascent + font->descent) * .15 + 0.5;
7766#endif
7767
7614 return font; 7768 return font;
7615} 7769}
7616 7770
@@ -7626,6 +7780,12 @@ mac_unload_font (dpyinfo, font)
7626#if USE_ATSUI 7780#if USE_ATSUI
7627 if (font->mac_style) 7781 if (font->mac_style)
7628 ATSUDisposeStyle (font->mac_style); 7782 ATSUDisposeStyle (font->mac_style);
7783#if USE_CG_TEXT_DRAWING
7784 if (font->cg_font)
7785 CGFontRelease (font->cg_font);
7786 if (font->cg_glyphs)
7787 xfree (font->cg_glyphs);
7788#endif
7629#endif 7789#endif
7630 xfree (font); 7790 xfree (font);
7631} 7791}
@@ -8000,16 +8160,16 @@ mac_to_emacs_modifiers (EventModifiers mods)
8000 unsigned int result = 0; 8160 unsigned int result = 0;
8001 if (mods & shiftKey) 8161 if (mods & shiftKey)
8002 result |= shift_modifier; 8162 result |= shift_modifier;
8003 8163
8004 8164
8005 8165
8006 /* Deactivated to simplify configuration: 8166 /* Deactivated to simplify configuration:
8007 if Vmac_option_modifier is non-NIL, we fully process the Option 8167 if Vmac_option_modifier is non-NIL, we fully process the Option
8008 key. Otherwise, we only process it if an additional Ctrl or Command 8168 key. Otherwise, we only process it if an additional Ctrl or Command
8009 is pressed. That way the system may convert the character to a 8169 is pressed. That way the system may convert the character to a
8010 composed one. 8170 composed one.
8011 if ((mods & optionKey) && 8171 if ((mods & optionKey) &&
8012 (( !NILP(Vmac_option_modifier) || 8172 (( !NILP(Vmac_option_modifier) ||
8013 ((mods & cmdKey) || (mods & controlKey))))) */ 8173 ((mods & cmdKey) || (mods & controlKey))))) */
8014 8174
8015 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { 8175 if (!NILP (Vmac_option_modifier) && (mods & optionKey)) {
@@ -8021,21 +8181,21 @@ mac_to_emacs_modifiers (EventModifiers mods)
8021 Lisp_Object val = Fget(Vmac_command_modifier, Qmodifier_value); 8181 Lisp_Object val = Fget(Vmac_command_modifier, Qmodifier_value);
8022 if (INTEGERP(val)) 8182 if (INTEGERP(val))
8023 result |= XUINT(val); 8183 result |= XUINT(val);
8024 } 8184 }
8025 if (!NILP (Vmac_control_modifier) && (mods & controlKey)) { 8185 if (!NILP (Vmac_control_modifier) && (mods & controlKey)) {
8026 Lisp_Object val = Fget(Vmac_control_modifier, Qmodifier_value); 8186 Lisp_Object val = Fget(Vmac_control_modifier, Qmodifier_value);
8027 if (INTEGERP(val)) 8187 if (INTEGERP(val))
8028 result |= XUINT(val); 8188 result |= XUINT(val);
8029 } 8189 }
8030 8190
8031#ifdef MAC_OSX 8191#ifdef MAC_OSX
8032 if (!NILP (Vmac_function_modifier) && (mods & kEventKeyModifierFnMask)) { 8192 if (!NILP (Vmac_function_modifier) && (mods & kEventKeyModifierFnMask)) {
8033 Lisp_Object val = Fget(Vmac_function_modifier, Qmodifier_value); 8193 Lisp_Object val = Fget(Vmac_function_modifier, Qmodifier_value);
8034 if (INTEGERP(val)) 8194 if (INTEGERP(val))
8035 result |= XUINT(val); 8195 result |= XUINT(val);
8036 } 8196 }
8037#endif 8197#endif
8038 8198
8039 return result; 8199 return result;
8040} 8200}
8041 8201
@@ -9407,7 +9567,7 @@ static unsigned char keycode_to_xkeysym_table[] = {
9407}; 9567};
9408 9568
9409 9569
9410static int 9570static int
9411keycode_to_xkeysym (int keyCode, int *xKeySym) 9571keycode_to_xkeysym (int keyCode, int *xKeySym)
9412{ 9572{
9413 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f]; 9573 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f];
@@ -9448,7 +9608,7 @@ static int
9448convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode) 9608convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9449{ 9609{
9450#ifdef MAC_OSX 9610#ifdef MAC_OSX
9451 /* Use the special map to translate keys when function modifier is 9611 /* Use the special map to translate keys when function modifier is
9452 to be caught. KeyTranslate can't be used in that case. 9612 to be caught. KeyTranslate can't be used in that case.
9453 We can't detect the function key using the input_event.modifiers, 9613 We can't detect the function key using the input_event.modifiers,
9454 because this uses the high word of an UInt32. Therefore, 9614 because this uses the high word of an UInt32. Therefore,
@@ -9464,7 +9624,7 @@ convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9464 9624
9465 - The table is meant for English language keyboards, and it will work 9625 - The table is meant for English language keyboards, and it will work
9466 for many others with the exception of key combinations like Fn-ö on 9626 for many others with the exception of key combinations like Fn-ö on
9467 a German keyboard, which is currently mapped to Fn-;. 9627 a German keyboard, which is currently mapped to Fn-;.
9468 How to solve this without keeping separate tables for all keyboards 9628 How to solve this without keeping separate tables for all keyboards
9469 around? KeyTranslate isn't of much help here, as it only takes a 16-bit 9629 around? KeyTranslate isn't of much help here, as it only takes a 16-bit
9470 value for keycode with the modifiers in he high byte, i.e. no room for the 9630 value for keycode with the modifiers in he high byte, i.e. no room for the
@@ -9473,13 +9633,13 @@ convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9473 */ 9633 */
9474 9634
9475 UInt32 mods = 0; 9635 UInt32 mods = 0;
9476 if (!NILP(Vmac_function_modifier)) 9636 if (!NILP(Vmac_function_modifier))
9477 { 9637 {
9478 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 9638 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
9479 sizeof (UInt32), NULL, &mods); 9639 sizeof (UInt32), NULL, &mods);
9480 if (mods & kEventKeyModifierFnMask) 9640 if (mods & kEventKeyModifierFnMask)
9481 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f]; 9641 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f];
9482 9642
9483 return (*newCode != 0); 9643 return (*newCode != 0);
9484 } 9644 }
9485 } 9645 }
@@ -9487,12 +9647,12 @@ convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9487 return false; 9647 return false;
9488} 9648}
9489 9649
9490static int 9650static int
9491backtranslate_modified_keycode(int mods, int keycode, int def) 9651backtranslate_modified_keycode(int mods, int keycode, int def)
9492{ 9652{
9493 if (mods & 9653 if (mods &
9494 (controlKey | 9654 (controlKey |
9495 (NILP (Vmac_option_modifier) ? 0 : optionKey) | 9655 (NILP (Vmac_option_modifier) ? 0 : optionKey) |
9496 cmdKey)) 9656 cmdKey))
9497 { 9657 {
9498 /* This code comes from Keyboard Resource, 9658 /* This code comes from Keyboard Resource,
@@ -9504,12 +9664,12 @@ backtranslate_modified_keycode(int mods, int keycode, int def)
9504 here also. 9664 here also.
9505 9665
9506 Not done for combinations with the option key (alt) 9666 Not done for combinations with the option key (alt)
9507 unless it is to be caught by Emacs: this is 9667 unless it is to be caught by Emacs: this is
9508 to preserve key combinations translated by the OS 9668 to preserve key combinations translated by the OS
9509 such as Alt-3. 9669 such as Alt-3.
9510 */ 9670 */
9511 /* mask off option and command */ 9671 /* mask off option and command */
9512 int new_modifiers = mods & 0xe600; 9672 int new_modifiers = mods & 0xe600;
9513 /* set high byte of keycode to modifier high byte*/ 9673 /* set high byte of keycode to modifier high byte*/
9514 int new_keycode = keycode | new_modifiers; 9674 int new_keycode = keycode | new_modifiers;
9515 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); 9675 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
@@ -10126,26 +10286,26 @@ XTread_socket (sd, expected, hold_quit)
10126 { 10286 {
10127 inev.code = xkeysym; 10287 inev.code = xkeysym;
10128 /* this doesn't work - tried to add shift modifiers */ 10288 /* this doesn't work - tried to add shift modifiers */
10129 inev.code = 10289 inev.code =
10130 backtranslate_modified_keycode(er.modifiers & (~0x2200), 10290 backtranslate_modified_keycode(er.modifiers & (~0x2200),
10131 xkeysym | 0x80, xkeysym); 10291 xkeysym | 0x80, xkeysym);
10132 inev.kind = ASCII_KEYSTROKE_EVENT; 10292 inev.kind = ASCII_KEYSTROKE_EVENT;
10133 } 10293 }
10134 else 10294 else
10135#endif 10295#endif
10136 if (keycode_to_xkeysym (keycode, &xkeysym)) 10296 if (keycode_to_xkeysym (keycode, &xkeysym))
10137 { 10297 {
10138 inev.code = 0xff00 | xkeysym; 10298 inev.code = 0xff00 | xkeysym;
10139 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10299 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
10140 } 10300 }
10141 else 10301 else
10142 { 10302 {
10143 10303
10144 inev.code = 10304 inev.code =
10145 backtranslate_modified_keycode(er.modifiers, keycode, 10305 backtranslate_modified_keycode(er.modifiers, keycode,
10146 er.message & charCodeMask); 10306 er.message & charCodeMask);
10147 inev.kind = ASCII_KEYSTROKE_EVENT; 10307 inev.kind = ASCII_KEYSTROKE_EVENT;
10148 10308
10149 } 10309 }
10150 } 10310 }
10151 10311
@@ -10587,7 +10747,7 @@ mac_determine_quit_char_modifiers()
10587 /* Map modifiers */ 10747 /* Map modifiers */
10588 mac_quit_char_modifiers = 0; 10748 mac_quit_char_modifiers = 0;
10589 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey; 10749 if (qc_modifiers & ctrl_modifier) mac_quit_char_modifiers |= controlKey;
10590 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey; 10750 if (qc_modifiers & shift_modifier) mac_quit_char_modifiers |= shiftKey;
10591 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey; 10751 if (qc_modifiers & alt_modifier) mac_quit_char_modifiers |= optionKey;
10592} 10752}
10593 10753
@@ -10748,7 +10908,7 @@ syms_of_macterm ()
10748 Qctrl = intern ("ctrl"); 10908 Qctrl = intern ("ctrl");
10749 Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier)); 10909 Fput (Qctrl, Qmodifier_value, make_number (ctrl_modifier));
10750 Qmeta = intern ("meta"); 10910 Qmeta = intern ("meta");
10751 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); 10911 Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
10752 Qalt = intern ("alt"); 10912 Qalt = intern ("alt");
10753 Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); 10913 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
10754 Qhyper = intern ("hyper"); 10914 Qhyper = intern ("hyper");
@@ -10800,13 +10960,13 @@ syms_of_macterm ()
10800 10960
10801 staticpro (&last_mouse_motion_frame); 10961 staticpro (&last_mouse_motion_frame);
10802 last_mouse_motion_frame = Qnil; 10962 last_mouse_motion_frame = Qnil;
10803 10963
10804 10964
10805 10965
10806/* Variables to configure modifier key assignment. */ 10966/* Variables to configure modifier key assignment. */
10807 10967
10808 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier, 10968 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier,
10809 doc: /* Modifier key assumed when the Mac control key is pressed. 10969 doc: /* Modifier key assumed when the Mac control key is pressed.
10810The value can be `alt', `ctrl', `hyper', or `super' for the respective 10970The value can be `alt', `ctrl', `hyper', or `super' for the respective
10811modifier. The default is `ctrl'. */); 10971modifier. The default is `ctrl'. */);
10812 Vmac_control_modifier = Qctrl; 10972 Vmac_control_modifier = Qctrl;
@@ -10815,18 +10975,18 @@ modifier. The default is `ctrl'. */);
10815 doc: /* Modifier key assumed when the Mac alt/option key is pressed. 10975 doc: /* Modifier key assumed when the Mac alt/option key is pressed.
10816The value can be `alt', `ctrl', `hyper', or `super' for the respective 10976The value can be `alt', `ctrl', `hyper', or `super' for the respective
10817modifier. If the value is nil then the key will act as the normal 10977modifier. If the value is nil then the key will act as the normal
10818Mac control modifier, and the option key can be used to compose 10978Mac control modifier, and the option key can be used to compose
10819characters depending on the chosen Mac keyboard setting. */); 10979characters depending on the chosen Mac keyboard setting. */);
10820 Vmac_option_modifier = Qnil; 10980 Vmac_option_modifier = Qnil;
10821 10981
10822 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier, 10982 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier,
10823 doc: /* Modifier key assumed when the Mac command key is pressed. 10983 doc: /* Modifier key assumed when the Mac command key is pressed.
10824The value can be `alt', `ctrl', `hyper', or `super' for the respective 10984The value can be `alt', `ctrl', `hyper', or `super' for the respective
10825modifier. The default is `meta'. */); 10985modifier. The default is `meta'. */);
10826 Vmac_command_modifier = Qmeta; 10986 Vmac_command_modifier = Qmeta;
10827 10987
10828 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier, 10988 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier,
10829 doc: /* Modifier key assumed when the Mac function key is pressed. 10989 doc: /* Modifier key assumed when the Mac function key is pressed.
10830The value can be `alt', `ctrl', `hyper', or `super' for the respective 10990The value can be `alt', `ctrl', `hyper', or `super' for the respective
10831modifier. Note that remapping the function key may lead to unexpected 10991modifier. Note that remapping the function key may lead to unexpected
10832results for some keys on non-US/GB keyboards. */); 10992results for some keys on non-US/GB keyboards. */);