diff options
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/macterm.c b/src/macterm.c index f62bbbc0d84..cdc1ccf41e3 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -228,6 +228,10 @@ extern int errno; | |||
| 228 | 228 | ||
| 229 | extern int extra_keyboard_modifiers; | 229 | extern int extra_keyboard_modifiers; |
| 230 | 230 | ||
| 231 | /* The keysyms to use for the various modifiers. */ | ||
| 232 | |||
| 233 | static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; | ||
| 234 | |||
| 231 | static Lisp_Object Qvendor_specific_keysyms; | 235 | static Lisp_Object Qvendor_specific_keysyms; |
| 232 | 236 | ||
| 233 | #if 0 | 237 | #if 0 |
| @@ -6988,6 +6992,9 @@ Lisp_Object Qreverse; | |||
| 6988 | /* True if using command key as meta key. */ | 6992 | /* True if using command key as meta key. */ |
| 6989 | Lisp_Object Vmac_command_key_is_meta; | 6993 | Lisp_Object Vmac_command_key_is_meta; |
| 6990 | 6994 | ||
| 6995 | /* Modifier associated with the option key, or nil for normal behavior. */ | ||
| 6996 | Lisp_Object Vmac_option_modifier; | ||
| 6997 | |||
| 6991 | /* True if the ctrl and meta keys should be reversed. */ | 6998 | /* True if the ctrl and meta keys should be reversed. */ |
| 6992 | Lisp_Object Vmac_reverse_ctrl_meta; | 6999 | Lisp_Object Vmac_reverse_ctrl_meta; |
| 6993 | 7000 | ||
| @@ -7069,6 +7076,12 @@ mac_to_emacs_modifiers (EventModifiers mods) | |||
| 7069 | result |= meta_modifier; | 7076 | result |= meta_modifier; |
| 7070 | if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) | 7077 | if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) |
| 7071 | result |= alt_modifier; | 7078 | result |= alt_modifier; |
| 7079 | if (!NILP (Vmac_option_modifier) && (mods & optionKey)) { | ||
| 7080 | Lisp_Object val = Fget(Vmac_option_modifier, Qmodifier_value); | ||
| 7081 | if (!NILP(val)) | ||
| 7082 | result |= XUINT(val); | ||
| 7083 | } | ||
| 7084 | |||
| 7072 | return result; | 7085 | return result; |
| 7073 | } | 7086 | } |
| 7074 | 7087 | ||
| @@ -8549,7 +8562,18 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8549 | unsigned long some_state = 0; | 8562 | unsigned long some_state = 0; |
| 8550 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | 8563 | inev.code = KeyTranslate (kchr_ptr, new_keycode, |
| 8551 | &some_state) & 0xff; | 8564 | &some_state) & 0xff; |
| 8552 | } | 8565 | } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) |
| 8566 | { | ||
| 8567 | /* When using the option key as an emacs modifier, convert | ||
| 8568 | the pressed key code back to one without the Mac option | ||
| 8569 | modifier applied. */ | ||
| 8570 | int new_modifiers = er.modifiers & ~optionKey; | ||
| 8571 | int new_keycode = keycode | new_modifiers; | ||
| 8572 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | ||
| 8573 | unsigned long some_state = 0; | ||
| 8574 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | ||
| 8575 | &some_state) & 0xff; | ||
| 8576 | } | ||
| 8553 | else | 8577 | else |
| 8554 | inev.code = er.message & charCodeMask; | 8578 | inev.code = er.message & charCodeMask; |
| 8555 | inev.kind = ASCII_KEYSTROKE_EVENT; | 8579 | inev.kind = ASCII_KEYSTROKE_EVENT; |
| @@ -9249,6 +9273,14 @@ syms_of_macterm () | |||
| 9249 | x_error_message_string = Qnil; | 9273 | x_error_message_string = Qnil; |
| 9250 | #endif | 9274 | #endif |
| 9251 | 9275 | ||
| 9276 | Qmodifier_value = intern ("modifier-value"); | ||
| 9277 | Qalt = intern ("alt"); | ||
| 9278 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); | ||
| 9279 | Qhyper = intern ("hyper"); | ||
| 9280 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); | ||
| 9281 | Qsuper = intern ("super"); | ||
| 9282 | Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); | ||
| 9283 | |||
| 9252 | Fprovide (intern ("mac-carbon"), Qnil); | 9284 | Fprovide (intern ("mac-carbon"), Qnil); |
| 9253 | 9285 | ||
| 9254 | staticpro (&Qreverse); | 9286 | staticpro (&Qreverse); |
| @@ -9305,6 +9337,12 @@ to 4.1, set this to nil. */); | |||
| 9305 | Otherwise the option key is used. */); | 9337 | Otherwise the option key is used. */); |
| 9306 | Vmac_command_key_is_meta = Qt; | 9338 | Vmac_command_key_is_meta = Qt; |
| 9307 | 9339 | ||
| 9340 | DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, | ||
| 9341 | doc: /* Modifier to use for the Mac alt/option key. The value can | ||
| 9342 | be alt, hyper, or super for the respective modifier. If the value is | ||
| 9343 | nil then the key will act as the normal Mac option modifier. */); | ||
| 9344 | Vmac_option_modifier = Qnil; | ||
| 9345 | |||
| 9308 | DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, | 9346 | DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, |
| 9309 | doc: /* Non-nil means that the control and meta keys are reversed. This is | 9347 | doc: /* Non-nil means that the control and meta keys are reversed. This is |
| 9310 | useful for non-standard keyboard layouts. */); | 9348 | useful for non-standard keyboard layouts. */); |