aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorMiles Bader2006-07-19 00:42:56 +0000
committerMiles Bader2006-07-19 00:42:56 +0000
commit63db3c1b3ffa669435b10aa362115ef664990ab2 (patch)
treea62f68b147d4265ce993136af897d4f348570594 /src/macterm.c
parent2988d6b36d310ba98ea1fed570142f436804fc18 (diff)
parent83676aa2e399363120942ef5ea19f8af6b75e8e8 (diff)
downloademacs-63db3c1b3ffa669435b10aa362115ef664990ab2.tar.gz
emacs-63db3c1b3ffa669435b10aa362115ef664990ab2.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 343-356) - Update from CVS - Update for ERC 5.1.3. - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 113-115) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-90
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c218
1 files changed, 111 insertions, 107 deletions
diff --git a/src/macterm.c b/src/macterm.c
index a6fc6b1a497..e98fc7729c0 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -8608,6 +8608,81 @@ extern int emacs_main (int, char **, char **);
8608extern void initialize_applescript(); 8608extern void initialize_applescript();
8609extern void terminate_applescript(); 8609extern void terminate_applescript();
8610 8610
8611/* Table for translating Mac keycode to X keysym values. Contributed
8612 by Sudhir Shenoy.
8613 Mapping for special keys is now identical to that in Apple X11
8614 except `clear' (-> <clear>) on the KeyPad, `enter' (-> <kp-enter>)
8615 on the right of the Cmd key on laptops, and fn + `enter' (->
8616 <linefeed>). */
8617static unsigned char keycode_to_xkeysym_table[] = {
8618 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8619 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8620 /*0x20*/ 0, 0, 0, 0, 0x0d /*return*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8621
8622 /*0x30*/ 0x09 /*tab*/, 0 /*0x0020 space*/, 0, 0x08 /*backspace*/,
8623 /*0x34*/ 0x8d /*enter on laptops*/, 0x1b /*escape*/, 0, 0,
8624 /*0x38*/ 0, 0, 0, 0,
8625 /*0x3C*/ 0, 0, 0, 0,
8626
8627 /*0x40*/ 0, 0xae /*kp-decimal*/, 0, 0xaa /*kp-multiply*/,
8628 /*0x44*/ 0, 0xab /*kp-add*/, 0, 0x0b /*clear*/,
8629 /*0x48*/ 0, 0, 0, 0xaf /*kp-divide*/,
8630 /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp-subtract*/, 0,
8631
8632 /*0x50*/ 0, 0xbd /*kp-equal*/, 0xb0 /*kp-0*/, 0xb1 /*kp-1*/,
8633 /*0x54*/ 0xb2 /*kp-2*/, 0xb3 /*kp-3*/, 0xb4 /*kp-4*/, 0xb5 /*kp-5*/,
8634 /*0x58*/ 0xb6 /*kp-6*/, 0xb7 /*kp-7*/, 0, 0xb8 /*kp-8*/,
8635 /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,
8636
8637 /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,
8638 /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,
8639 /*0x68*/ 0, 0xca /*f13*/, 0xcd /*f16*/, 0xcb /*f14*/,
8640 /*0x6C*/ 0, 0xc7 /*f10*/, 0x0a /*fn+enter on laptops*/, 0xc9 /*f12*/,
8641
8642 /*0x70*/ 0, 0xcc /*f15*/, 0x6a /*help*/, 0x50 /*home*/,
8643 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/,
8644 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/,
8645 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
8646};
8647
8648#ifdef MAC_OSX
8649/* Table for translating Mac keycode with the laptop `fn' key to that
8650 without it. Destination symbols in comments are keys on US
8651 keyboard, and they may not be the same on other types of keyboards.
8652 If the destination is identical to the source (f1 ... f12), it
8653 doesn't map `fn' key to a modifier. */
8654static unsigned char fn_keycode_to_keycode_table[] = {
8655 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8656 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8657 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8658
8659 /*0x30*/ 0, 0, 0, 0,
8660 /*0x34*/ 0, 0, 0, 0,
8661 /*0x38*/ 0, 0, 0, 0,
8662 /*0x3C*/ 0, 0, 0, 0,
8663
8664 /*0x40*/ 0, 0x2f /*kp-decimal -> '.'*/, 0, 0x23 /*kp-multiply -> 'p'*/,
8665 /*0x44*/ 0, 0x2c /*kp-add -> '/'*/, 0, 0x16 /*clear -> '6'*/,
8666 /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
8667 /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-subtract -> ';'*/, 0,
8668
8669 /*0x50*/ 0, 0x1b /*kp-equal -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
8670 /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
8671 /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
8672 /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
8673
8674 /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/,
8675 /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/,
8676 /*0x68*/ 0, 0, 0, 0,
8677 /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/,
8678
8679 /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
8680 /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/,
8681 /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0,
8682 /*0x7C*/ 0, 0, 0, 0
8683};
8684#endif /* MAC_OSX */
8685
8611static unsigned int 8686static unsigned int
8612#if USE_CARBON_EVENTS 8687#if USE_CARBON_EVENTS
8613mac_to_emacs_modifiers (UInt32 mods) 8688mac_to_emacs_modifiers (UInt32 mods)
@@ -9671,7 +9746,6 @@ mac_handle_text_input_event (next_handler, event, data)
9671 { 9746 {
9672 EventRef kbd_event; 9747 EventRef kbd_event;
9673 UInt32 actual_size, modifiers, mapped_modifiers; 9748 UInt32 actual_size, modifiers, mapped_modifiers;
9674 UniChar code;
9675 9749
9676 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent, 9750 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent,
9677 typeEventRef, NULL, sizeof (EventRef), NULL, 9751 typeEventRef, NULL, sizeof (EventRef), NULL,
@@ -9699,26 +9773,37 @@ mac_handle_text_input_event (next_handler, event, data)
9699 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, 9773 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
9700 typeUnicodeText, NULL, 0, &actual_size, 9774 typeUnicodeText, NULL, 0, &actual_size,
9701 NULL); 9775 NULL);
9702 if (err == noErr) 9776 if (err == noErr && actual_size == sizeof (UniChar))
9703 { 9777 {
9704 if (actual_size == sizeof (UniChar)) 9778 UniChar code;
9705 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, 9779
9706 typeUnicodeText, NULL, 9780 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
9707 sizeof (UniChar), NULL, &code); 9781 typeUnicodeText, NULL,
9782 sizeof (UniChar), NULL, &code);
9708 if (err == noErr && code < 0x80) 9783 if (err == noErr && code < 0x80)
9709 { 9784 {
9710 /* ASCII character. Process it in XTread_socket. */ 9785 /* ASCII character. Process it in XTread_socket. */
9711 if (read_socket_inev && code >= 0x20 && code <= 0x7e) 9786 if (read_socket_inev && code >= 0x20 && code <= 0x7e)
9712 { 9787 {
9713 struct frame *f = mac_focus_frame (&one_mac_display_info); 9788 UInt32 key_code;
9714 9789
9715 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT; 9790 err = GetEventParameter (kbd_event, kEventParamKeyCode,
9716 read_socket_inev->code = code; 9791 typeUInt32, NULL, sizeof (UInt32),
9717 read_socket_inev->modifiers = 9792 NULL, &key_code);
9718 (extra_keyboard_modifiers 9793 if (!(err == noErr && key_code <= 0x7f
9719 & (meta_modifier | alt_modifier 9794 && keycode_to_xkeysym_table [key_code]))
9720 | hyper_modifier | super_modifier)); 9795 {
9721 XSETFRAME (read_socket_inev->frame_or_window, f); 9796 struct frame *f =
9797 mac_focus_frame (&one_mac_display_info);
9798
9799 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT;
9800 read_socket_inev->code = code;
9801 read_socket_inev->modifiers =
9802 (extra_keyboard_modifiers
9803 & (meta_modifier | alt_modifier
9804 | hyper_modifier | super_modifier));
9805 XSETFRAME (read_socket_inev->frame_or_window, f);
9806 }
9722 } 9807 }
9723 return eventNotHandledErr; 9808 return eventNotHandledErr;
9724 } 9809 }
@@ -9991,89 +10076,6 @@ main (void)
9991} 10076}
9992#endif 10077#endif
9993 10078
9994/* Table for translating Mac keycode to X keysym values. Contributed
9995 by Sudhir Shenoy.
9996 Mapping for special keys is now identical to that in Apple X11
9997 except `clear' (-> <clear>) on the KeyPad, `enter' (-> <kp-enter>)
9998 on the right of the Cmd key on laptops, and fn + `enter' (->
9999 <linefeed>). */
10000static unsigned char keycode_to_xkeysym_table[] = {
10001 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10002 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10003 /*0x20*/ 0, 0, 0, 0, 0x0d /*return*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10004
10005 /*0x30*/ 0x09 /*tab*/, 0 /*0x0020 space*/, 0, 0x08 /*backspace*/,
10006 /*0x34*/ 0x8d /*enter on laptops*/, 0x1b /*escape*/, 0, 0,
10007 /*0x38*/ 0, 0, 0, 0,
10008 /*0x3C*/ 0, 0, 0, 0,
10009
10010 /*0x40*/ 0, 0xae /*kp-.*/, 0, 0xaa /*kp-**/,
10011 /*0x44*/ 0, 0xab /*kp-+*/, 0, 0x0b /*clear*/,
10012 /*0x48*/ 0, 0, 0, 0xaf /*kp-/*/,
10013 /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp--*/, 0,
10014
10015 /*0x50*/ 0, 0xbd /*kp-=*/, 0xb0 /*kp-0*/, 0xb1 /*kp-1*/,
10016 /*0x54*/ 0xb2 /*kp-2*/, 0xb3 /*kp-3*/, 0xb4 /*kp-4*/, 0xb5 /*kp-5*/,
10017 /*0x58*/ 0xb6 /*kp-6*/, 0xb7 /*kp-7*/, 0, 0xb8 /*kp-8*/,
10018 /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,
10019
10020 /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,
10021 /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,
10022 /*0x68*/ 0, 0xca /*f13*/, 0xcd /*f16*/, 0xcb /*f14*/,
10023 /*0x6C*/ 0, 0xc7 /*f10*/, 0x0a /*fn+enter on laptops*/, 0xc9 /*f12*/,
10024
10025 /*0x70*/ 0, 0xcc /*f15*/, 0x6a /*help*/, 0x50 /*home*/,
10026 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/,
10027 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/,
10028 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
10029};
10030
10031
10032static int
10033keycode_to_xkeysym (int keyCode, int *xKeySym)
10034{
10035 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f];
10036 return *xKeySym != 0;
10037}
10038
10039#ifdef MAC_OSX
10040/* Table for translating Mac keycode with the laptop `fn' key to that
10041 without it. Destination symbols in comments are keys on US
10042 keyboard, and they may not be the same on other types of keyboards.
10043 If the destination is identical to the source (f1 ... f12), it
10044 doesn't map `fn' key to a modifier. */
10045static unsigned char fn_keycode_to_keycode_table[] = {
10046 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10047 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10048 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10049
10050 /*0x30*/ 0, 0, 0, 0,
10051 /*0x34*/ 0, 0, 0, 0,
10052 /*0x38*/ 0, 0, 0, 0,
10053 /*0x3C*/ 0, 0, 0, 0,
10054
10055 /*0x40*/ 0, 0x2f /*kp-. -> '.'*/, 0, 0x23 /*kp-* -> 'p'*/,
10056 /*0x44*/ 0, 0x2c /*kp-+ -> '/'*/, 0, 0x16 /*clear -> '6'*/,
10057 /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
10058 /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-- -> ';'*/, 0,
10059
10060 /*0x50*/ 0, 0x1b /*kp-= -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
10061 /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
10062 /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
10063 /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
10064
10065 /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/,
10066 /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/,
10067 /*0x68*/ 0, 0, 0, 0,
10068 /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/,
10069
10070 /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
10071 /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/,
10072 /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0,
10073 /*0x7C*/ 0, 0, 0, 0
10074};
10075#endif /* MAC_OSX */
10076
10077#if !USE_CARBON_EVENTS 10079#if !USE_CARBON_EVENTS
10078static RgnHandle mouse_region = NULL; 10080static RgnHandle mouse_region = NULL;
10079 10081
@@ -10676,7 +10678,6 @@ XTread_socket (sd, expected, hold_quit)
10676 case autoKey: 10678 case autoKey:
10677 { 10679 {
10678 int keycode = (er.message & keyCodeMask) >> 8; 10680 int keycode = (er.message & keyCodeMask) >> 8;
10679 int xkeysym;
10680 static SInt16 last_key_script = -1; 10681 static SInt16 last_key_script = -1;
10681 SInt16 current_key_script; 10682 SInt16 current_key_script;
10682 UInt32 modifiers = er.modifiers, mapped_modifiers; 10683 UInt32 modifiers = er.modifiers, mapped_modifiers;
@@ -10755,10 +10756,10 @@ XTread_socket (sd, expected, hold_quit)
10755 && fn_keycode_to_keycode_table[keycode]) 10756 && fn_keycode_to_keycode_table[keycode])
10756 keycode = fn_keycode_to_keycode_table[keycode]; 10757 keycode = fn_keycode_to_keycode_table[keycode];
10757#endif 10758#endif
10758 if (keycode_to_xkeysym (keycode, &xkeysym)) 10759 if (keycode <= 0x7f && keycode_to_xkeysym_table [keycode])
10759 { 10760 {
10760 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10761 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
10761 inev.code = 0xff00 | xkeysym; 10762 inev.code = 0xff00 | keycode_to_xkeysym_table [keycode];
10762#ifdef MAC_OSX 10763#ifdef MAC_OSX
10763 if (modifiers & kEventKeyModifierFnMask 10764 if (modifiers & kEventKeyModifierFnMask
10764 && keycode <= 0x7f 10765 && keycode <= 0x7f
@@ -11098,7 +11099,7 @@ mac_initialize_display_info ()
11098#ifdef MAC_OSX 11099#ifdef MAC_OSX
11099 /* HasDepth returns true if it is possible to have a 32 bit display, 11100 /* HasDepth returns true if it is possible to have a 32 bit display,
11100 but this may not be what is actually used. Mac OSX can do better. */ 11101 but this may not be what is actually used. Mac OSX can do better. */
11101 dpyinfo->color_p = 1; 11102 dpyinfo->color_p = CGDisplaySamplesPerPixel (kCGDirectMainDisplay) > 1;
11102 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay); 11103 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay);
11103 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay); 11104 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
11104 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay); 11105 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay);
@@ -11229,11 +11230,14 @@ x_delete_display (dpyinfo)
11229 xfree (dpyinfo->font_table[i].name); 11230 xfree (dpyinfo->font_table[i].name);
11230 } 11231 }
11231 11232
11232 if (dpyinfo->font_table->font_encoder) 11233 if (dpyinfo->font_table)
11233 xfree (dpyinfo->font_table->font_encoder); 11234 {
11234 11235 if (dpyinfo->font_table->font_encoder)
11235 xfree (dpyinfo->font_table); 11236 xfree (dpyinfo->font_table->font_encoder);
11236 xfree (dpyinfo->mac_id_name); 11237 xfree (dpyinfo->font_table);
11238 }
11239 if (dpyinfo->mac_id_name)
11240 xfree (dpyinfo->mac_id_name);
11237 11241
11238 if (x_display_list == 0) 11242 if (x_display_list == 0)
11239 { 11243 {