diff options
| author | YAMAMOTO Mitsuharu | 2008-02-04 03:03:52 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2008-02-04 03:03:52 +0000 |
| commit | 10fdc4c2483e5286345ce05c37c1b54a0963bc14 (patch) | |
| tree | d85c2620e0817da7de7fb47fb1b044658fd61238 /src | |
| parent | 7ff926e0aa431bbabe43a291fe0b555e83378df3 (diff) | |
| download | emacs-10fdc4c2483e5286345ce05c37c1b54a0963bc14.tar.gz emacs-10fdc4c2483e5286345ce05c37c1b54a0963bc14.zip | |
[MAC_OSX] (fn_keycode_to_keycode_table): Add more entries
that ignores kEventKeyModifierFnMask.
(XTread_socket) [MAC_OSX]: Move code for ignoring
kEventKeyModifierFnMask for some keys ...
(mac_mapped_modifiers) [MAC_OSX]: ... to here. Add argument KEY_CODE.
All callers changed.
(mac_quit_char_key_p, XTread_socket): Get Emacs modifiers from
mapped modifiers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/macterm.c | 88 |
2 files changed, 56 insertions, 43 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 54678a2dccf..e3b083b0474 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2008-02-04 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * macterm.c [MAC_OSX] (fn_keycode_to_keycode_table): Add more entries | ||
| 4 | that ignores kEventKeyModifierFnMask. | ||
| 5 | (XTread_socket) [MAC_OSX]: Move code for ignoring | ||
| 6 | kEventKeyModifierFnMask for some keys ... | ||
| 7 | (mac_mapped_modifiers) [MAC_OSX]: ... to here. Add argument KEY_CODE. | ||
| 8 | All callers changed. | ||
| 9 | (mac_quit_char_key_p, XTread_socket): Get Emacs modifiers from | ||
| 10 | mapped modifiers. | ||
| 11 | |||
| 1 | 2008-02-01 Kenichi Handa <handa@ni.aist.go.jp> | 12 | 2008-02-01 Kenichi Handa <handa@ni.aist.go.jp> |
| 2 | 13 | ||
| 3 | * ccl.c (CCL_WRITE_CHAR): Fix overflow checking. | 14 | * ccl.c (CCL_WRITE_CHAR): Fix overflow checking. |
diff --git a/src/macterm.c b/src/macterm.c index b110f0372fc..93efc711250 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -9009,8 +9009,8 @@ static const unsigned char keycode_to_xkeysym_table[] = { | |||
| 9009 | /* Table for translating Mac keycode with the laptop `fn' key to that | 9009 | /* Table for translating Mac keycode with the laptop `fn' key to that |
| 9010 | without it. Destination symbols in comments are keys on US | 9010 | without it. Destination symbols in comments are keys on US |
| 9011 | keyboard, and they may not be the same on other types of keyboards. | 9011 | keyboard, and they may not be the same on other types of keyboards. |
| 9012 | If the destination is identical to the source (f1 ... f12), it | 9012 | If the destination is identical to the source, it doesn't map `fn' |
| 9013 | doesn't map `fn' key to a modifier. */ | 9013 | key to a modifier. */ |
| 9014 | static const unsigned char fn_keycode_to_keycode_table[] = { | 9014 | static const unsigned char fn_keycode_to_keycode_table[] = { |
| 9015 | /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 9015 | /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 9016 | /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 9016 | /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| @@ -9033,13 +9033,13 @@ static const unsigned char fn_keycode_to_keycode_table[] = { | |||
| 9033 | 9033 | ||
| 9034 | /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/, | 9034 | /*0x60*/ 0x60 /*f5 = f5*/, 0x61 /*f6 = f6*/, 0x62 /*f7 = f7*/, 0x63 /*f3 = f3*/, |
| 9035 | /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/, | 9035 | /*0x64*/ 0x64 /*f8 = f8*/, 0x65 /*f9 = f9*/, 0, 0x67 /*f11 = f11*/, |
| 9036 | /*0x68*/ 0, 0, 0, 0, | 9036 | /*0x68*/ 0, 0x69 /*f13 = f13*/, 0x6a /*f16 = f16*/, 0x6b /*f14 = f14*/, |
| 9037 | /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/, | 9037 | /*0x6C*/ 0, 0x6d /*f10 = f10*/, 0, 0x6f /*f12 = f12*/, |
| 9038 | 9038 | ||
| 9039 | /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/, | 9039 | /*0x70*/ 0, 0x71 /*f15 = f15*/, 0x72 /*help = help*/, 0x7b /*home -> left*/, |
| 9040 | /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/, | 9040 | /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0x76 /*f4 = f4*/, 0x7c /*end -> right*/, |
| 9041 | /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0, | 9041 | /*0x78*/ 0x78 /*f2 = f2*/, 0x7d /*pgdown -> down*/, 0x7a /*f1 = f1*/, 0x7b /*left = left*/, |
| 9042 | /*0x7C*/ 0, 0, 0, 0 | 9042 | /*0x7C*/ 0x7c /*right = right*/, 0x7d /*down = down*/, 0x7e /*up = up*/, 0 |
| 9043 | }; | 9043 | }; |
| 9044 | #endif /* MAC_OSX */ | 9044 | #endif /* MAC_OSX */ |
| 9045 | 9045 | ||
| @@ -9091,8 +9091,8 @@ mac_to_emacs_modifiers (EventModifiers mods) | |||
| 9091 | } | 9091 | } |
| 9092 | 9092 | ||
| 9093 | static UInt32 | 9093 | static UInt32 |
| 9094 | mac_mapped_modifiers (modifiers) | 9094 | mac_mapped_modifiers (modifiers, key_code) |
| 9095 | UInt32 modifiers; | 9095 | UInt32 modifiers, key_code; |
| 9096 | { | 9096 | { |
| 9097 | UInt32 mapped_modifiers_all = | 9097 | UInt32 mapped_modifiers_all = |
| 9098 | (NILP (Vmac_control_modifier) ? 0 : controlKey) | 9098 | (NILP (Vmac_control_modifier) ? 0 : controlKey) |
| @@ -9102,6 +9102,17 @@ mac_mapped_modifiers (modifiers) | |||
| 9102 | #ifdef MAC_OSX | 9102 | #ifdef MAC_OSX |
| 9103 | mapped_modifiers_all |= | 9103 | mapped_modifiers_all |= |
| 9104 | (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask); | 9104 | (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask); |
| 9105 | |||
| 9106 | /* The meaning of kEventKeyModifierFnMask has changed in Mac OS X | ||
| 9107 | 10.5, and it now behaves much like Cocoa's NSFunctionKeyMask. It | ||
| 9108 | no longer means laptop's `fn' key is down for the following keys: | ||
| 9109 | F1, F2, and so on, Help, Forward Delete, Home, End, Page Up, Page | ||
| 9110 | Down, the arrow keys, and Clear. We ignore the corresponding bit | ||
| 9111 | if that key can be entered without the `fn' key on laptops. */ | ||
| 9112 | if (modifiers & kEventKeyModifierFnMask | ||
| 9113 | && key_code <= 0x7f | ||
| 9114 | && fn_keycode_to_keycode_table[key_code] == key_code) | ||
| 9115 | modifiers &= ~kEventKeyModifierFnMask; | ||
| 9105 | #endif | 9116 | #endif |
| 9106 | 9117 | ||
| 9107 | return mapped_modifiers_all & modifiers; | 9118 | return mapped_modifiers_all & modifiers; |
| @@ -9130,18 +9141,19 @@ int | |||
| 9130 | mac_quit_char_key_p (modifiers, key_code) | 9141 | mac_quit_char_key_p (modifiers, key_code) |
| 9131 | UInt32 modifiers, key_code; | 9142 | UInt32 modifiers, key_code; |
| 9132 | { | 9143 | { |
| 9133 | UInt32 char_code; | 9144 | UInt32 char_code, mapped_modifiers; |
| 9134 | unsigned long some_state = 0; | 9145 | unsigned long some_state = 0; |
| 9135 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | 9146 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); |
| 9136 | int c, emacs_modifiers; | 9147 | int c, emacs_modifiers; |
| 9137 | 9148 | ||
| 9138 | /* Mask off modifier keys that are mapped to some Emacs modifiers. */ | 9149 | /* Mask off modifier keys that are mapped to some Emacs modifiers. */ |
| 9139 | key_code |= (modifiers & ~(mac_mapped_modifiers (modifiers))); | 9150 | mapped_modifiers = mac_mapped_modifiers (modifiers, key_code); |
| 9151 | key_code |= (modifiers & ~mapped_modifiers); | ||
| 9140 | char_code = KeyTranslate (kchr_ptr, key_code, &some_state); | 9152 | char_code = KeyTranslate (kchr_ptr, key_code, &some_state); |
| 9141 | if (char_code & ~0xff) | 9153 | if (char_code & ~0xff) |
| 9142 | return 0; | 9154 | return 0; |
| 9143 | 9155 | ||
| 9144 | emacs_modifiers = mac_to_emacs_modifiers (modifiers); | 9156 | emacs_modifiers = mac_to_emacs_modifiers (mapped_modifiers); |
| 9145 | if (emacs_modifiers & ctrl_modifier) | 9157 | if (emacs_modifiers & ctrl_modifier) |
| 9146 | c = make_ctrl_char (char_code); | 9158 | c = make_ctrl_char (char_code); |
| 9147 | 9159 | ||
| @@ -10203,7 +10215,7 @@ mac_handle_text_input_event (next_handler, event, data) | |||
| 10203 | case kEventTextInputUnicodeForKeyEvent: | 10215 | case kEventTextInputUnicodeForKeyEvent: |
| 10204 | { | 10216 | { |
| 10205 | EventRef kbd_event; | 10217 | EventRef kbd_event; |
| 10206 | UInt32 actual_size, modifiers; | 10218 | UInt32 actual_size, modifiers, key_code; |
| 10207 | 10219 | ||
| 10208 | err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent, | 10220 | err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent, |
| 10209 | typeEventRef, NULL, sizeof (EventRef), NULL, | 10221 | typeEventRef, NULL, sizeof (EventRef), NULL, |
| @@ -10212,7 +10224,11 @@ mac_handle_text_input_event (next_handler, event, data) | |||
| 10212 | err = GetEventParameter (kbd_event, kEventParamKeyModifiers, | 10224 | err = GetEventParameter (kbd_event, kEventParamKeyModifiers, |
| 10213 | typeUInt32, NULL, | 10225 | typeUInt32, NULL, |
| 10214 | sizeof (UInt32), NULL, &modifiers); | 10226 | sizeof (UInt32), NULL, &modifiers); |
| 10215 | if (err == noErr && mac_mapped_modifiers (modifiers)) | 10227 | if (err == noErr) |
| 10228 | err = GetEventParameter (kbd_event, kEventParamKeyCode, | ||
| 10229 | typeUInt32, NULL, sizeof (UInt32), | ||
| 10230 | NULL, &key_code); | ||
| 10231 | if (err == noErr && mac_mapped_modifiers (modifiers, key_code)) | ||
| 10216 | /* There're mapped modifier keys. Process it in | 10232 | /* There're mapped modifier keys. Process it in |
| 10217 | XTread_socket. */ | 10233 | XTread_socket. */ |
| 10218 | return eventNotHandledErr; | 10234 | return eventNotHandledErr; |
| @@ -10230,29 +10246,21 @@ mac_handle_text_input_event (next_handler, event, data) | |||
| 10230 | if (err == noErr && code < 0x80) | 10246 | if (err == noErr && code < 0x80) |
| 10231 | { | 10247 | { |
| 10232 | /* ASCII character. Process it in XTread_socket. */ | 10248 | /* ASCII character. Process it in XTread_socket. */ |
| 10233 | if (read_socket_inev && code >= 0x20 && code <= 0x7e) | 10249 | if (read_socket_inev && code >= 0x20 && code <= 0x7e |
| 10250 | && !(key_code <= 0x7f | ||
| 10251 | && keycode_to_xkeysym_table [key_code])) | ||
| 10234 | { | 10252 | { |
| 10235 | UInt32 key_code; | 10253 | struct frame *f = mac_focus_frame (&one_mac_display_info); |
| 10236 | 10254 | ||
| 10237 | err = GetEventParameter (kbd_event, kEventParamKeyCode, | 10255 | read_socket_inev->kind = ASCII_KEYSTROKE_EVENT; |
| 10238 | typeUInt32, NULL, sizeof (UInt32), | 10256 | read_socket_inev->code = code; |
| 10239 | NULL, &key_code); | 10257 | read_socket_inev->modifiers = |
| 10240 | if (!(err == noErr && key_code <= 0x7f | 10258 | mac_to_emacs_modifiers (modifiers); |
| 10241 | && keycode_to_xkeysym_table [key_code])) | 10259 | read_socket_inev->modifiers |= |
| 10242 | { | 10260 | (extra_keyboard_modifiers |
| 10243 | struct frame *f = | 10261 | & (meta_modifier | alt_modifier |
| 10244 | mac_focus_frame (&one_mac_display_info); | 10262 | | hyper_modifier | super_modifier)); |
| 10245 | 10263 | XSETFRAME (read_socket_inev->frame_or_window, f); | |
| 10246 | read_socket_inev->kind = ASCII_KEYSTROKE_EVENT; | ||
| 10247 | read_socket_inev->code = code; | ||
| 10248 | read_socket_inev->modifiers = | ||
| 10249 | mac_to_emacs_modifiers (modifiers); | ||
| 10250 | read_socket_inev->modifiers |= | ||
| 10251 | (extra_keyboard_modifiers | ||
| 10252 | & (meta_modifier | alt_modifier | ||
| 10253 | | hyper_modifier | super_modifier)); | ||
| 10254 | XSETFRAME (read_socket_inev->frame_or_window, f); | ||
| 10255 | } | ||
| 10256 | } | 10264 | } |
| 10257 | return eventNotHandledErr; | 10265 | return eventNotHandledErr; |
| 10258 | } | 10266 | } |
| @@ -11264,7 +11272,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 11264 | typeUInt32, NULL, | 11272 | typeUInt32, NULL, |
| 11265 | sizeof (UInt32), NULL, &modifiers); | 11273 | sizeof (UInt32), NULL, &modifiers); |
| 11266 | #endif | 11274 | #endif |
| 11267 | mapped_modifiers = mac_mapped_modifiers (modifiers); | 11275 | mapped_modifiers = mac_mapped_modifiers (modifiers, keycode); |
| 11268 | 11276 | ||
| 11269 | #if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM) | 11277 | #if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM) |
| 11270 | /* When using Carbon Events, we need to pass raw keyboard | 11278 | /* When using Carbon Events, we need to pass raw keyboard |
| @@ -11329,12 +11337,6 @@ XTread_socket (sd, expected, hold_quit) | |||
| 11329 | { | 11337 | { |
| 11330 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; | 11338 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; |
| 11331 | inev.code = 0xff00 | keycode_to_xkeysym_table [keycode]; | 11339 | inev.code = 0xff00 | keycode_to_xkeysym_table [keycode]; |
| 11332 | #ifdef MAC_OSX | ||
| 11333 | if (modifiers & kEventKeyModifierFnMask | ||
| 11334 | && keycode <= 0x7f | ||
| 11335 | && fn_keycode_to_keycode_table[keycode] == keycode) | ||
| 11336 | modifiers &= ~kEventKeyModifierFnMask; | ||
| 11337 | #endif | ||
| 11338 | } | 11340 | } |
| 11339 | else if (mapped_modifiers) | 11341 | else if (mapped_modifiers) |
| 11340 | { | 11342 | { |
| @@ -11428,7 +11430,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 11428 | inev.code = er.message & charCodeMask; | 11430 | inev.code = er.message & charCodeMask; |
| 11429 | } | 11431 | } |
| 11430 | 11432 | ||
| 11431 | inev.modifiers = mac_to_emacs_modifiers (modifiers); | 11433 | inev.modifiers = mac_to_emacs_modifiers (mapped_modifiers); |
| 11432 | inev.modifiers |= (extra_keyboard_modifiers | 11434 | inev.modifiers |= (extra_keyboard_modifiers |
| 11433 | & (meta_modifier | alt_modifier | 11435 | & (meta_modifier | alt_modifier |
| 11434 | | hyper_modifier | super_modifier)); | 11436 | | hyper_modifier | super_modifier)); |