aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-12-26 03:16:59 +0000
committerKaroly Lorentey2005-12-26 03:16:59 +0000
commitfeba0cd6405ebb80af743e2f978442d9c837bcd2 (patch)
tree1cb964aa641bee514d9cda2eafe27a0a97e65ad1 /src/macterm.c
parent30663b475e57197c9896a252e1d4ca31c579fa2b (diff)
parent7a32e81fb608282314e27db21a00138aaa91f29a (diff)
downloademacs-feba0cd6405ebb80af743e2f978442d9c837bcd2.tar.gz
emacs-feba0cd6405ebb80af743e2f978442d9c837bcd2.zip
Merged from miles@gnu.org--gnu-2005 (patch 677)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-677 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-463
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c131
1 files changed, 71 insertions, 60 deletions
diff --git a/src/macterm.c b/src/macterm.c
index ba39450b4b4..cbf7078cb25 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -93,8 +93,9 @@ Boston, MA 02110-1301, USA. */
93 93
94Lisp_Object Vx_toolkit_scroll_bars; 94Lisp_Object Vx_toolkit_scroll_bars;
95 95
96/* If Non-nil, the text will be rendered using Core Graphics text rendering which may anti-alias the text. */ 96/* If non-zero, the text will be rendered using Core Graphics text
97Lisp_Object Vmac_use_core_graphics; 97 rendering which may anti-alias the text. */
98int mac_use_core_graphics;
98 99
99 100
100/* Non-zero means that a HELP_EVENT has been generated since Emacs 101/* Non-zero means that a HELP_EVENT has been generated since Emacs
@@ -105,6 +106,10 @@ static int any_help_event_p;
105/* Last window where we saw the mouse. Used by mouse-autoselect-window. */ 106/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
106static Lisp_Object last_window; 107static Lisp_Object last_window;
107 108
109/* Non-zero means make use of UNDERLINE_POSITION font properties.
110 (Not yet supported.) */
111int x_use_underline_position_properties;
112
108/* This is a chain of structures for all the X displays currently in 113/* This is a chain of structures for all the X displays currently in
109 use. */ 114 use. */
110 115
@@ -199,8 +204,7 @@ extern EMACS_INT extra_keyboard_modifiers;
199 204
200/* The keysyms to use for the various modifiers. */ 205/* The keysyms to use for the various modifiers. */
201 206
202static Lisp_Object Qalt, Qhyper, Qsuper, Qcontrol, 207static Lisp_Object Qalt, Qhyper, Qsuper, Qcontrol, Qmeta, Qmodifier_value;
203 Qmeta, Qmodifier_value;
204 208
205extern int inhibit_window_system; 209extern int inhibit_window_system;
206 210
@@ -687,7 +691,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
687{ 691{
688#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 692#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
689 UInt32 textFlags, savedFlags; 693 UInt32 textFlags, savedFlags;
690 if (!NILP(Vmac_use_core_graphics)) { 694 if (mac_use_core_graphics) {
691 textFlags = kQDUseCGTextRendering; 695 textFlags = kQDUseCGTextRendering;
692 savedFlags = SwapQDTextFlags(textFlags); 696 savedFlags = SwapQDTextFlags(textFlags);
693 } 697 }
@@ -723,7 +727,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
723 if (err == noErr) 727 if (err == noErr)
724 { 728 {
725#ifdef MAC_OSX 729#ifdef MAC_OSX
726 if (NILP (Vmac_use_core_graphics)) 730 if (!mac_use_core_graphics)
727 { 731 {
728#endif 732#endif
729 mac_begin_clip (GC_CLIP_REGION (gc)); 733 mac_begin_clip (GC_CLIP_REGION (gc));
@@ -802,7 +806,7 @@ mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
802 if (mode != srcOr) 806 if (mode != srcOr)
803 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f))); 807 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
804#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 808#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
805 if (!NILP(Vmac_use_core_graphics)) 809 if (mac_use_core_graphics)
806 SwapQDTextFlags(savedFlags); 810 SwapQDTextFlags(savedFlags);
807#endif 811#endif
808} 812}
@@ -895,7 +899,7 @@ mac_draw_string_cg (f, gc, x, y, buf, nchars)
895 CGGlyph *glyphs; 899 CGGlyph *glyphs;
896 CGSize *advances; 900 CGSize *advances;
897 901
898 if (NILP (Vmac_use_core_graphics) || GC_FONT (gc)->cg_font == NULL) 902 if (!mac_use_core_graphics || GC_FONT (gc)->cg_font == NULL)
899 return 0; 903 return 0;
900 904
901 port = GetWindowPort (FRAME_MAC_WINDOW (f)); 905 port = GetWindowPort (FRAME_MAC_WINDOW (f));
@@ -8109,17 +8113,17 @@ Lisp_Object Vmac_function_modifier;
8109Lisp_Object Vmac_emulate_three_button_mouse; 8113Lisp_Object Vmac_emulate_three_button_mouse;
8110 8114
8111#if USE_CARBON_EVENTS 8115#if USE_CARBON_EVENTS
8112/* True if the mouse wheel button (i.e. button 4) should map to 8116/* Non-zero if the mouse wheel button (i.e. button 4) should map to
8113 mouse-2, instead of mouse-3. */ 8117 mouse-2, instead of mouse-3. */
8114Lisp_Object Vmac_wheel_button_is_mouse_2; 8118int mac_wheel_button_is_mouse_2;
8115 8119
8116/* If Non-nil, the Mac "Command" key is passed on to the Mac Toolbox 8120/* If non-zero, the Mac "Command" key is passed on to the Mac Toolbox
8117 for processing before Emacs sees it. */ 8121 for processing before Emacs sees it. */
8118Lisp_Object Vmac_pass_command_to_system; 8122int mac_pass_command_to_system;
8119 8123
8120/* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox 8124/* If non-zero, the Mac "Control" key is passed on to the Mac Toolbox
8121 for processing before Emacs sees it. */ 8125 for processing before Emacs sees it. */
8122Lisp_Object Vmac_pass_control_to_system; 8126int mac_pass_control_to_system;
8123#endif 8127#endif
8124 8128
8125/* Points to the variable `inev' in the function XTread_socket. It is 8129/* Points to the variable `inev' in the function XTread_socket. It is
@@ -8176,8 +8180,6 @@ mac_to_emacs_modifiers (EventModifiers mods)
8176 if (mods & shiftKey) 8180 if (mods & shiftKey)
8177 result |= shift_modifier; 8181 result |= shift_modifier;
8178 8182
8179
8180
8181 /* Deactivated to simplify configuration: 8183 /* Deactivated to simplify configuration:
8182 if Vmac_option_modifier is non-NIL, we fully process the Option 8184 if Vmac_option_modifier is non-NIL, we fully process the Option
8183 key. Otherwise, we only process it if an additional Ctrl or Command 8185 key. Otherwise, we only process it if an additional Ctrl or Command
@@ -8265,10 +8267,10 @@ mac_get_mouse_btn (EventRef ref)
8265 return mac_get_emulated_btn(mods); 8267 return mac_get_emulated_btn(mods);
8266 } 8268 }
8267 case kEventMouseButtonSecondary: 8269 case kEventMouseButtonSecondary:
8268 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2; 8270 return mac_wheel_button_is_mouse_2 ? 2 : 1;
8269 case kEventMouseButtonTertiary: 8271 case kEventMouseButtonTertiary:
8270 case 4: /* 4 is the number for the mouse wheel button */ 8272 case 4: /* 4 is the number for the mouse wheel button */
8271 return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1; 8273 return mac_wheel_button_is_mouse_2 ? 1 : 2;
8272 default: 8274 default:
8273 return 0; 8275 return 0;
8274 } 8276 }
@@ -8779,10 +8781,8 @@ mac_handle_command_event (next_handler, event, data)
8779 kEventParamKeyModifiers}; 8781 kEventParamKeyModifiers};
8780 static EventParamType types[] = {typeHICommand, 8782 static EventParamType types[] = {typeHICommand,
8781 typeUInt32}; 8783 typeUInt32};
8782 static UInt32 sizes[] = {sizeof (HICommand),
8783 sizeof (UInt32)};
8784 err = create_apple_event_from_event_ref (event, 2, names, types, 8784 err = create_apple_event_from_event_ref (event, 2, names, types,
8785 sizes, &apple_event); 8785 &apple_event);
8786 if (err == noErr) 8786 if (err == noErr)
8787 { 8787 {
8788 err = mac_store_apple_event (class_key, id_key, &apple_event); 8788 err = mac_store_apple_event (class_key, id_key, &apple_event);
@@ -8966,8 +8966,8 @@ mac_store_services_event (event)
8966 { 8966 {
8967 case kEventServicePaste: 8967 case kEventServicePaste:
8968 id_key = Qpaste; 8968 id_key = Qpaste;
8969 err = create_apple_event_from_event_ref (event, 0, NULL, 8969 err = create_apple_event_from_event_ref (event, 0, NULL, NULL,
8970 NULL, NULL, &apple_event); 8970 &apple_event);
8971 break; 8971 break;
8972 8972
8973 case kEventServicePerform: 8973 case kEventServicePerform:
@@ -8976,12 +8976,10 @@ mac_store_services_event (event)
8976 kEventParamServiceUserData}; 8976 kEventParamServiceUserData};
8977 static EventParamType types[] = {typeCFStringRef, 8977 static EventParamType types[] = {typeCFStringRef,
8978 typeCFStringRef}; 8978 typeCFStringRef};
8979 static UInt32 sizes[] = {sizeof (CFStringRef),
8980 sizeof (CFStringRef)};
8981 8979
8982 id_key = Qperform; 8980 id_key = Qperform;
8983 err = create_apple_event_from_event_ref (event, 2, names, types, 8981 err = create_apple_event_from_event_ref (event, 2, names, types,
8984 sizes, &apple_event); 8982 &apple_event);
8985 } 8983 }
8986 break; 8984 break;
8987 8985
@@ -9191,8 +9189,8 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
9191 XSETINT (event.x, mouse.h); 9189 XSETINT (event.x, mouse.h);
9192 XSETINT (event.y, mouse.v); 9190 XSETINT (event.y, mouse.v);
9193 XSETFRAME (frame, f); 9191 XSETFRAME (frame, f);
9194 event.frame_or_window = Fcons (frame, file_list); 9192 event.frame_or_window = frame;
9195 event.arg = Qnil; 9193 event.arg = file_list;
9196 /* Post to the interrupt queue */ 9194 /* Post to the interrupt queue */
9197 kbd_buffer_store_event (&event); 9195 kbd_buffer_store_event (&event);
9198 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */ 9196 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */
@@ -9411,10 +9409,12 @@ convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9411static int 9409static int
9412backtranslate_modified_keycode(int mods, int keycode, int def) 9410backtranslate_modified_keycode(int mods, int keycode, int def)
9413{ 9411{
9414 if (mods & 9412 EventModifiers mapped_modifiers =
9415 (controlKey | 9413 (NILP (Vmac_control_modifier) ? 0 : controlKey)
9416 (NILP (Vmac_option_modifier) ? 0 : optionKey) | 9414 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
9417 cmdKey)) 9415 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
9416
9417 if (mods & mapped_modifiers)
9418 { 9418 {
9419 /* This code comes from Keyboard Resource, 9419 /* This code comes from Keyboard Resource,
9420 Appendix C of IM - Text. This is necessary 9420 Appendix C of IM - Text. This is necessary
@@ -9429,14 +9429,15 @@ backtranslate_modified_keycode(int mods, int keycode, int def)
9429 to preserve key combinations translated by the OS 9429 to preserve key combinations translated by the OS
9430 such as Alt-3. 9430 such as Alt-3.
9431 */ 9431 */
9432 /* mask off option and command */ 9432 /* Mask off modifier keys that are mapped to some Emacs
9433 int new_modifiers = mods & 0xe600; 9433 modifiers. */
9434 int new_modifiers = mods & ~mapped_modifiers;
9434 /* set high byte of keycode to modifier high byte*/ 9435 /* set high byte of keycode to modifier high byte*/
9435 int new_keycode = keycode | new_modifiers; 9436 int new_keycode = keycode | new_modifiers;
9436 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); 9437 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9437 unsigned long some_state = 0; 9438 unsigned long some_state = 0;
9438 return (int) KeyTranslate (kchr_ptr, new_keycode, 9439 return (int) KeyTranslate (kchr_ptr, new_keycode,
9439 &some_state) & 0xff; 9440 &some_state) & 0xff;
9440 /* TO DO: Recognize two separate resulting characters, "for 9441 /* TO DO: Recognize two separate resulting characters, "for
9441 example, when the user presses Option-E followed by N, you 9442 example, when the user presses Option-E followed by N, you
9442 can map this through the KeyTranslate function using the 9443 can map this through the KeyTranslate function using the
@@ -9990,9 +9991,9 @@ XTread_socket (sd, expected, hold_quit)
9990 will pass back noErr, otherwise it will pass back 9991 will pass back noErr, otherwise it will pass back
9991 "eventNotHandledErr" and we can process it 9992 "eventNotHandledErr" and we can process it
9992 normally. */ 9993 normally. */
9993 if ((!NILP (Vmac_pass_command_to_system) 9994 if ((mac_pass_command_to_system
9994 || !(er.modifiers & cmdKey)) 9995 || !(er.modifiers & cmdKey))
9995 && (!NILP (Vmac_pass_control_to_system) 9996 && (mac_pass_control_to_system
9996 || !(er.modifiers & controlKey)) 9997 || !(er.modifiers & controlKey))
9997 && (NILP (Vmac_option_modifier) 9998 && (NILP (Vmac_option_modifier)
9998 || !(er.modifiers & optionKey))) 9999 || !(er.modifiers & optionKey)))
@@ -10061,12 +10062,10 @@ XTread_socket (sd, expected, hold_quit)
10061 } 10062 }
10062 else 10063 else
10063 { 10064 {
10064
10065 inev.code = 10065 inev.code =
10066 backtranslate_modified_keycode(er.modifiers, keycode, 10066 backtranslate_modified_keycode(er.modifiers, keycode,
10067 er.message & charCodeMask); 10067 er.message & charCodeMask);
10068 inev.kind = ASCII_KEYSTROKE_EVENT; 10068 inev.kind = ASCII_KEYSTROKE_EVENT;
10069
10070 } 10069 }
10071 } 10070 }
10072 10071
@@ -10711,6 +10710,18 @@ syms_of_macterm ()
10711 atsu_font_id_hash = Qnil; 10710 atsu_font_id_hash = Qnil;
10712#endif 10711#endif
10713 10712
10713 /* We don't yet support this, but defining this here avoids whining
10714 from cus-start.el and other places, like "M-x set-variable". */
10715 DEFVAR_BOOL ("x-use-underline-position-properties",
10716 &x_use_underline_position_properties,
10717 doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
10718nil means ignore them. If you encounter fonts with bogus
10719UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10720to 4.1, set this to nil.
10721
10722NOTE: Not supported on Mac yet. */);
10723 x_use_underline_position_properties = 0;
10724
10714 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 10725 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
10715 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 10726 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
10716#ifdef USE_TOOLKIT_SCROLL_BARS 10727#ifdef USE_TOOLKIT_SCROLL_BARS
@@ -10725,35 +10736,35 @@ syms_of_macterm ()
10725/* Variables to configure modifier key assignment. */ 10736/* Variables to configure modifier key assignment. */
10726 10737
10727 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier, 10738 DEFVAR_LISP ("mac-control-modifier", &Vmac_control_modifier,
10728 doc: /* Modifier key assumed when the Mac control key is pressed. 10739 doc: /* *Modifier key assumed when the Mac control key is pressed.
10729The value can be `alt', `control', `hyper', or `super' for the 10740The value can be `control', `meta', `alt', `hyper', or `super' for the
10730respective modifier. The default is `control'. */); 10741respective modifier. The default is `control'. */);
10731 Vmac_control_modifier = Qcontrol; 10742 Vmac_control_modifier = Qcontrol;
10732 10743
10733 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier, 10744 DEFVAR_LISP ("mac-option-modifier", &Vmac_option_modifier,
10734 doc: /* Modifier key assumed when the Mac alt/option key is pressed. 10745 doc: /* *Modifier key assumed when the Mac alt/option key is pressed.
10735The value can be `alt', `control', `hyper', or `super' for the 10746The value can be `control', `meta', `alt', `hyper', or `super' for the
10736respective modifier. If the value is nil then the key will act as the 10747respective modifier. If the value is nil then the key will act as the
10737normal Mac control modifier, and the option key can be used to compose 10748normal Mac control modifier, and the option key can be used to compose
10738characters depending on the chosen Mac keyboard setting. */); 10749characters depending on the chosen Mac keyboard setting. */);
10739 Vmac_option_modifier = Qnil; 10750 Vmac_option_modifier = Qnil;
10740 10751
10741 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier, 10752 DEFVAR_LISP ("mac-command-modifier", &Vmac_command_modifier,
10742 doc: /* Modifier key assumed when the Mac command key is pressed. 10753 doc: /* *Modifier key assumed when the Mac command key is pressed.
10743The value can be `alt', `control', `hyper', or `super' for the 10754The value can be `control', `meta', `alt', `hyper', or `super' for the
10744respective modifier. The default is `meta'. */); 10755respective modifier. The default is `meta'. */);
10745 Vmac_command_modifier = Qmeta; 10756 Vmac_command_modifier = Qmeta;
10746 10757
10747 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier, 10758 DEFVAR_LISP ("mac-function-modifier", &Vmac_function_modifier,
10748 doc: /* Modifier key assumed when the Mac function key is pressed. 10759 doc: /* *Modifier key assumed when the Mac function key is pressed.
10749The value can be `alt', `control', `hyper', or `super' for the 10760The value can be `control', `meta', `alt', `hyper', or `super' for the
10750respective modifier. Note that remapping the function key may lead to 10761respective modifier. Note that remapping the function key may lead to
10751unexpected results for some keys on non-US/GB keyboards. */); 10762unexpected results for some keys on non-US/GB keyboards. */);
10752 Vmac_function_modifier = Qnil; 10763 Vmac_function_modifier = Qnil;
10753 10764
10754 DEFVAR_LISP ("mac-emulate-three-button-mouse", 10765 DEFVAR_LISP ("mac-emulate-three-button-mouse",
10755 &Vmac_emulate_three_button_mouse, 10766 &Vmac_emulate_three_button_mouse,
10756 doc: /* Specify a way of three button mouse emulation. 10767 doc: /* *Specify a way of three button mouse emulation.
10757The value can be nil, t, or the symbol `reverse'. 10768The value can be nil, t, or the symbol `reverse'.
10758nil means that no emulation should be done and the modifiers should be 10769nil means that no emulation should be done and the modifiers should be
10759placed on the mouse-1 event. 10770placed on the mouse-1 event.
@@ -10765,27 +10776,27 @@ mouse-3 and the command-key will register for mouse-2. */);
10765 Vmac_emulate_three_button_mouse = Qnil; 10776 Vmac_emulate_three_button_mouse = Qnil;
10766 10777
10767#if USE_CARBON_EVENTS 10778#if USE_CARBON_EVENTS
10768 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, 10779 DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2,
10769 doc: /* Non-nil if the wheel button is mouse-2 and the right click mouse-3. 10780 doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3.
10770Otherwise, the right click will be treated as mouse-2 and the wheel 10781Otherwise, the right click will be treated as mouse-2 and the wheel
10771button will be mouse-3. */); 10782button will be mouse-3. */);
10772 Vmac_wheel_button_is_mouse_2 = Qt; 10783 mac_wheel_button_is_mouse_2 = 1;
10773 10784
10774 DEFVAR_LISP ("mac-pass-command-to-system", &Vmac_pass_command_to_system, 10785 DEFVAR_BOOL ("mac-pass-command-to-system", &mac_pass_command_to_system,
10775 doc: /* Non-nil if command key presses are passed on to the Mac Toolbox. */); 10786 doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */);
10776 Vmac_pass_command_to_system = Qt; 10787 mac_pass_command_to_system = 1;
10777 10788
10778 DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system, 10789 DEFVAR_BOOL ("mac-pass-control-to-system", &mac_pass_control_to_system,
10779 doc: /* Non-nil if control key presses are passed on to the Mac Toolbox. */); 10790 doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */);
10780 Vmac_pass_control_to_system = Qt; 10791 mac_pass_control_to_system = 1;
10781 10792
10782#endif 10793#endif
10783 10794
10784 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics, 10795 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics,
10785 doc: /* If non-nil, allow anti-aliasing. 10796 doc: /* *If non-nil, allow anti-aliasing.
10786The text will be rendered using Core Graphics text rendering which 10797The text will be rendered using Core Graphics text rendering which
10787may anti-alias the text. */); 10798may anti-alias the text. */);
10788 Vmac_use_core_graphics = Qnil; 10799 mac_use_core_graphics = 0;
10789 10800
10790 /* Register an entry for `mac-roman' so that it can be used when 10801 /* Register an entry for `mac-roman' so that it can be used when
10791 creating the terminal frame on Mac OS 9 before loading 10802 creating the terminal frame on Mac OS 9 before loading