summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 @@
+2006-05-23 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macterm.c (fn_keycode_to_xkeysym_table, convert_fn_keycode): Remove.
+ (fn_keycode_to_keycode_table) [MAC_OSX]: New variable.
+ (mac_set_unicode_keystroke_event) [TARGET_API_MAC_CARBON]: New function.
+ (XTread_socket) [TARGET_API_MAC_CARBON]: Use it.
+ (XTread_socket) [MAC_OSX]: Try 'uchr' Unicode keyboard-layout
+ resource to backtranslate key with modifiers.
+ (XTread_socket): Don't set read_socket_inev around AEProcessAppleEvent.
+
+2006-05-23 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * xterm.c: Remove declarations already in xterm.h
+
+ * xterm.h: Add extern declarations for x_clear_errors,
+ x_fully_uncatch_errors, x_catching_errors and
+ x_alloc_lighter_color_for_widget. Remove duplicated declarations.
+
+2006-05-21 Richard Stallman <rms@gnu.org>
+
+ * buffer.c (syms_of_buffer, Fmake_overlay): Doc fixes.
+
+2006-05-20 Kim F. Storm <storm@cua.dk>
+
+ * xfaces.c (best_matching_font): Fix crash in 2006-05-17 change.
+
+2006-05-20 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
+
+ * macterm.c (convert_fn_keycode): Fix last change.
+
+2006-05-19 Eli Zaretskii <eliz@gnu.org>
+
+ * w32.c (init_environment): Perform the processing of environment
+ variables on a copy of default variables and their values, not on
+ the original. Simplify code that calls ExpandEnvironmentStrings
+ and make buf1[] and buf2[] more visible for easier debugging.
+
2006-05-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* frame.c (x_set_border_width): Remove #ifndef MAC_OS.
@@ -49,6 +86,13 @@
* xdisp.c (display_tool_bar_line): Don't adjust tool-bar height by more than
height of one frame default line.
+2006-05-17 Richard Stallman <rms@gnu.org>
+
+ * xfaces.c (better_font_p): Any font beats no font.
+ (best_matching_font): Simplify based on above change.
+
+ * buffer.c (Fprevious_overlay_change, Fnext_overlay_change): Doc fixes.
+
2006-05-16 Kim F. Storm <storm@cua.dk>
* xterm.c (handle_one_xevent): Check that f is not NULL before
@@ -113,7 +157,7 @@
[MAC_OS] (gif_load): Emulate Graphic Control Extension block.
* macfns.c (x_to_mac_color): Fix shift amount change.
- [USE_MAC_FONT_PANEL] (mac_set_font): Use x_get_focus_frame.
+ (mac_set_font) [USE_MAC_FONT_PANEL]: Use x_get_focus_frame.
[USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): Doc fix.
* 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.
BEG and END may be integers or markers.
The fourth arg FRONT-ADVANCE, if non-nil, makes the marker
for the front of the overlay advance when text is inserted there
-(which means the text *is not* included in the overlay).
+\(which means the text *is not* included in the overlay).
The fifth arg REAR-ADVANCE, if non-nil, makes the marker
for the rear of the overlay advance when text is inserted there
-(which means the text *is* included in the overlay). */)
+\(which means the text *is* included in the overlay). */)
(beg, end, buffer, front_advance, rear_advance)
Lisp_Object beg, end, buffer;
Lisp_Object front_advance, rear_advance;
@@ -5769,7 +5769,7 @@ the actual bitmap shown in the left or right fringe for the logical
indicator. LEFT and RIGHT are the bitmaps shown in the left and/or
right fringe for the specific indicator. The LEFT1 or RIGHT1 bitmaps
are used only for the `bottom' and `one-line' indicators when the last
-(only) line in has no final newline. BITMAPS may also be a single
+\(only) line in has no final newline. BITMAPS may also be a single
symbol which is used in both left and right fringes. */);
DEFVAR_PER_BUFFER ("fringe-cursor-alist",
@@ -6016,7 +6016,7 @@ this variable has no effect; the cursor appears as a hollow box. */);
doc: /* Additional space to put between lines when displaying a buffer.
The space is measured in pixels, and put below lines on window systems.
If value is a floating point number, it specifies the spacing relative
-to the default frame line height. */);
+to the default frame line height. nil means add no extra space. */);
DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
&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
|| (coding)->common_flags & CODING_REQUIRE_DECODING_MASK)
/* Return 1 if the coding system CODING requires code conversion on
- encoding. */
+ encoding.
+ The non-multibyte part of the condition is to support encoding of
+ unibyte strings/buffers generated by string-as-unibyte or
+ (set-buffer-multibyte nil) from multibyte strings/buffers. */
#define CODING_REQUIRE_ENCODING(coding) \
((coding)->src_multibyte \
|| (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)
register INTERVAL to, from, toprev, fromprev;
int buffer_point;
int old_position = BUF_PT (buffer);
+ /* This ensures that we move forward past intangible text when the
+ initial position is the same as the destination, in the rare
+ instances where this is important, e.g. in line-move-finish
+ (simple.el). */
int backwards = (charpos < old_position ? 1 : 0);
int have_overlays;
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)
return *xKeySym != 0;
}
-static unsigned char fn_keycode_to_xkeysym_table[] = {
+#ifdef MAC_OSX
+/* Table for translating Mac keycode with the laptop `fn' key to that
+ without it. Destination symbols in comments are keys on US
+ keyboard, and they may not be the same on other types of
+ keyboards. */
+static unsigned char fn_keycode_to_keycode_table[] = {
/*0x00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*0x10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*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[] = {
/*0x38*/ 0, 0, 0, 0,
/*0x3C*/ 0, 0, 0, 0,
- /*0x40*/ 0, 0x2e /*kp-. = .*/, 0, 0x50 /*kp-* = 'p'*/,
- /*0x44*/ 0, '/' /*kp-+*/, 0, 0,
- /*0x48*/ 0, 0, 0, 0x30 /*kp-/ = '0'*/,
- /*0x4C*/ 0, 0, 0x3b /*kp-- = ';'*/, 0,
+ /*0x40*/ 0, 0x2f /*kp-. -> '.'*/, 0, 0x23 /*kp-* -> 'p'*/,
+ /*0x44*/ 0, 0x2c /*kp-+ -> '/'*/, 0, 0x16 /*clear -> '6'*/,
+ /*0x48*/ 0, 0, 0, 0x1d /*kp-/ -> '0'*/,
+ /*0x4C*/ 0x24 /*kp-enter -> return*/, 0, 0x29 /*kp-- -> ';'*/, 0,
- /*0x50*/ 0, 0x2d /*kp-= = '-'*/, 0x6d /*kp-0 = 'm'*/, 0x6a /*kp-1 = 'j'*/,
- /*0x54*/ 0x6b /*kp-2 = 'k'*/, 0x6c /*kp-3 = 'l'*/, 'u' /*kp-4*/, 'i' /*kp-5*/,
- /*0x58*/ 'o' /*kp-6*/, '7' /*kp-7*/, 0, '8' /*kp-8*/,
- /*0x5C*/ '9' /*kp-9*/, 0, 0, 0,
+ /*0x50*/ 0, 0x1b /*kp-= -> '-'*/, 0x2e /*kp-0 -> 'm'*/, 0x26 /*kp-1 -> 'j'*/,
+ /*0x54*/ 0x28 /*kp-2 -> 'k'*/, 0x25 /*kp-3 -> 'l'*/, 0x20 /*kp-4 -> 'u'*/, 0x22 /*kp-5 ->'i'*/,
+ /*0x58*/ 0x1f /*kp-6 -> 'o'*/, 0x1a /*kp-7 -> '7'*/, 0, 0x1c /*kp-8 -> '8'*/,
+ /*0x5C*/ 0x19 /*kp-9 -> '9'*/, 0, 0, 0,
/*0x60*/ 0, 0, 0, 0,
/*0x64*/ 0, 0, 0, 0,
/*0x68*/ 0, 0, 0, 0,
/*0x6C*/ 0, 0, 0, 0,
- /*0x70*/ 0, 0, 0, 0,
- /*0x74*/ 0, 0, 0, 0,
- /*0x78*/ 0, 0, 0, 0,
+ /*0x70*/ 0, 0, 0, 0x7b /*home -> left*/,
+ /*0x74*/ 0x7e /*pgup -> up*/, 0x33 /*delete -> backspace*/, 0, 0x7c /*end -> right*/,
+ /*0x78*/ 0, 0x7d /*pgdown -> down*/, 0, 0,
/*0x7C*/ 0, 0, 0, 0
};
-static int
-convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
-{
-#ifdef MAC_OSX
- /* Use the special map to translate keys when function modifier is
- to be caught. KeyTranslate can't be used in that case.
- We can't detect the function key using the input_event.modifiers,
- because this uses the high word of an UInt32. Therefore,
- we'll just read it out of the original eventRef.
- */
-
-
- /* TODO / known issues
-
- - Fn-Shift-j is regonized as Fn-j and not Fn-J.
- The above table always translates to lower characters. We need to use
- the KCHR keyboard resource (KeyTranslate() ) to map k->K and 8->*.
-
- - The table is meant for English language keyboards, and it will work
- for many others with the exception of key combinations like Fn-ö on
- a German keyboard, which is currently mapped to Fn-;.
- How to solve this without keeping separate tables for all keyboards
- around? KeyTranslate isn't of much help here, as it only takes a 16-bit
- value for keycode with the modifiers in he high byte, i.e. no room for the
- Fn modifier. That's why we need the table.
-
- */
- OSStatus err;
- UInt32 mods = 0;
- if (!NILP(Vmac_function_modifier))
- {
- err = GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
- NULL, sizeof (UInt32), NULL, &mods);
- if (err != noErr && mods & kEventKeyModifierFnMask)
- { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f];
-
- return (*newCode != 0);
- }
- }
-#endif
- return false;
-}
-
-static int
-backtranslate_modified_keycode(int mods, int keycode, int def)
-{
- EventModifiers mapped_modifiers =
- (NILP (Vmac_control_modifier) ? 0 : controlKey)
- | (NILP (Vmac_option_modifier) ? 0 : optionKey)
- | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
-
- if (mods & mapped_modifiers)
- {
- /* This code comes from Keyboard Resource,
- Appendix C of IM - Text. This is necessary
- since shift is ignored in KCHR table
- translation when option or command is pressed.
- It also does not translate correctly
- control-shift chars like C-% so mask off shift
- here also.
-
- Not done for combinations with the option key (alt)
- unless it is to be caught by Emacs: this is
- to preserve key combinations translated by the OS
- such as Alt-3.
- */
- /* Mask off modifier keys that are mapped to some Emacs
- modifiers. */
- int new_modifiers = mods & ~mapped_modifiers;
- /* set high byte of keycode to modifier high byte*/
- int new_keycode = keycode | new_modifiers;
- Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
- unsigned long some_state = 0;
- return (int) KeyTranslate (kchr_ptr, new_keycode,
- &some_state) & 0xff;
- /* TO DO: Recognize two separate resulting characters, "for
- example, when the user presses Option-E followed by N, you
- can map this through the KeyTranslate function using the
- U.S. 'KCHR' resource to produce ´n, which KeyTranslate
- returns as two characters in the bytes labeled Character code
- 1 and Character code 2." (from Carbon API doc) */
-
- }
- else
- return def;
-}
-
+#endif /* MAC_OSX */
#if !USE_CARBON_EVENTS
static RgnHandle mouse_region = NULL;
@@ -9819,6 +9738,44 @@ mac_post_mouse_moved_event ()
return err;
}
+
+static void
+mac_set_unicode_keystroke_event (code, buf)
+ UniChar code;
+ struct input_event *buf;
+{
+ int charset_id, c1, c2;
+
+ if (code < 0x80)
+ {
+ buf->kind = ASCII_KEYSTROKE_EVENT;
+ buf->code = code;
+ }
+ else if (code < 0x100)
+ {
+ if (code < 0xA0)
+ charset_id = CHARSET_8_BIT_CONTROL;
+ else
+ charset_id = charset_latin_iso8859_1;
+ buf->kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+ buf->code = MAKE_CHAR (charset_id, code, 0);
+ }
+ else
+ {
+ if (code < 0x2500)
+ charset_id = charset_mule_unicode_0100_24ff,
+ code -= 0x100;
+ else if (code < 0x33FF)
+ charset_id = charset_mule_unicode_2500_33ff,
+ code -= 0x2500;
+ else if (code >= 0xE000)
+ charset_id = charset_mule_unicode_e000_ffff,
+ code -= 0xE000;
+ c1 = (code / 96) + 32, c2 = (code % 96) + 32;
+ buf->kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+ buf->code = MAKE_CHAR (charset_id, c1, c2);
+ }
+}
#endif
/* Emacs calls this whenever it wants to read an input event from the
@@ -10338,55 +10295,39 @@ XTread_socket (sd, expected, hold_quit)
{
int keycode = (er.message & keyCodeMask) >> 8;
int xkeysym;
+ static SInt16 last_key_script = -1;
+ SInt16 current_key_script;
+ UInt32 modifiers = er.modifiers, mapped_modifiers;
+
+ mapped_modifiers =
+ (NILP (Vmac_control_modifier) ? 0 : controlKey)
+ | (NILP (Vmac_option_modifier) ? 0 : optionKey)
+ | (NILP (Vmac_command_modifier) ? 0 : cmdKey);
#if USE_CARBON_EVENTS && defined (MAC_OSX)
+ mapped_modifiers |=
+ (NILP (Vmac_function_modifier) ? 0 : kEventKeyModifierFnMask);
+
+ GetEventParameter (eventRef, kEventParamKeyModifiers,
+ typeUInt32, NULL,
+ sizeof (UInt32), NULL, &modifiers);
+
/* When using Carbon Events, we need to pass raw keyboard
events to the TSM ourselves. If TSM handles it, it
will pass back noErr, otherwise it will pass back
"eventNotHandledErr" and we can process it
normally. */
- if ((mac_pass_command_to_system
- || !(er.modifiers & cmdKey))
- && (mac_pass_control_to_system
- || !(er.modifiers & controlKey))
- && (NILP (Vmac_option_modifier)
- || !(er.modifiers & optionKey)))
+ if (!(modifiers
+ & mapped_modifiers
+ & ~(mac_pass_command_to_system ? cmdKey : 0)
+ & ~(mac_pass_control_to_system ? controlKey : 0)))
if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
!= eventNotHandledErr)
- break;
+ break;
#endif
if (er.what == keyUp)
break;
-#if 0
- if (dpyinfo->x_focus_frame == NULL)
- {
- /* Beep if keyboard input occurs when all the frames
- are invisible. */
- SysBeep (1);
- break;
- }
-#endif
-
- {
- static SInt16 last_key_script = -1;
- SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
-
- if (last_key_script != current_key_script)
- {
- struct input_event event;
-
- EVENT_INIT (event);
- event.kind = LANGUAGE_CHANGE_EVENT;
- event.arg = Qnil;
- event.code = current_key_script;
- event.timestamp = timestamp;
- kbd_buffer_store_event (&event);
- count++;
- }
- last_key_script = current_key_script;
- }
-
ObscureCursor ();
f = mac_focus_frame (dpyinfo);
@@ -10398,51 +10339,156 @@ XTread_socket (sd, expected, hold_quit)
dpyinfo->mouse_face_hidden = 1;
}
- /* translate the keycode back to determine the original key */
- /* Convert key code if function key is pressed.
- Otherwise, if non-ASCII-event, take care of that
- without re-translating the key code. */
-#if USE_CARBON_EVENTS
- if (convert_fn_keycode (eventRef, keycode, &xkeysym))
+ current_key_script = GetScriptManagerVariable (smKeyScript);
+ if (last_key_script != current_key_script)
{
- inev.code = xkeysym;
- /* this doesn't work - tried to add shift modifiers */
- inev.code =
- backtranslate_modified_keycode(er.modifiers & (~0x2200),
- xkeysym | 0x80, xkeysym);
- inev.kind = ASCII_KEYSTROKE_EVENT;
+ struct input_event event;
+
+ EVENT_INIT (event);
+ event.kind = LANGUAGE_CHANGE_EVENT;
+ event.arg = Qnil;
+ event.code = current_key_script;
+ event.timestamp = timestamp;
+ kbd_buffer_store_event (&event);
+ count++;
+ last_key_script = current_key_script;
}
- else
+
+#ifdef MAC_OSX
+ if (modifiers & kEventKeyModifierFnMask
+ && keycode <= 0x7f
+ && fn_keycode_to_keycode_table[keycode])
+ keycode = fn_keycode_to_keycode_table[keycode];
#endif
- if (keycode_to_xkeysym (keycode, &xkeysym))
- {
- inev.code = 0xff00 | xkeysym;
- inev.kind = NON_ASCII_KEYSTROKE_EVENT;
- }
- else
- {
- inev.code =
- backtranslate_modified_keycode(er.modifiers, keycode,
- er.message & charCodeMask);
- inev.kind = ASCII_KEYSTROKE_EVENT;
- }
- }
+ if (keycode_to_xkeysym (keycode, &xkeysym))
+ {
+ inev.kind = NON_ASCII_KEYSTROKE_EVENT;
+ inev.code = 0xff00 | xkeysym;
+ }
+ else if (modifiers & mapped_modifiers)
+ {
+ /* translate the keycode back to determine the
+ original key */
+#ifdef MAC_OSX
+ static SInt16 last_key_layout_id = 0;
+ static Handle uchr_handle = (Handle)-1;
+ SInt16 current_key_layout_id =
+ GetScriptVariable (current_key_script, smScriptKeys);
+
+ if (uchr_handle == (Handle)-1
+ || last_key_layout_id != current_key_layout_id)
+ {
+ uchr_handle = GetResource ('uchr', current_key_layout_id);
+ last_key_layout_id = current_key_layout_id;
+ }
+
+ if (uchr_handle)
+ {
+ OSStatus status;
+ UInt16 key_action = er.what - keyDown;
+ UInt32 modifier_key_state =
+ (modifiers & ~mapped_modifiers) >> 8;
+ UInt32 keyboard_type = LMGetKbdType ();
+ SInt32 dead_key_state = 0;
+ UniChar code;
+ UniCharCount actual_length;
+
+ status = UCKeyTranslate ((UCKeyboardLayout *)*uchr_handle,
+ keycode, key_action,
+ modifier_key_state,
+ keyboard_type,
+ kUCKeyTranslateNoDeadKeysMask,
+ &dead_key_state,
+ 1, &actual_length, &code);
+ if (status == noErr && actual_length == 1)
+ mac_set_unicode_keystroke_event (code, &inev);
+ }
+#endif /* MAC_OSX */
+
+ if (inev.kind == NO_EVENT)
+ {
+ /* This code comes from Keyboard Resource,
+ Appendix C of IM - Text. This is necessary
+ since shift is ignored in KCHR table
+ translation when option or command is pressed.
+ It also does not translate correctly
+ control-shift chars like C-% so mask off shift
+ here also. */
+ /* Mask off modifier keys that are mapped to some
+ Emacs modifiers. */
+ int new_modifiers = er.modifiers & ~mapped_modifiers;
+ /* set high byte of keycode to modifier high byte*/
+ int new_keycode = keycode | new_modifiers;
+ Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
+ unsigned long some_state = 0;
+ UInt32 new_char_code;
+
+ new_char_code = KeyTranslate (kchr_ptr, new_keycode,
+ &some_state);
+ if (new_char_code == 0)
+ /* Seems like a dead key. Append up-stroke. */
+ new_char_code = KeyTranslate (kchr_ptr,
+ new_keycode | 0x80,
+ &some_state);
+ if (new_char_code)
+ {
+ inev.kind = ASCII_KEYSTROKE_EVENT;
+ inev.code = new_char_code & 0xff;
+ }
+ }
+ }
+
+ if (inev.kind == NO_EVENT)
+ {
+ inev.kind = ASCII_KEYSTROKE_EVENT;
+ inev.code = er.message & charCodeMask;
+ }
#if USE_CARBON_EVENTS
- inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
+ inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
#else
- inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
+ inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
+#endif
+ inev.modifiers |= (extra_keyboard_modifiers
+ & (meta_modifier | alt_modifier
+ | hyper_modifier | super_modifier));
+ XSETFRAME (inev.frame_or_window, f);
+
+#if TARGET_API_MAC_CARBON
+ if (inev.kind == ASCII_KEYSTROKE_EVENT
+ && inev.code >= 0x80 && inev.modifiers)
+ {
+ OSStatus err;
+ TextEncoding encoding = kTextEncodingMacRoman;
+ TextToUnicodeInfo ttu_info;
+
+ UpgradeScriptInfoToTextEncoding (current_key_script,
+ kTextLanguageDontCare,
+ kTextRegionDontCare,
+ NULL, &encoding);
+ err = CreateTextToUnicodeInfoByEncoding (encoding, &ttu_info);
+ if (err == noErr)
+ {
+ UniChar code;
+ Str255 pstr;
+ ByteCount unicode_len;
+
+ pstr[0] = 1;
+ pstr[1] = inev.code;
+ err = ConvertFromPStringToUnicode (ttu_info, pstr,
+ sizeof (UniChar),
+ &unicode_len, &code);
+ if (err == noErr && unicode_len == sizeof (UniChar))
+ mac_set_unicode_keystroke_event (code, &inev);
+ DisposeTextToUnicodeInfo (&ttu_info);
+ }
+ }
#endif
- inev.modifiers |= (extra_keyboard_modifiers
- & (meta_modifier | alt_modifier
- | hyper_modifier | super_modifier));
- XSETFRAME (inev.frame_or_window, f);
+ }
break;
case kHighLevelEvent:
- read_socket_inev = &inev;
AEProcessAppleEvent (&er);
- read_socket_inev = NULL;
break;
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)
struct stat ignored;
char default_home[MAX_PATH];
- static struct env_entry
+ static const struct env_entry
{
char * name;
char * def_value;
- } env_vars[] =
+ } dflt_envvars[] =
{
{"HOME", "C:/"},
{"PRELOAD_WINSOCK", NULL},
@@ -971,6 +971,17 @@ init_environment (char ** argv)
{"LANG", NULL},
};
+#define N_ENV_VARS sizeof(dflt_envvars)/sizeof(dflt_envvars[0])
+
+ /* We need to copy dflt_envvars[] and work on the copy because we
+ don't want the dumped Emacs to inherit the values of
+ environment variables we saw during dumping (which could be on
+ a different system). The defaults above must be left intact. */
+ struct env_entry env_vars[N_ENV_VARS];
+
+ for (i = 0; i < N_ENV_VARS; i++)
+ env_vars[i] = dflt_envvars[i];
+
/* For backwards compatibility, check if a .emacs file exists in C:/
If not, then we can try to default to the appdata directory under the
user's profile, which is more likely to be writable. */
@@ -1005,7 +1016,7 @@ init_environment (char ** argv)
LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
locale_name, sizeof (locale_name)))
{
- for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
+ for (i = 0; i < N_ENV_VARS; i++)
{
if (strcmp (env_vars[i].name, "LANG") == 0)
{
@@ -1069,7 +1080,7 @@ init_environment (char ** argv)
}
}
- for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
+ for (i = 0; i < N_ENV_VARS; i++)
{
if (!getenv (env_vars[i].name))
{
@@ -1084,20 +1095,17 @@ init_environment (char ** argv)
if (lpval)
{
- if (dwType == REG_EXPAND_SZ)
- {
- char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
+ char buf1[SET_ENV_BUF_SIZE], buf2[SET_ENV_BUF_SIZE];
- ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
- _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1);
- _putenv (strdup (buf2));
- }
+ if (dwType == REG_EXPAND_SZ)
+ ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1));
else if (dwType == REG_SZ)
+ strcpy (buf1, lpval);
+ if (dwType == REG_EXPAND_SZ || dwType == REG_SZ)
{
- char buf[SET_ENV_BUF_SIZE];
-
- _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval);
- _putenv (strdup (buf));
+ _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name,
+ buf1);
+ _putenv (strdup (buf2));
}
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)
best = NULL;
/* Find the best match among the non-scalable fonts. */
- for (i = 1; i < nfonts; ++i)
+ for (i = 0; i < nfonts; ++i)
if (!font_scalable_p (fonts + i)
&& better_font_p (specified, fonts + i, best, 1, avgwidth))
{
@@ -6694,30 +6694,30 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
best = fonts + i;
}
}
-
- if (needs_overstrike)
- {
- enum xlfd_weight want_weight = specified[XLFD_WEIGHT];
- enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT];
-
- if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight)
- {
- /* We want a bold font, but didn't get one; try to use
- overstriking instead to simulate bold-face. However,
- don't overstrike an already-bold fontn unless the
- desired weight grossly exceeds the available weight. */
- if (got_weight > XLFD_WEIGHT_MEDIUM)
- *needs_overstrike = (got_weight - want_weight) > 2;
- else
- *needs_overstrike = 1;
- }
- }
}
/* We should have found SOME font. */
if (best == NULL)
abort ();
+ if (! exact_p && needs_overstrike)
+ {
+ enum xlfd_weight want_weight = specified[XLFD_WEIGHT];
+ enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT];
+
+ if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight)
+ {
+ /* We want a bold font, but didn't get one; try to use
+ overstriking instead to simulate bold-face. However,
+ don't overstrike an already-bold fontn unless the
+ desired weight grossly exceeds the available weight. */
+ if (got_weight > XLFD_WEIGHT_MEDIUM)
+ *needs_overstrike = (got_weight - want_weight) > 2;
+ else
+ *needs_overstrike = 1;
+ }
+ }
+
if (font_scalable_p (best))
font_name = build_scalable_font_name (f, best, pt);
else
@@ -7091,7 +7091,7 @@ realize_default_face (f)
face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID);
#ifdef HAVE_WINDOW_SYSTEM
-#ifdef HAVE_X_WINDOWS
+#ifdef HAVE_X_WINDOWS
if (FRAME_X_P (f) && face->font != FRAME_FONT (f))
/* As the font specified for the frame was not acceptable as a
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 *));
static void x_set_window_size_1 P_ ((struct frame *, int, int, int));
static const XColor *x_color_cells P_ ((Display *, int *));
static void x_update_window_end P_ ((struct window *, int, int));
-void x_delete_display P_ ((struct x_display_info *));
static int x_io_error_quitter P_ ((Display *));
-void x_catch_errors P_ ((Display *));
-void x_uncatch_errors P_ ((void));
-void x_lower_frame P_ ((struct frame *));
-void x_scroll_bar_clear P_ ((struct frame *));
-int x_had_errors_p P_ ((Display *));
-void x_wm_set_size_hint P_ ((struct frame *, long, int));
-void x_raise_frame P_ ((struct frame *));
-void x_set_window_size P_ ((struct frame *, int, int, int));
-void x_wm_set_window_state P_ ((struct frame *, int));
-void x_wm_set_icon_pixmap P_ ((struct frame *, int));
static struct terminal *x_create_terminal P_ ((struct x_display_info *));
void x_delete_terminal P_ ((struct terminal *));
-void x_initialize P_ ((void));
static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
static int x_compute_min_glyph_bounds P_ ((struct frame *));
static 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 *));
void x_make_frame_visible P_ ((struct frame *));
void x_iconify_frame P_ ((struct frame *));
void x_wm_set_size_hint P_ ((struct frame *, long, int));
-void x_catch_errors P_ ((Display *));
-int x_had_errors_p P_ ((Display *));
-void x_uncatch_errors P_ ((void));
-void x_check_errors P_ ((Display *, char *));
int x_text_icon P_ ((struct frame *, char *));
int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
void x_set_window_size P_ ((struct frame *, int, int, int));
@@ -980,7 +976,10 @@ extern int x_bitmap_icon P_ ((struct frame *, Lisp_Object));
extern void x_catch_errors P_ ((Display *));
extern void x_check_errors P_ ((Display *, char *));
extern int x_had_errors_p P_ ((Display *));
+extern int x_catching_errors P_ ((void));
extern void x_uncatch_errors P_ ((void));
+extern void x_clear_errors P_ ((Display *));
+extern void x_fully_uncatch_errors P_ ((void));
extern void x_set_window_size P_ ((struct frame *, int, int, int));
extern void x_set_mouse_position P_ ((struct frame *, int, int));
extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));
@@ -1000,6 +999,9 @@ extern void x_initialize P_ ((void));
extern unsigned long x_copy_color P_ ((struct frame *, unsigned long));
#ifdef USE_X_TOOLKIT
extern XtAppContext Xt_app_con;
+extern int x_alloc_lighter_color_for_widget __P ((Widget, Display*, Colormap,
+ unsigned long *,
+ double, int));
#endif
extern void x_query_colors P_ ((struct frame *f, XColor *, int));
extern void x_query_color P_ ((struct frame *f, XColor *));