aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-05-24 09:13:31 +0000
committerKaroly Lorentey2006-05-24 09:13:31 +0000
commit40a1b46245c1a8786324f5a06d6cb8d4bd9d5b74 (patch)
treef45020695e190f511f4faf4dd3ed144059f298c0 /src
parentdbe9f5ba9648890dc34f4836a49fde766b21ce74 (diff)
parent4ea5193b9cc5c577127ca6c89ecfaad819398d3b (diff)
downloademacs-40a1b46245c1a8786324f5a06d6cb8d4bd9d5b74.tar.gz
emacs-40a1b46245c1a8786324f5a06d6cb8d4bd9d5b74.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-289 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-290 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-291 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-292 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-293 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-567
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog46
-rw-r--r--src/buffer.c8
-rw-r--r--src/coding.h5
-rw-r--r--src/intervals.c4
-rw-r--r--src/macterm.c384
-rw-r--r--src/w32.c38
-rw-r--r--src/xfaces.c40
-rw-r--r--src/xterm.c12
-rw-r--r--src/xterm.h10
9 files changed, 321 insertions, 226 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5acc6313bbb..c2fdb389729 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,40 @@
12006-05-23 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macterm.c (fn_keycode_to_xkeysym_table, convert_fn_keycode): Remove.
4 (fn_keycode_to_keycode_table) [MAC_OSX]: New variable.
5 (mac_set_unicode_keystroke_event) [TARGET_API_MAC_CARBON]: New function.
6 (XTread_socket) [TARGET_API_MAC_CARBON]: Use it.
7 (XTread_socket) [MAC_OSX]: Try 'uchr' Unicode keyboard-layout
8 resource to backtranslate key with modifiers.
9 (XTread_socket): Don't set read_socket_inev around AEProcessAppleEvent.
10
112006-05-23 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
12
13 * xterm.c: Remove declarations already in xterm.h
14
15 * xterm.h: Add extern declarations for x_clear_errors,
16 x_fully_uncatch_errors, x_catching_errors and
17 x_alloc_lighter_color_for_widget. Remove duplicated declarations.
18
192006-05-21 Richard Stallman <rms@gnu.org>
20
21 * buffer.c (syms_of_buffer, Fmake_overlay): Doc fixes.
22
232006-05-20 Kim F. Storm <storm@cua.dk>
24
25 * xfaces.c (best_matching_font): Fix crash in 2006-05-17 change.
26
272006-05-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
28
29 * macterm.c (convert_fn_keycode): Fix last change.
30
312006-05-19 Eli Zaretskii <eliz@gnu.org>
32
33 * w32.c (init_environment): Perform the processing of environment
34 variables on a copy of default variables and their values, not on
35 the original. Simplify code that calls ExpandEnvironmentStrings
36 and make buf1[] and buf2[] more visible for easier debugging.
37
12006-05-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 382006-05-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 39
3 * frame.c (x_set_border_width): Remove #ifndef MAC_OS. 40 * frame.c (x_set_border_width): Remove #ifndef MAC_OS.
@@ -49,6 +86,13 @@
49 * xdisp.c (display_tool_bar_line): Don't adjust tool-bar height by more than 86 * xdisp.c (display_tool_bar_line): Don't adjust tool-bar height by more than
50 height of one frame default line. 87 height of one frame default line.
51 88
892006-05-17 Richard Stallman <rms@gnu.org>
90
91 * xfaces.c (better_font_p): Any font beats no font.
92 (best_matching_font): Simplify based on above change.
93
94 * buffer.c (Fprevious_overlay_change, Fnext_overlay_change): Doc fixes.
95
522006-05-16 Kim F. Storm <storm@cua.dk> 962006-05-16 Kim F. Storm <storm@cua.dk>
53 97
54 * xterm.c (handle_one_xevent): Check that f is not NULL before 98 * xterm.c (handle_one_xevent): Check that f is not NULL before
@@ -113,7 +157,7 @@
113 [MAC_OS] (gif_load): Emulate Graphic Control Extension block. 157 [MAC_OS] (gif_load): Emulate Graphic Control Extension block.
114 158
115 * macfns.c (x_to_mac_color): Fix shift amount change. 159 * macfns.c (x_to_mac_color): Fix shift amount change.
116 [USE_MAC_FONT_PANEL] (mac_set_font): Use x_get_focus_frame. 160 (mac_set_font) [USE_MAC_FONT_PANEL]: Use x_get_focus_frame.
117 [USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): Doc fix. 161 [USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): Doc fix.
118 162
119 * macselect.c (Vmac_service_selection) [MAC_OSX]: Rename from 163 * macselect.c (Vmac_service_selection) [MAC_OSX]: Rename from
diff --git a/src/buffer.c b/src/buffer.c
index 6317c14d393..3dff44a6b86 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3584,10 +3584,10 @@ If omitted, BUFFER defaults to the current buffer.
3584BEG and END may be integers or markers. 3584BEG and END may be integers or markers.
3585The fourth arg FRONT-ADVANCE, if non-nil, makes the marker 3585The fourth arg FRONT-ADVANCE, if non-nil, makes the marker
3586for the front of the overlay advance when text is inserted there 3586for the front of the overlay advance when text is inserted there
3587(which means the text *is not* included in the overlay). 3587\(which means the text *is not* included in the overlay).
3588The fifth arg REAR-ADVANCE, if non-nil, makes the marker 3588The fifth arg REAR-ADVANCE, if non-nil, makes the marker
3589for the rear of the overlay advance when text is inserted there 3589for the rear of the overlay advance when text is inserted there
3590(which means the text *is* included in the overlay). */) 3590\(which means the text *is* included in the overlay). */)
3591 (beg, end, buffer, front_advance, rear_advance) 3591 (beg, end, buffer, front_advance, rear_advance)
3592 Lisp_Object beg, end, buffer; 3592 Lisp_Object beg, end, buffer;
3593 Lisp_Object front_advance, rear_advance; 3593 Lisp_Object front_advance, rear_advance;
@@ -5769,7 +5769,7 @@ the actual bitmap shown in the left or right fringe for the logical
5769indicator. LEFT and RIGHT are the bitmaps shown in the left and/or 5769indicator. LEFT and RIGHT are the bitmaps shown in the left and/or
5770right fringe for the specific indicator. The LEFT1 or RIGHT1 bitmaps 5770right fringe for the specific indicator. The LEFT1 or RIGHT1 bitmaps
5771are used only for the `bottom' and `one-line' indicators when the last 5771are used only for the `bottom' and `one-line' indicators when the last
5772(only) line in has no final newline. BITMAPS may also be a single 5772\(only) line in has no final newline. BITMAPS may also be a single
5773symbol which is used in both left and right fringes. */); 5773symbol which is used in both left and right fringes. */);
5774 5774
5775 DEFVAR_PER_BUFFER ("fringe-cursor-alist", 5775 DEFVAR_PER_BUFFER ("fringe-cursor-alist",
@@ -6016,7 +6016,7 @@ this variable has no effect; the cursor appears as a hollow box. */);
6016 doc: /* Additional space to put between lines when displaying a buffer. 6016 doc: /* Additional space to put between lines when displaying a buffer.
6017The space is measured in pixels, and put below lines on window systems. 6017The space is measured in pixels, and put below lines on window systems.
6018If value is a floating point number, it specifies the spacing relative 6018If value is a floating point number, it specifies the spacing relative
6019to the default frame line height. */); 6019to the default frame line height. nil means add no extra space. */);
6020 6020
6021 DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows", 6021 DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
6022 &current_buffer->cursor_in_non_selected_windows, Qnil, 6022 &current_buffer->cursor_in_non_selected_windows, Qnil,
diff --git a/src/coding.h b/src/coding.h
index be68753acb2..81dcb7f08ad 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -462,7 +462,10 @@ struct coding_system
462 || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK) 462 || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK)
463 463
464/* Return 1 if the coding system CODING requires code conversion on 464/* Return 1 if the coding system CODING requires code conversion on
465 encoding. */ 465 encoding.
466 The non-multibyte part of the condition is to support encoding of
467 unibyte strings/buffers generated by string-as-unibyte or
468 (set-buffer-multibyte nil) from multibyte strings/buffers. */
466#define CODING_REQUIRE_ENCODING(coding) \ 469#define CODING_REQUIRE_ENCODING(coding) \
467 ((coding)->src_multibyte \ 470 ((coding)->src_multibyte \
468 || (coding)->common_flags & CODING_REQUIRE_ENCODING_MASK) 471 || (coding)->common_flags & CODING_REQUIRE_ENCODING_MASK)
diff --git a/src/intervals.c b/src/intervals.c
index e69ff701387..20c4c191a93 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -2016,6 +2016,10 @@ set_point_both (buffer, charpos, bytepos)
2016 register INTERVAL to, from, toprev, fromprev; 2016 register INTERVAL to, from, toprev, fromprev;
2017 int buffer_point; 2017 int buffer_point;
2018 int old_position = BUF_PT (buffer); 2018 int old_position = BUF_PT (buffer);
2019 /* This ensures that we move forward past intangible text when the
2020 initial position is the same as the destination, in the rare
2021 instances where this is important, e.g. in line-move-finish
2022 (simple.el). */
2019 int backwards = (charpos < old_position ? 1 : 0); 2023 int backwards = (charpos < old_position ? 1 : 0);
2020 int have_overlays; 2024 int have_overlays;
2021 int original_position; 2025 int original_position;
diff --git a/src/macterm.c b/src/macterm.c
index 68959758e98..e793e5d04f0 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -9629,7 +9629,12 @@ keycode_to_xkeysym (int keyCode, int *xKeySym)
9629 return *xKeySym != 0; 9629 return *xKeySym != 0;
9630} 9630}
9631 9631
9632static unsigned char fn_keycode_to_xkeysym_table[] = { 9632#ifdef MAC_OSX
9633/* Table for translating Mac keycode with the laptop `fn' key to that
9634 without it. Destination symbols in comments are keys on US
9635 keyboard, and they may not be the same on other types of
9636 keyboards. */
9637static unsigned char fn_keycode_to_keycode_table[] = {
9633 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9638 /*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9634 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9639 /*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9635 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9640 /*0x20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -9639,113 +9644,27 @@ static unsigned char fn_keycode_to_xkeysym_table[] = {
9639 /*0x38*/ 0, 0, 0, 0, 9644 /*0x38*/ 0, 0, 0, 0,
9640 /*0x3C*/ 0, 0, 0, 0, 9645 /*0x3C*/ 0, 0, 0, 0,
9641 9646
9642 /*0x40*/ 0, 0x2e /*kp-. = .*/, 0, 0x50 /*kp-* = 'p'*/, 9647 /*0x40*/ 0, 0x2f /*kp-. -> '.'*/, 0, 0x23 /*kp-* -> 'p'*/,
9643 /*0x44*/ 0, '/' /*kp-+*/, 0, 0, 9648 /*0x44*/ 0, 0x2c /*kp-+ -> '/'*/, 0, 0x16 /*clear -> '6'*/,
9644 /*0x48*/ 0, 0, 0, 0x30 /*kp-/ = '0'*/, 9649 /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
9645 /*0x4C*/ 0, 0, 0x3b /*kp-- = ';'*/, 0, 9650 /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-- -> ';'*/, 0,
9646 9651
9647 /*0x50*/ 0, 0x2d /*kp-= = '-'*/, 0x6d /*kp-0 = 'm'*/, 0x6a /*kp-1 = 'j'*/, 9652 /*0x50*/ 0, 0x1b /*kp-= -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
9648 /*0x54*/ 0x6b /*kp-2 = 'k'*/, 0x6c /*kp-3 = 'l'*/, 'u' /*kp-4*/, 'i' /*kp-5*/, 9653 /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
9649 /*0x58*/ 'o' /*kp-6*/, '7' /*kp-7*/, 0, '8' /*kp-8*/, 9654 /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
9650 /*0x5C*/ '9' /*kp-9*/, 0, 0, 0, 9655 /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
9651 9656
9652 /*0x60*/ 0, 0, 0, 0, 9657 /*0x60*/ 0, 0, 0, 0,
9653 /*0x64*/ 0, 0, 0, 0, 9658 /*0x64*/ 0, 0, 0, 0,
9654 /*0x68*/ 0, 0, 0, 0, 9659 /*0x68*/ 0, 0, 0, 0,
9655 /*0x6C*/ 0, 0, 0, 0, 9660 /*0x6C*/ 0, 0, 0, 0,
9656 9661
9657 /*0x70*/ 0, 0, 0, 0, 9662 /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
9658 /*0x74*/ 0, 0, 0, 0, 9663 /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0, 0x7c /*end -> right*/,
9659 /*0x78*/ 0, 0, 0, 0, 9664 /*0x78*/ 0, 0x7d /*pgdown -> down*/, 0, 0,
9660 /*0x7C*/ 0, 0, 0, 0 9665 /*0x7C*/ 0, 0, 0, 0
9661}; 9666};
9662static int 9667#endif /* MAC_OSX */
9663convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
9664{
9665#ifdef MAC_OSX
9666 /* Use the special map to translate keys when function modifier is
9667 to be caught. KeyTranslate can't be used in that case.
9668 We can't detect the function key using the input_event.modifiers,
9669 because this uses the high word of an UInt32. Therefore,
9670 we'll just read it out of the original eventRef.
9671 */
9672
9673
9674 /* TODO / known issues
9675
9676 - Fn-Shift-j is regonized as Fn-j and not Fn-J.
9677 The above table always translates to lower characters. We need to use
9678 the KCHR keyboard resource (KeyTranslate() ) to map k->K and 8->*.
9679
9680 - The table is meant for English language keyboards, and it will work
9681 for many others with the exception of key combinations like Fn-ö on
9682 a German keyboard, which is currently mapped to Fn-;.
9683 How to solve this without keeping separate tables for all keyboards
9684 around? KeyTranslate isn't of much help here, as it only takes a 16-bit
9685 value for keycode with the modifiers in he high byte, i.e. no room for the
9686 Fn modifier. That's why we need the table.
9687
9688 */
9689 OSStatus err;
9690 UInt32 mods = 0;
9691 if (!NILP(Vmac_function_modifier))
9692 {
9693 err = GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
9694 NULL, sizeof (UInt32), NULL, &mods);
9695 if (err != noErr && mods & kEventKeyModifierFnMask)
9696 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f];
9697
9698 return (*newCode != 0);
9699 }
9700 }
9701#endif
9702 return false;
9703}
9704
9705static int
9706backtranslate_modified_keycode(int mods, int keycode, int def)
9707{
9708 EventModifiers mapped_modifiers =
9709 (NILP (Vmac_control_modifier) ? 0 : controlKey)
9710 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
9711 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
9712
9713 if (mods & mapped_modifiers)
9714 {
9715 /* This code comes from Keyboard Resource,
9716 Appendix C of IM - Text. This is necessary
9717 since shift is ignored in KCHR table
9718 translation when option or command is pressed.
9719 It also does not translate correctly
9720 control-shift chars like C-% so mask off shift
9721 here also.
9722
9723 Not done for combinations with the option key (alt)
9724 unless it is to be caught by Emacs: this is
9725 to preserve key combinations translated by the OS
9726 such as Alt-3.
9727 */
9728 /* Mask off modifier keys that are mapped to some Emacs
9729 modifiers. */
9730 int new_modifiers = mods & ~mapped_modifiers;
9731 /* set high byte of keycode to modifier high byte*/
9732 int new_keycode = keycode | new_modifiers;
9733 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9734 unsigned long some_state = 0;
9735 return (int) KeyTranslate (kchr_ptr, new_keycode,
9736 &some_state) & 0xff;
9737 /* TO DO: Recognize two separate resulting characters, "for
9738 example, when the user presses Option-E followed by N, you
9739 can map this through the KeyTranslate function using the
9740 U.S. 'KCHR' resource to produce ´n, which KeyTranslate
9741 returns as two characters in the bytes labeled Character code
9742 1 and Character code 2." (from Carbon API doc) */
9743
9744 }
9745 else
9746 return def;
9747}
9748
9749 9668
9750#if !USE_CARBON_EVENTS 9669#if !USE_CARBON_EVENTS
9751static RgnHandle mouse_region = NULL; 9670static RgnHandle mouse_region = NULL;
@@ -9819,6 +9738,44 @@ mac_post_mouse_moved_event ()
9819 9738
9820 return err; 9739 return err;
9821} 9740}
9741
9742static void
9743mac_set_unicode_keystroke_event (code, buf)
9744 UniChar code;
9745 struct input_event *buf;
9746{
9747 int charset_id, c1, c2;
9748
9749 if (code < 0x80)
9750 {
9751 buf->kind = ASCII_KEYSTROKE_EVENT;
9752 buf->code = code;
9753 }
9754 else if (code < 0x100)
9755 {
9756 if (code < 0xA0)
9757 charset_id = CHARSET_8_BIT_CONTROL;
9758 else
9759 charset_id = charset_latin_iso8859_1;
9760 buf->kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
9761 buf->code = MAKE_CHAR (charset_id, code, 0);
9762 }
9763 else
9764 {
9765 if (code < 0x2500)
9766 charset_id = charset_mule_unicode_0100_24ff,
9767 code -= 0x100;
9768 else if (code < 0x33FF)
9769 charset_id = charset_mule_unicode_2500_33ff,
9770 code -= 0x2500;
9771 else if (code >= 0xE000)
9772 charset_id = charset_mule_unicode_e000_ffff,
9773 code -= 0xE000;
9774 c1 = (code / 96) + 32, c2 = (code % 96) + 32;
9775 buf->kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
9776 buf->code = MAKE_CHAR (charset_id, c1, c2);
9777 }
9778}
9822#endif 9779#endif
9823 9780
9824/* Emacs calls this whenever it wants to read an input event from the 9781/* Emacs calls this whenever it wants to read an input event from the
@@ -10338,55 +10295,39 @@ XTread_socket (sd, expected, hold_quit)
10338 { 10295 {
10339 int keycode = (er.message & keyCodeMask) >> 8; 10296 int keycode = (er.message & keyCodeMask) >> 8;
10340 int xkeysym; 10297 int xkeysym;
10298 static SInt16 last_key_script = -1;
10299 SInt16 current_key_script;
10300 UInt32 modifiers = er.modifiers, mapped_modifiers;
10301
10302 mapped_modifiers =
10303 (NILP (Vmac_control_modifier) ? 0 : controlKey)
10304 | (NILP (Vmac_option_modifier) ? 0 : optionKey)
10305 | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
10341 10306
10342#if USE_CARBON_EVENTS && defined (MAC_OSX) 10307#if USE_CARBON_EVENTS && defined (MAC_OSX)
10308 mapped_modifiers |=
10309 (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask);
10310
10311 GetEventParameter (eventRef, kEventParamKeyModifiers,
10312 typeUInt32, NULL,
10313 sizeof (UInt32), NULL, &modifiers);
10314
10343 /* When using Carbon Events, we need to pass raw keyboard 10315 /* When using Carbon Events, we need to pass raw keyboard
10344 events to the TSM ourselves. If TSM handles it, it 10316 events to the TSM ourselves. If TSM handles it, it
10345 will pass back noErr, otherwise it will pass back 10317 will pass back noErr, otherwise it will pass back
10346 "eventNotHandledErr" and we can process it 10318 "eventNotHandledErr" and we can process it
10347 normally. */ 10319 normally. */
10348 if ((mac_pass_command_to_system 10320 if (!(modifiers
10349 || !(er.modifiers & cmdKey)) 10321 & mapped_modifiers
10350 && (mac_pass_control_to_system 10322 & ~(mac_pass_command_to_system ? cmdKey : 0)
10351 || !(er.modifiers & controlKey)) 10323 & ~(mac_pass_control_to_system ? controlKey : 0)))
10352 && (NILP (Vmac_option_modifier)
10353 || !(er.modifiers & optionKey)))
10354 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 10324 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
10355 != eventNotHandledErr) 10325 != eventNotHandledErr)
10356 break; 10326 break;
10357#endif 10327#endif
10358 if (er.what == keyUp) 10328 if (er.what == keyUp)
10359 break; 10329 break;
10360 10330
10361#if 0
10362 if (dpyinfo->x_focus_frame == NULL)
10363 {
10364 /* Beep if keyboard input occurs when all the frames
10365 are invisible. */
10366 SysBeep (1);
10367 break;
10368 }
10369#endif
10370
10371 {
10372 static SInt16 last_key_script = -1;
10373 SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
10374
10375 if (last_key_script != current_key_script)
10376 {
10377 struct input_event event;
10378
10379 EVENT_INIT (event);
10380 event.kind = LANGUAGE_CHANGE_EVENT;
10381 event.arg = Qnil;
10382 event.code = current_key_script;
10383 event.timestamp = timestamp;
10384 kbd_buffer_store_event (&event);
10385 count++;
10386 }
10387 last_key_script = current_key_script;
10388 }
10389
10390 ObscureCursor (); 10331 ObscureCursor ();
10391 10332
10392 f = mac_focus_frame (dpyinfo); 10333 f = mac_focus_frame (dpyinfo);
@@ -10398,51 +10339,156 @@ XTread_socket (sd, expected, hold_quit)
10398 dpyinfo->mouse_face_hidden = 1; 10339 dpyinfo->mouse_face_hidden = 1;
10399 } 10340 }
10400 10341
10401 /* translate the keycode back to determine the original key */ 10342 current_key_script = GetScriptManagerVariable (smKeyScript);
10402 /* Convert key code if function key is pressed. 10343 if (last_key_script != current_key_script)
10403 Otherwise, if non-ASCII-event, take care of that
10404 without re-translating the key code. */
10405#if USE_CARBON_EVENTS
10406 if (convert_fn_keycode (eventRef, keycode, &xkeysym))
10407 { 10344 {
10408 inev.code = xkeysym; 10345 struct input_event event;
10409 /* this doesn't work - tried to add shift modifiers */ 10346
10410 inev.code = 10347 EVENT_INIT (event);
10411 backtranslate_modified_keycode(er.modifiers & (~0x2200), 10348 event.kind = LANGUAGE_CHANGE_EVENT;
10412 xkeysym | 0x80, xkeysym); 10349 event.arg = Qnil;
10413 inev.kind = ASCII_KEYSTROKE_EVENT; 10350 event.code = current_key_script;
10351 event.timestamp = timestamp;
10352 kbd_buffer_store_event (&event);
10353 count++;
10354 last_key_script = current_key_script;
10414 } 10355 }
10415 else 10356
10357#ifdef MAC_OSX
10358 if (modifiers & kEventKeyModifierFnMask
10359 && keycode <= 0x7f
10360 && fn_keycode_to_keycode_table[keycode])
10361 keycode = fn_keycode_to_keycode_table[keycode];
10416#endif 10362#endif
10417 if (keycode_to_xkeysym (keycode, &xkeysym)) 10363 if (keycode_to_xkeysym (keycode, &xkeysym))
10418 { 10364 {
10419 inev.code = 0xff00 | xkeysym; 10365 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
10420 inev.kind = NON_ASCII_KEYSTROKE_EVENT; 10366 inev.code = 0xff00 | xkeysym;
10421 } 10367 }
10422 else 10368 else if (modifiers & mapped_modifiers)
10423 { 10369 {
10424 inev.code = 10370 /* translate the keycode back to determine the
10425 backtranslate_modified_keycode(er.modifiers, keycode, 10371 original key */
10426 er.message & charCodeMask); 10372#ifdef MAC_OSX
10427 inev.kind = ASCII_KEYSTROKE_EVENT; 10373 static SInt16 last_key_layout_id = 0;
10428 } 10374 static Handle uchr_handle = (Handle)-1;
10429 } 10375 SInt16 current_key_layout_id =
10376 GetScriptVariable (current_key_script, smScriptKeys);
10377
10378 if (uchr_handle == (Handle)-1
10379 || last_key_layout_id != current_key_layout_id)
10380 {
10381 uchr_handle = GetResource ('uchr', current_key_layout_id);
10382 last_key_layout_id = current_key_layout_id;
10383 }
10384
10385 if (uchr_handle)
10386 {
10387 OSStatus status;
10388 UInt16 key_action = er.what - keyDown;
10389 UInt32 modifier_key_state =
10390 (modifiers & ~mapped_modifiers) >> 8;
10391 UInt32 keyboard_type = LMGetKbdType ();
10392 SInt32 dead_key_state = 0;
10393 UniChar code;
10394 UniCharCount actual_length;
10395
10396 status = UCKeyTranslate ((UCKeyboardLayout *)*uchr_handle,
10397 keycode, key_action,
10398 modifier_key_state,
10399 keyboard_type,
10400 kUCKeyTranslateNoDeadKeysMask,
10401 &dead_key_state,
10402 1, &actual_length, &code);
10403 if (status == noErr && actual_length == 1)
10404 mac_set_unicode_keystroke_event (code, &inev);
10405 }
10406#endif /* MAC_OSX */
10407
10408 if (inev.kind == NO_EVENT)
10409 {
10410 /* This code comes from Keyboard Resource,
10411 Appendix C of IM - Text. This is necessary
10412 since shift is ignored in KCHR table
10413 translation when option or command is pressed.
10414 It also does not translate correctly
10415 control-shift chars like C-% so mask off shift
10416 here also. */
10417 /* Mask off modifier keys that are mapped to some
10418 Emacs modifiers. */
10419 int new_modifiers = er.modifiers & ~mapped_modifiers;
10420 /* set high byte of keycode to modifier high byte*/
10421 int new_keycode = keycode | new_modifiers;
10422 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
10423 unsigned long some_state = 0;
10424 UInt32 new_char_code;
10425
10426 new_char_code = KeyTranslate (kchr_ptr, new_keycode,
10427 &some_state);
10428 if (new_char_code == 0)
10429 /* Seems like a dead key. Append up-stroke. */
10430 new_char_code = KeyTranslate (kchr_ptr,
10431 new_keycode | 0x80,
10432 &some_state);
10433 if (new_char_code)
10434 {
10435 inev.kind = ASCII_KEYSTROKE_EVENT;
10436 inev.code = new_char_code & 0xff;
10437 }
10438 }
10439 }
10440
10441 if (inev.kind == NO_EVENT)
10442 {
10443 inev.kind = ASCII_KEYSTROKE_EVENT;
10444 inev.code = er.message & charCodeMask;
10445 }
10430 10446
10431#if USE_CARBON_EVENTS 10447#if USE_CARBON_EVENTS
10432 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 10448 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
10433#else 10449#else
10434 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 10450 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
10451#endif
10452 inev.modifiers |= (extra_keyboard_modifiers
10453 & (meta_modifier | alt_modifier
10454 | hyper_modifier | super_modifier));
10455 XSETFRAME (inev.frame_or_window, f);
10456
10457#if TARGET_API_MAC_CARBON
10458 if (inev.kind == ASCII_KEYSTROKE_EVENT
10459 && inev.code >= 0x80 && inev.modifiers)
10460 {
10461 OSStatus err;
10462 TextEncoding encoding = kTextEncodingMacRoman;
10463 TextToUnicodeInfo ttu_info;
10464
10465 UpgradeScriptInfoToTextEncoding (current_key_script,
10466 kTextLanguageDontCare,
10467 kTextRegionDontCare,
10468 NULL, &encoding);
10469 err = CreateTextToUnicodeInfoByEncoding (encoding, &ttu_info);
10470 if (err == noErr)
10471 {
10472 UniChar code;
10473 Str255 pstr;
10474 ByteCount unicode_len;
10475
10476 pstr[0] = 1;
10477 pstr[1] = inev.code;
10478 err = ConvertFromPStringToUnicode (ttu_info, pstr,
10479 sizeof (UniChar),
10480 &unicode_len, &code);
10481 if (err == noErr && unicode_len == sizeof (UniChar))
10482 mac_set_unicode_keystroke_event (code, &inev);
10483 DisposeTextToUnicodeInfo (&ttu_info);
10484 }
10485 }
10435#endif 10486#endif
10436 inev.modifiers |= (extra_keyboard_modifiers 10487 }
10437 & (meta_modifier | alt_modifier
10438 | hyper_modifier | super_modifier));
10439 XSETFRAME (inev.frame_or_window, f);
10440 break; 10488 break;
10441 10489
10442 case kHighLevelEvent: 10490 case kHighLevelEvent:
10443 read_socket_inev = &inev;
10444 AEProcessAppleEvent (&er); 10491 AEProcessAppleEvent (&er);
10445 read_socket_inev = NULL;
10446 break; 10492 break;
10447 10493
10448 default: 10494 default:
diff --git a/src/w32.c b/src/w32.c
index 71799befdbb..f11ffb7a785 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -950,11 +950,11 @@ init_environment (char ** argv)
950 struct stat ignored; 950 struct stat ignored;
951 char default_home[MAX_PATH]; 951 char default_home[MAX_PATH];
952 952
953 static struct env_entry 953 static const struct env_entry
954 { 954 {
955 char * name; 955 char * name;
956 char * def_value; 956 char * def_value;
957 } env_vars[] = 957 } dflt_envvars[] =
958 { 958 {
959 {"HOME", "C:/"}, 959 {"HOME", "C:/"},
960 {"PRELOAD_WINSOCK", NULL}, 960 {"PRELOAD_WINSOCK", NULL},
@@ -971,6 +971,17 @@ init_environment (char ** argv)
971 {"LANG", NULL}, 971 {"LANG", NULL},
972 }; 972 };
973 973
974#define N_ENV_VARS sizeof(dflt_envvars)/sizeof(dflt_envvars[0])
975
976 /* We need to copy dflt_envvars[] and work on the copy because we
977 don't want the dumped Emacs to inherit the values of
978 environment variables we saw during dumping (which could be on
979 a different system). The defaults above must be left intact. */
980 struct env_entry env_vars[N_ENV_VARS];
981
982 for (i = 0; i < N_ENV_VARS; i++)
983 env_vars[i] = dflt_envvars[i];
984
974 /* For backwards compatibility, check if a .emacs file exists in C:/ 985 /* For backwards compatibility, check if a .emacs file exists in C:/
975 If not, then we can try to default to the appdata directory under the 986 If not, then we can try to default to the appdata directory under the
976 user's profile, which is more likely to be writable. */ 987 user's profile, which is more likely to be writable. */
@@ -1005,7 +1016,7 @@ init_environment (char ** argv)
1005 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, 1016 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
1006 locale_name, sizeof (locale_name))) 1017 locale_name, sizeof (locale_name)))
1007 { 1018 {
1008 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 1019 for (i = 0; i < N_ENV_VARS; i++)
1009 { 1020 {
1010 if (strcmp (env_vars[i].name, "LANG") == 0) 1021 if (strcmp (env_vars[i].name, "LANG") == 0)
1011 { 1022 {
@@ -1069,7 +1080,7 @@ init_environment (char ** argv)
1069 } 1080 }
1070 } 1081 }
1071 1082
1072 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 1083 for (i = 0; i < N_ENV_VARS; i++)
1073 { 1084 {
1074 if (!getenv (env_vars[i].name)) 1085 if (!getenv (env_vars[i].name))
1075 { 1086 {
@@ -1084,20 +1095,17 @@ init_environment (char ** argv)
1084 1095
1085 if (lpval) 1096 if (lpval)
1086 { 1097 {
1087 if (dwType == REG_EXPAND_SZ) 1098 char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
1088 {
1089 char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
1090 1099
1091 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1)); 1100 if (dwType == REG_EXPAND_SZ)
1092 _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1); 1101 ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
1093 _putenv (strdup (buf2));
1094 }
1095 else if (dwType == REG_SZ) 1102 else if (dwType == REG_SZ)
1103 strcpy (buf1, lpval);
1104 if (dwType == REG_EXPAND_SZ || dwType == REG_SZ)
1096 { 1105 {
1097 char buf[SET_ENV_BUF_SIZE]; 1106 _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name,
1098 1107 buf1);
1099 _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); 1108 _putenv (strdup (buf2));
1100 _putenv (strdup (buf));
1101 } 1109 }
1102 1110
1103 if (!dont_free) 1111 if (!dont_free)
diff --git a/src/xfaces.c b/src/xfaces.c
index 0a77a24189f..1b9a9c079f1 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -6653,7 +6653,7 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
6653 best = NULL; 6653 best = NULL;
6654 6654
6655 /* Find the best match among the non-scalable fonts. */ 6655 /* Find the best match among the non-scalable fonts. */
6656 for (i = 1; i < nfonts; ++i) 6656 for (i = 0; i < nfonts; ++i)
6657 if (!font_scalable_p (fonts + i) 6657 if (!font_scalable_p (fonts + i)
6658 && better_font_p (specified, fonts + i, best, 1, avgwidth)) 6658 && better_font_p (specified, fonts + i, best, 1, avgwidth))
6659 { 6659 {
@@ -6694,30 +6694,30 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
6694 best = fonts + i; 6694 best = fonts + i;
6695 } 6695 }
6696 } 6696 }
6697
6698 if (needs_overstrike)
6699 {
6700 enum xlfd_weight want_weight = specified[XLFD_WEIGHT];
6701 enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT];
6702
6703 if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight)
6704 {
6705 /* We want a bold font, but didn't get one; try to use
6706 overstriking instead to simulate bold-face. However,
6707 don't overstrike an already-bold fontn unless the
6708 desired weight grossly exceeds the available weight. */
6709 if (got_weight > XLFD_WEIGHT_MEDIUM)
6710 *needs_overstrike = (got_weight - want_weight) > 2;
6711 else
6712 *needs_overstrike = 1;
6713 }
6714 }
6715 } 6697 }
6716 6698
6717 /* We should have found SOME font. */ 6699 /* We should have found SOME font. */
6718 if (best == NULL) 6700 if (best == NULL)
6719 abort (); 6701 abort ();
6720 6702
6703 if (! exact_p && needs_overstrike)
6704 {
6705 enum xlfd_weight want_weight = specified[XLFD_WEIGHT];
6706 enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT];
6707
6708 if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight)
6709 {
6710 /* We want a bold font, but didn't get one; try to use
6711 overstriking instead to simulate bold-face. However,
6712 don't overstrike an already-bold fontn unless the
6713 desired weight grossly exceeds the available weight. */
6714 if (got_weight > XLFD_WEIGHT_MEDIUM)
6715 *needs_overstrike = (got_weight - want_weight) > 2;
6716 else
6717 *needs_overstrike = 1;
6718 }
6719 }
6720
6721 if (font_scalable_p (best)) 6721 if (font_scalable_p (best))
6722 font_name = build_scalable_font_name (f, best, pt); 6722 font_name = build_scalable_font_name (f, best, pt);
6723 else 6723 else
@@ -7091,7 +7091,7 @@ realize_default_face (f)
7091 face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID); 7091 face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID);
7092 7092
7093#ifdef HAVE_WINDOW_SYSTEM 7093#ifdef HAVE_WINDOW_SYSTEM
7094#ifdef HAVE_X_WINDOWS 7094#ifdef HAVE_X_WINDOWS
7095 if (FRAME_X_P (f) && face->font != FRAME_FONT (f)) 7095 if (FRAME_X_P (f) && face->font != FRAME_FONT (f))
7096 /* As the font specified for the frame was not acceptable as a 7096 /* As the font specified for the frame was not acceptable as a
7097 font for the default face (perhaps because auto-scaled fonts 7097 font for the default face (perhaps because auto-scaled fonts
diff --git a/src/xterm.c b/src/xterm.c
index 356ee3b963b..cc06c48df33 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -324,22 +324,10 @@ static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *));
324static void x_set_window_size_1 P_ ((struct frame *, int, int, int)); 324static void x_set_window_size_1 P_ ((struct frame *, int, int, int));
325static const XColor *x_color_cells P_ ((Display *, int *)); 325static const XColor *x_color_cells P_ ((Display *, int *));
326static void x_update_window_end P_ ((struct window *, int, int)); 326static void x_update_window_end P_ ((struct window *, int, int));
327void x_delete_display P_ ((struct x_display_info *));
328 327
329static int x_io_error_quitter P_ ((Display *)); 328static int x_io_error_quitter P_ ((Display *));
330void x_catch_errors P_ ((Display *));
331void x_uncatch_errors P_ ((void));
332void x_lower_frame P_ ((struct frame *));
333void x_scroll_bar_clear P_ ((struct frame *));
334int x_had_errors_p P_ ((Display *));
335void x_wm_set_size_hint P_ ((struct frame *, long, int));
336void x_raise_frame P_ ((struct frame *));
337void x_set_window_size P_ ((struct frame *, int, int, int));
338void x_wm_set_window_state P_ ((struct frame *, int));
339void x_wm_set_icon_pixmap P_ ((struct frame *, int));
340static struct terminal *x_create_terminal P_ ((struct x_display_info *)); 329static struct terminal *x_create_terminal P_ ((struct x_display_info *));
341void x_delete_terminal P_ ((struct terminal *)); 330void x_delete_terminal P_ ((struct terminal *));
342void x_initialize P_ ((void));
343static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); 331static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
344static int x_compute_min_glyph_bounds P_ ((struct frame *)); 332static int x_compute_min_glyph_bounds P_ ((struct frame *));
345static void x_update_end P_ ((struct frame *)); 333static void x_update_end P_ ((struct frame *));
diff --git a/src/xterm.h b/src/xterm.h
index b54c39f2fd0..03d7b630d65 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -961,10 +961,6 @@ void x_delete_display P_ ((struct x_display_info *));
961void x_make_frame_visible P_ ((struct frame *)); 961void x_make_frame_visible P_ ((struct frame *));
962void x_iconify_frame P_ ((struct frame *)); 962void x_iconify_frame P_ ((struct frame *));
963void x_wm_set_size_hint P_ ((struct frame *, long, int)); 963void x_wm_set_size_hint P_ ((struct frame *, long, int));
964void x_catch_errors P_ ((Display *));
965int x_had_errors_p P_ ((Display *));
966void x_uncatch_errors P_ ((void));
967void x_check_errors P_ ((Display *, char *));
968int x_text_icon P_ ((struct frame *, char *)); 964int x_text_icon P_ ((struct frame *, char *));
969int x_bitmap_icon P_ ((struct frame *, Lisp_Object)); 965int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
970void x_set_window_size P_ ((struct frame *, int, int, int)); 966void x_set_window_size P_ ((struct frame *, int, int, int));
@@ -980,7 +976,10 @@ extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
980extern void x_catch_errors P_ ((Display *)); 976extern void x_catch_errors P_ ((Display *));
981extern void x_check_errors P_ ((Display *, char *)); 977extern void x_check_errors P_ ((Display *, char *));
982extern int x_had_errors_p P_ ((Display *)); 978extern int x_had_errors_p P_ ((Display *));
979extern int x_catching_errors P_ ((void));
983extern void x_uncatch_errors P_ ((void)); 980extern void x_uncatch_errors P_ ((void));
981extern void x_clear_errors P_ ((Display *));
982extern void x_fully_uncatch_errors P_ ((void));
984extern void x_set_window_size P_ ((struct frame *, int, int, int)); 983extern void x_set_window_size P_ ((struct frame *, int, int, int));
985extern void x_set_mouse_position P_ ((struct frame *, int, int)); 984extern void x_set_mouse_position P_ ((struct frame *, int, int));
986extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int)); 985extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));
@@ -1000,6 +999,9 @@ extern void x_initialize P_ ((void));
1000extern unsigned long x_copy_color P_ ((struct frame *, unsigned long)); 999extern unsigned long x_copy_color P_ ((struct frame *, unsigned long));
1001#ifdef USE_X_TOOLKIT 1000#ifdef USE_X_TOOLKIT
1002extern XtAppContext Xt_app_con; 1001extern XtAppContext Xt_app_con;
1002extern int x_alloc_lighter_color_for_widget __P ((Widget, Display*, Colormap,
1003 unsigned long *,
1004 double, int));
1003#endif 1005#endif
1004extern void x_query_colors P_ ((struct frame *f, XColor *, int)); 1006extern void x_query_colors P_ ((struct frame *f, XColor *, int));
1005extern void x_query_color P_ ((struct frame *f, XColor *)); 1007extern void x_query_color P_ ((struct frame *f, XColor *));