aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/macterm.c226
2 files changed, 128 insertions, 108 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 56e375d55b5..e71981695d2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12006-07-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macterm.c (keycode_to_xkeysym): Remove function. All uses now
4 directly lookup keycode_to_xkeysym_table.
5 [USE_MAC_TSM] (mac_handle_text_input_event): Don't construct
6 ASCII_KEYSTROKE_EVENT for non-zero keycode_to_xkeysym_table entries.
7 (XTread_socket): Use character codes to construct keypad key events.
8 (mac_initialize_display_info) [MAC_OSX]: Use CGDisplaySamplesPerPixel.
9 (x_delete_display): Apply 2006-07-04 change for xterm.c.
10
12006-07-17 Kim F. Storm <storm@cua.dk> 112006-07-17 Kim F. Storm <storm@cua.dk>
2 12
3 * xdisp.c (handle_single_display_spec): Ensure the right value of 13 * xdisp.c (handle_single_display_spec): Ensure the right value of
diff --git a/src/macterm.c b/src/macterm.c
index 0b6c0fca31c..a6274114a25 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -8587,6 +8587,81 @@ extern int emacs_main (int, char **, char **);
8587extern void initialize_applescript(); 8587extern void initialize_applescript();
8588extern void terminate_applescript(); 8588extern void terminate_applescript();
8589 8589
8590/* Table for translating Mac keycode to X keysym values. Contributed
8591 by Sudhir Shenoy.
8592 Mapping for special keys is now identical to that in Apple X11
8593 except `clear' (-> <clear>) on the KeyPad, `enter' (-> <kp-enter>)
8594 on the right of the Cmd key on laptops, and fn + `enter' (->
8595 <linefeed>). */
8596static unsigned char keycode_to_xkeysym_table[] = {
8597 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8598 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8599 /*0x20*/ 0, 0, 0, 0, 0x0d /*return*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8600
8601 /*0x30*/ 0x09 /*tab*/, 0 /*0x0020 space*/, 0, 0x08 /*backspace*/,
8602 /*0x34*/ 0x8d /*enter on laptops*/, 0x1b /*escape*/, 0, 0,
8603 /*0x38*/ 0, 0, 0, 0,
8604 /*0x3C*/ 0, 0, 0, 0,
8605
8606 /*0x40*/ 0, 0xae /*kp-decimal*/, 0, 0xaa /*kp-multiply*/,
8607 /*0x44*/ 0, 0xab /*kp-add*/, 0, 0x0b /*clear*/,
8608 /*0x48*/ 0, 0, 0, 0xaf /*kp-divide*/,
8609 /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp-subtract*/, 0,
8610
8611 /*0x50*/ 0, 0xbd /*kp-equal*/, 0xb0 /*kp-0*/, 0xb1 /*kp-1*/,
8612 /*0x54*/ 0xb2 /*kp-2*/, 0xb3 /*kp-3*/, 0xb4 /*kp-4*/, 0xb5 /*kp-5*/,
8613 /*0x58*/ 0xb6 /*kp-6*/, 0xb7 /*kp-7*/, 0, 0xb8 /*kp-8*/,
8614 /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,
8615
8616 /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,
8617 /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,
8618 /*0x68*/ 0, 0xca /*f13*/, 0xcd /*f16*/, 0xcb /*f14*/,
8619 /*0x6C*/ 0, 0xc7 /*f10*/, 0x0a /*fn+enter on laptops*/, 0xc9 /*f12*/,
8620
8621 /*0x70*/ 0, 0xcc /*f15*/, 0x6a /*help*/, 0x50 /*home*/,
8622 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/,
8623 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/,
8624 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
8625};
8626
8627#ifdef MAC_OSX
8628/* Table for translating Mac keycode with the laptop `fn' key to that
8629 without it. Destination symbols in comments are keys on US
8630 keyboard, and they may not be the same on other types of keyboards.
8631 If the destination is identical to the source (f1 ... f12), it
8632 doesn't map `fn' key to a modifier. */
8633static unsigned char fn_keycode_to_keycode_table[] = {
8634 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8635 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8636 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8637
8638 /*0x30*/ 0, 0, 0, 0,
8639 /*0x34*/ 0, 0, 0, 0,
8640 /*0x38*/ 0, 0, 0, 0,
8641 /*0x3C*/ 0, 0, 0, 0,
8642
8643 /*0x40*/ 0, 0x2f /*kp-decimal -> '.'*/, 0, 0x23 /*kp-multiply -> 'p'*/,
8644 /*0x44*/ 0, 0x2c /*kp-add -> '/'*/, 0, 0x16 /*clear -> '6'*/,
8645 /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
8646 /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-subtract -> ';'*/, 0,
8647
8648 /*0x50*/ 0, 0x1b /*kp-equal -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
8649 /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
8650 /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
8651 /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
8652
8653 /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/,
8654 /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/,
8655 /*0x68*/ 0, 0, 0, 0,
8656 /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/,
8657
8658 /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
8659 /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/,
8660 /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0,
8661 /*0x7C*/ 0, 0, 0, 0
8662};
8663#endif /* MAC_OSX */
8664
8590static unsigned int 8665static unsigned int
8591#if USE_CARBON_EVENTS 8666#if USE_CARBON_EVENTS
8592mac_to_emacs_modifiers (UInt32 mods) 8667mac_to_emacs_modifiers (UInt32 mods)
@@ -9650,7 +9725,6 @@ mac_handle_text_input_event (next_handler, event, data)
9650 { 9725 {
9651 EventRef kbd_event; 9726 EventRef kbd_event;
9652 UInt32 actual_size, modifiers, mapped_modifiers; 9727 UInt32 actual_size, modifiers, mapped_modifiers;
9653 UniChar code;
9654 9728
9655 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent, 9729 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent,
9656 typeEventRef, NULL, sizeof (EventRef), NULL, 9730 typeEventRef, NULL, sizeof (EventRef), NULL,
@@ -9678,26 +9752,37 @@ mac_handle_text_input_event (next_handler, event, data)
9678 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, 9752 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
9679 typeUnicodeText, NULL, 0, &actual_size, 9753 typeUnicodeText, NULL, 0, &actual_size,
9680 NULL); 9754 NULL);
9681 if (err == noErr) 9755 if (err == noErr && actual_size == sizeof (UniChar))
9682 { 9756 {
9683 if (actual_size == sizeof (UniChar)) 9757 UniChar code;
9684 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes, 9758
9685 typeUnicodeText, NULL, 9759 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
9686 sizeof (UniChar), NULL, &code); 9760 typeUnicodeText, NULL,
9761 sizeof (UniChar), NULL, &code);
9687 if (err == noErr && code < 0x80) 9762 if (err == noErr && code < 0x80)
9688 { 9763 {
9689 /* ASCII character. Process it in XTread_socket. */ 9764 /* ASCII character. Process it in XTread_socket. */
9690 if (read_socket_inev && code >= 0x20 && code <= 0x7e) 9765 if (read_socket_inev && code >= 0x20 && code <= 0x7e)
9691 { 9766 {
9692 struct frame *f = mac_focus_frame (&one_mac_display_info); 9767 UInt32 key_code;
9693 9768
9694 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT; 9769 err = GetEventParameter (kbd_event, kEventParamKeyCode,
9695 read_socket_inev->code = code; 9770 typeUInt32, NULL, sizeof (UInt32),
9696 read_socket_inev->modifiers = 9771 NULL, &key_code);
9697 (extra_keyboard_modifiers 9772 if (!(err == noErr && key_code <= 0x7f
9698 & (meta_modifier | alt_modifier 9773 && keycode_to_xkeysym_table [key_code]))
9699 | hyper_modifier | super_modifier)); 9774 {
9700 XSETFRAME (read_socket_inev->frame_or_window, f); 9775 struct frame *f =
9776 mac_focus_frame (&one_mac_display_info);
9777
9778 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT;
9779 read_socket_inev->code = code;
9780 read_socket_inev->modifiers =
9781 (extra_keyboard_modifiers
9782 & (meta_modifier | alt_modifier
9783 | hyper_modifier | super_modifier));
9784 XSETFRAME (read_socket_inev->frame_or_window, f);
9785 }
9701 } 9786 }
9702 return eventNotHandledErr; 9787 return eventNotHandledErr;
9703 } 9788 }
@@ -9970,89 +10055,6 @@ main (void)
9970} 10055}
9971#endif 10056#endif
9972 10057
9973/* Table for translating Mac keycode to X keysym values. Contributed
9974 by Sudhir Shenoy.
9975 Mapping for special keys is now identical to that in Apple X11
9976 except `clear' (-> <clear>) on the KeyPad, `enter' (-> <kp-enter>)
9977 on the right of the Cmd key on laptops, and fn + `enter' (->
9978 <linefeed>). */
9979static unsigned char keycode_to_xkeysym_table[] = {
9980 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9981 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9982 /*0x20*/ 0, 0, 0, 0, 0x0d /*return*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9983
9984 /*0x30*/ 0x09 /*tab*/, 0 /*0x0020 space*/, 0, 0x08 /*backspace*/,
9985 /*0x34*/ 0x8d /*enter on laptops*/, 0x1b /*escape*/, 0, 0,
9986 /*0x38*/ 0, 0, 0, 0,
9987 /*0x3C*/ 0, 0, 0, 0,
9988
9989 /*0x40*/ 0, 0xae /*kp-.*/, 0, 0xaa /*kp-**/,
9990 /*0x44*/ 0, 0xab /*kp-+*/, 0, 0x0b /*clear*/,
9991 /*0x48*/ 0, 0, 0, 0xaf /*kp-/*/,
9992 /*0x4C*/ 0x8d /*kp-enter*/, 0, 0xad /*kp--*/, 0,
9993
9994 /*0x50*/ 0, 0xbd /*kp-=*/, 0xb0 /*kp-0*/, 0xb1 /*kp-1*/,
9995 /*0x54*/ 0xb2 /*kp-2*/, 0xb3 /*kp-3*/, 0xb4 /*kp-4*/, 0xb5 /*kp-5*/,
9996 /*0x58*/ 0xb6 /*kp-6*/, 0xb7 /*kp-7*/, 0, 0xb8 /*kp-8*/,
9997 /*0x5C*/ 0xb9 /*kp-9*/, 0, 0, 0,
9998
9999 /*0x60*/ 0xc2 /*f5*/, 0xc3 /*f6*/, 0xc4 /*f7*/, 0xc0 /*f3*/,
10000 /*0x64*/ 0xc5 /*f8*/, 0xc6 /*f9*/, 0, 0xc8 /*f11*/,
10001 /*0x68*/ 0, 0xca /*f13*/, 0xcd /*f16*/, 0xcb /*f14*/,
10002 /*0x6C*/ 0, 0xc7 /*f10*/, 0x0a /*fn+enter on laptops*/, 0xc9 /*f12*/,
10003
10004 /*0x70*/ 0, 0xcc /*f15*/, 0x6a /*help*/, 0x50 /*home*/,
10005 /*0x74*/ 0x55 /*pgup*/, 0xff /*delete*/, 0xc1 /*f4*/, 0x57 /*end*/,
10006 /*0x78*/ 0xbf /*f2*/, 0x56 /*pgdown*/, 0xbe /*f1*/, 0x51 /*left*/,
10007 /*0x7C*/ 0x53 /*right*/, 0x54 /*down*/, 0x52 /*up*/, 0
10008};
10009
10010
10011static int
10012keycode_to_xkeysym (int keyCode, int *xKeySym)
10013{
10014 *xKeySym = keycode_to_xkeysym_table [keyCode & 0x7f];
10015 return *xKeySym != 0;
10016}
10017
10018#ifdef MAC_OSX
10019/* Table for translating Mac keycode with the laptop `fn' key to that
10020 without it. Destination symbols in comments are keys on US
10021 keyboard, and they may not be the same on other types of keyboards.
10022 If the destination is identical to the source (f1 ... f12), it
10023 doesn't map `fn' key to a modifier. */
10024static unsigned char fn_keycode_to_keycode_table[] = {
10025 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10026 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10027 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10028
10029 /*0x30*/ 0, 0, 0, 0,
10030 /*0x34*/ 0, 0, 0, 0,
10031 /*0x38*/ 0, 0, 0, 0,
10032 /*0x3C*/ 0, 0, 0, 0,
10033
10034 /*0x40*/ 0, 0x2f /*kp-. -> '.'*/, 0, 0x23 /*kp-* -> 'p'*/,
10035 /*0x44*/ 0, 0x2c /*kp-+ -> '/'*/, 0, 0x16 /*clear -> '6'*/,
10036 /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
10037 /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-- -> ';'*/, 0,
10038
10039 /*0x50*/ 0, 0x1b /*kp-= -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
10040 /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
10041 /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
10042 /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
10043
10044 /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/,
10045 /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/,
10046 /*0x68*/ 0, 0, 0, 0,
10047 /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/,
10048
10049 /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
10050 /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/,
10051 /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0,
10052 /*0x7C*/ 0, 0, 0, 0
10053};
10054#endif /* MAC_OSX */
10055
10056#if !USE_CARBON_EVENTS 10058#if !USE_CARBON_EVENTS
10057static RgnHandle mouse_region = NULL; 10059static RgnHandle mouse_region = NULL;
10058 10060
@@ -10679,7 +10681,7 @@ XTread_socket (sd, expected, hold_quit)
10679 case autoKey: 10681 case autoKey:
10680 { 10682 {
10681 int keycode = (er.message & keyCodeMask) >> 8; 10683 int keycode = (er.message & keyCodeMask) >> 8;
10682 int xkeysym; 10684 int char_code = er.message & charCodeMask;
10683 static SInt16 last_key_script = -1; 10685 static SInt16 last_key_script = -1;
10684 SInt16 current_key_script; 10686 SInt16 current_key_script;
10685 UInt32 modifiers = er.modifiers, mapped_modifiers; 10687 UInt32 modifiers = er.modifiers, mapped_modifiers;
@@ -10758,10 +10760,15 @@ XTread_socket (sd, expected, hold_quit)
10758 && fn_keycode_to_keycode_table[keycode]) 10760 && fn_keycode_to_keycode_table[keycode])
10759 keycode = fn_keycode_to_keycode_table[keycode]; 10761 keycode = fn_keycode_to_keycode_table[keycode];
10760#endif 10762#endif
10761 if (keycode_to_xkeysym (keycode, &xkeysym)) 10763 if (keycode <= 0x7f && keycode_to_xkeysym_table [keycode])
10762 { 10764 {
10763 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10765 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
10764 inev.code = 0xff00 | xkeysym; 10766 inev.code = 0xff00 | keycode_to_xkeysym_table [keycode];
10767 /* Some keyboards (e.g., German, French ones) use
10768 different layouts for keypad keys. */
10769 if (inev.code >= 0xffaa && inev.code <= 0xffbd
10770 && char_code >= 0x2a && char_code <= 0x3d)
10771 inev.code = 0xff80 | char_code;
10765#ifdef MAC_OSX 10772#ifdef MAC_OSX
10766 if (modifiers & kEventKeyModifierFnMask 10773 if (modifiers & kEventKeyModifierFnMask
10767 && keycode <= 0x7f 10774 && keycode <= 0x7f
@@ -10845,7 +10852,7 @@ XTread_socket (sd, expected, hold_quit)
10845 if (inev.kind == NO_EVENT) 10852 if (inev.kind == NO_EVENT)
10846 { 10853 {
10847 inev.kind = ASCII_KEYSTROKE_EVENT; 10854 inev.kind = ASCII_KEYSTROKE_EVENT;
10848 inev.code = er.message & charCodeMask; 10855 inev.code = char_code;
10849 } 10856 }
10850 10857
10851 inev.modifiers = mac_to_emacs_modifiers (modifiers); 10858 inev.modifiers = mac_to_emacs_modifiers (modifiers);
@@ -11101,7 +11108,7 @@ mac_initialize_display_info ()
11101#ifdef MAC_OSX 11108#ifdef MAC_OSX
11102 /* HasDepth returns true if it is possible to have a 32 bit display, 11109 /* HasDepth returns true if it is possible to have a 32 bit display,
11103 but this may not be what is actually used. Mac OSX can do better. */ 11110 but this may not be what is actually used. Mac OSX can do better. */
11104 dpyinfo->color_p = 1; 11111 dpyinfo->color_p = CGDisplaySamplesPerPixel (kCGDirectMainDisplay) > 1;
11105 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay); 11112 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay);
11106 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay); 11113 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
11107 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay); 11114 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay);
@@ -11232,11 +11239,14 @@ x_delete_display (dpyinfo)
11232 xfree (dpyinfo->font_table[i].name); 11239 xfree (dpyinfo->font_table[i].name);
11233 } 11240 }
11234 11241
11235 if (dpyinfo->font_table->font_encoder) 11242 if (dpyinfo->font_table)
11236 xfree (dpyinfo->font_table->font_encoder); 11243 {
11237 11244 if (dpyinfo->font_table->font_encoder)
11238 xfree (dpyinfo->font_table); 11245 xfree (dpyinfo->font_table->font_encoder);
11239 xfree (dpyinfo->mac_id_name); 11246 xfree (dpyinfo->font_table);
11247 }
11248 if (dpyinfo->mac_id_name)
11249 xfree (dpyinfo->mac_id_name);
11240 11250
11241 if (x_display_list == 0) 11251 if (x_display_list == 0)
11242 { 11252 {