aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2005-04-21 05:59:53 +0000
committerMiles Bader2005-04-21 05:59:53 +0000
commit135f59d513767b781223f651cd6a5f139f270c2c (patch)
treea7e4b5e507f3435fa5070e9f956be279f5c3df27 /src
parentdb92e81ec1e176c3bd2bc58bf6d6a33d3df5c07b (diff)
parent2375e71aff23becd70d22689895512e2d95d3c0f (diff)
downloademacs-135f59d513767b781223f651cd6a5f139f270c2c.tar.gz
emacs-135f59d513767b781223f651cd6a5f139f270c2c.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-39
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 258-271) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 66) - Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog252
-rw-r--r--src/Makefile.in11
-rw-r--r--src/config.in9
-rw-r--r--src/dired.c6
-rw-r--r--src/dispextern.h8
-rw-r--r--src/dispnew.c6
-rw-r--r--src/editfns.c4
-rw-r--r--src/fileio.c4
-rw-r--r--src/filelock.c6
-rw-r--r--src/fns.c17
-rw-r--r--src/fringe.c16
-rw-r--r--src/image.c2
-rw-r--r--src/lisp.h1
-rw-r--r--src/lread.c6
-rw-r--r--src/mac.c82
-rw-r--r--src/macfns.c18
-rw-r--r--src/macgui.h6
-rw-r--r--src/macterm.c1082
-rw-r--r--src/macterm.h11
-rw-r--r--src/sysdep.c1
-rw-r--r--src/term.c21
-rw-r--r--src/window.c1
-rw-r--r--src/window.h3
-rw-r--r--src/xdisp.c102
-rw-r--r--src/xfaces.c13
-rw-r--r--src/xmenu.c10
-rw-r--r--src/xrdb.c4
27 files changed, 1001 insertions, 701 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5847c35f37a..7ace79442e9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,223 @@
12005-04-20 Thien-Thi Nguyen <ttn@gnu.org>
2
3 * sysdep.c: Remove reference to defunct vms-pwd.h.
4 * dired.c: Likewise. Also, for pwd.h, use HAVE_PWD_H, not !VMS.
5 * editfns.c, fileio.c, filelock.c, sysdep.c, xrdb.c: Likewise.
6
7 * config.in: Regenerate.
8
92005-04-20 Kenichi Handa <handa@m17n.org>
10
11 * lisp.h (CHAR_TABLE_DEFAULT_SLOT_ASCII): New macro.
12 (CHAR_TABLE_DEFAULT_SLOT_8_BIT_CONTROL): New macro.
13 (CHAR_TABLE_DEFAULT_SLOT_8_BIT_GRAPHIC): New macro.
14
15 * alloc.c (make_sub_char_table): Argument changed to initial
16 value of the slots.
17
18 * data.c (Faref): Handle special slots used as default values of
19 ascii, eight-bit-control, eight-bit-control. Don't ignore a
20 default value set for a group of characters.
21 (Faset): Signal an error if IDXVAL is not a valid character code.
22 Make a sub-chartable with correct initial value.
23
24 * fns.c (Fset_char_table_range): Don't set slots used as default
25 values for ascii, eight-bit-control, eight-bit-graphic. Don't
26 call Faref with charset-id.
27 (Fset_char_table_default): Document how to treat normal character
28 argument. Handle special slots used as default values of ascii,
29 eight-bit-control, eight-bit-control. Make a sub chartable if
30 necessary.
31
322005-04-20 Kenichi Handa <handa@m17n.org>
33
34 * search.c (boyer_moore): Fix previous change.
35
362005-04-19 Kim F. Storm <storm@cua.dk>
37
38 * xdisp.c (setup_for_ellipsis): Reset saved_face_id to use default
39 face unless last visible char and first invisible char have the
40 same face. Also use default face if saved_face_id is undefined.
41
422005-04-19 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
43
44 * macgui.h (MacFontStruct): Remove member `fontname'. Add member
45 `full_name'.
46 [TARGET_API_MAC_CARBON] (MacFontStruct): Use type int for
47 mac_scriptcode member.
48
49 * macterm.c (Qbig5, Qcn_gb, Qsjis, Qeuc_kr): Remove variables.
50 (syms_of_mac): Don't initialize them.
51 (Vmac_charset_info_alist): New variable.
52 (syms_of_mac): Defvar it.
53 (create_text_encoding_info_alist): New function.
54 (decode_mac_font_name, mac_to_x_fontname)
55 (x_font_name_to_mac_font_name, init_font_name_table): Don't hard
56 code the correspondence among XLFD charsets, Mac script codes, and
57 Emacs coding systems. Use Vmac_charset_info_alist and result of
58 create_text_encoding_info_alist instead.
59 (init_font_name_table) [TARGET_API_MAC_CARBON]: Use Font Manager
60 routines also on Mac OS Classic.
61 (init_font_name_table) [!TARGET_API_MAC_CARBON]: Use
62 add_font_name_table_entry.
63 (mac_do_list_fonts): Regard 0 in XLFD scaleble fields as
64 specified. Derive unspecified scalable fields from specified one.
65 (x_list_fonts): Consider Valternate_fontname_alist.
66 (kDefaultFontSize): Change value from 9 to 12.
67 (XLoadQueryFont): Get decoded font family, font face, and charset
68 from x_font_name_to_mac_font_name. Set full name of loaded font.
69 (mac_unload_font): Free `full_name' member.
70 (x_load_font): Don't try XLoadQueryFont if x_list_fonts returns
71 NULL. Copy full_name member of struct MacFontStruct to that of
72 struct font_info.
73
742005-04-19 Kim F. Storm <storm@cua.dk>
75
76 * xdisp.c (handle_stop): Set saved_face_id to current face if
77 selective_display_ellipsis_p so ellipsis will be shown in same
78 face as preceding text.
79 (setup_for_ellipsis): Don't set saved_face_id here.
80 (next_element_from_display_vector): Default to saved_face_id.
81
82 * fns.c (Fsafe_get): New function.
83 (syms_of_fns): Defsubr it.
84
85 * lisp.h (Fsafe_get): EXFUN it.
86
87 * xfaces.c (resolve_face_name): Use Fsafe_get to avoid redisplay
88 loops in case of bad face property lists. Limit number of face
89 alias lookups to 10 (in case of face alias loops).
90
912005-04-18 Kim F. Storm <storm@cua.dk>
92
93 * dispextern.h (struct glyph_row): New member overlay_arrow_bitmap.
94 It replaces the corresponding member from struct window, as a
95 window may now show multiple overlay arrows.
96 Remove member overlay_arrow_p, superseeded by overlay_arrow_bitmap.
97
98 * dispnew.c (row_equal_p, update_window_line, scrolling_window):
99 Compare overlay_arrow_bitmap than overlay_arrow_p members.
100
101 * fringe.c (draw_fringe_bitmap): Use overlay_arrow_bitmap from row
102 rather than from window.
103 (update_window_fringes): Compare overlay_arrow_bitmap rather than
104 overlay_arrow_p members.
105 (Ffringe_bitmaps_at_pos): Return fringe overlay_arrow_bitmap name
106 if not default.
107
108 * window.h (struct window): Remove member overlay_arrow_bitmap.
109
110 * window.c (make_window): Don't initialize overlay_arrow_bitmap.
111
112 * xdisp.c (overlay_arrow_string_or_property): Remove PBITMAP arg.
113 Calls changed. Don't check for overlay-arrow-bitmap property here.
114 (overlay_arrow_at_row): Remove PBITMAP arg. Instead, if left
115 fringe is present, return Lisp integer for bitmap (or -1 for default).
116 Fix value of overlay-arrow-bitmap property to be a symbol, use
117 lookup_fringe_bitmap to parse it.
118 (display_line): Change call to overlay_arrow_at_row. Store integer
119 return value as overlay bitmap in row rather than window.
120 Only show overlay arrow if row displays text, or if no other overlay
121 arrow is seen in window (if overlay marker is at point-max).
122
1232005-04-18 Thien-Thi Nguyen <ttn@gnu.org>
124
125 * xfaces.c (realize_x_face) [!HAVE_WINDOW_SYSTEM]: Return NULL.
126
1272005-04-18 Lute Kamstra <lute@gnu.org>
128
129 * lread.c (Vloads_in_progress): Static.
130 * fns.c (Vloads_in_progress): Remove extern.
131 (load_in_progress): Add extern.
132 (Frequire): Use load_in_progress instead of Vloads_in_progress.
133
1342005-04-18 Thien-Thi Nguyen <ttn@gnu.org>
135
136 * xmenu.c (Fx_popup_menu): Initialize error_name to NULL.
137
1382005-04-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
139
140 * macterm.c (XTread_socket): Don't beep on keyboard input even if
141 no frame is visible.
142
1432005-04-16 Dan Nicolaescu <dann@ics.uci.edu>
144
145 * term.c (struct keys): Add support for shifted keys.
146
1472005-04-16 Richard M. Stallman <rms@gnu.org>
148
149 * xdisp.c (with_echo_area_buffer): Delete WHICH < 0 case.
150 (set_message): Call with_echo_area_buffer with WHICH = 0.
151 (set_message_1): Erase the echo area buffer first thing.
152 (echo_area_display): Don't clear echo_message_buffer.
153
1542005-04-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
155
156 * Makefile.in (mac.o): Depend on charset.h and coding.h.
157
158 * mac.c: Include charset.h and coding.h.
159 [TARGET_API_MAC_CARBON] (Qutf_8): Remove extern.
160 [TARGET_API_MAC_CARBON] (cfstring_create_with_string): New
161 function.
162 [TARGET_API_MAC_CARBON] (Fmac_get_preference): Use it.
163
164 * macfns.c [TARGET_API_MAC_CARBON] (Fx_file_dialog): Likewise.
165
166 * image.c [MAC_OSX] (image_load_quartz2d): Likewise.
167
168 * macterm.c (x_autoselect_window_p): Remove variable.
169 (last_window): New variable.
170 (XTreassert_line_highlight, x_change_line_highlight): Remove
171 declarations.
172 (mac_focus_changed, x_detect_focus_change): New functions and
173 declarations.
174 (XTextExtents16, front_emacs_window): Remove function.
175 (mac_focus_frame): New function.
176 (XTmouse_position, do_menu_choice, do_zoom_window, XTread_socket)
177 (mac_check_for_quit_char): Use it instead of front_emacs_window.
178 (x_scroll_bar_report_motion): Obtain window from control owner.
179 (x_make_frame_invisible): Set window manager size hint.
180 (do_mouse_moved): Remove function.
181 (XTread_socket): Move its contents here. Generate select-window
182 event on mouse movement if needed. Use x_detect_focus_change on
183 activate/deactivate events. Don't deiconify frame or invalidate
184 window rectangle when dnd items are dropped. Don't
185 activate/deactivate root control.
186 (frame_highlight, frame_unhighlight): Activate/deactivate root
187 control here.
188 (syms_of_macterm): Delete DEFVAR_BOOL for x_autoselect_window_p.
189
190 * macterm.h (cfstring_create_with_string) [TARGET_API_MAC_CARBON]:
191 New extern.
192
1932005-04-15 Luc Teirlinck <teirllm@auburn.edu>
194
195 * Makefile.in: Define new macro TOOLTIP_SUPPORT.
196 (lisp): Use it.
197 (SOME_MACHINE_LISP): Add tooltip.
198
1992005-04-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
200
201 * mac.c [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't
202 include TextEncodingConverter.h.
203 (mac_system_script_code, Vmac_system_locale): New variables.
204 (syms_of_mac): Defvar them.
205 (mac_get_system_locale): New function.
206
207 * macfns.c (x_set_name, x_set_title) [!TARGET_API_MAC_CARBON]: Use
208 ENCODE_SYSTEM to encode title bar string.
209 (x_create_tip_frame): Apply 2005-03-18 change for xfns.c.
210 (Fx_file_dialog) [TARGET_API_MAC_CARBON && !MAC_OSX]: Use
211 CFStringGetSystemEncoding to get system default string encoding.
212
213 * macterm.c [!TARGET_API_MAC_CARBON]: Don't include
214 TextEncodingConverter.h.
215
2162005-04-13 Steven Tamm <steventamm@mac.com>
217
218 * macterm.c (syms_of_macterm): Remove redundant definition of
219 mac-pass-control-to-system.
220
12005-04-12 Stefan Monnier <monnier@iro.umontreal.ca> 2212005-04-12 Stefan Monnier <monnier@iro.umontreal.ca>
2 222
3 * window.c (Fset_window_configuration): Be careful when you choose 223 * window.c (Fset_window_configuration): Be careful when you choose
@@ -13,13 +233,11 @@
13 233
14 * macterm.c (mac_keyboard_text_encoding) 234 * macterm.c (mac_keyboard_text_encoding)
15 (current_mac_keyboard_text_encoding): Remove variables. 235 (current_mac_keyboard_text_encoding): Remove variables.
16 (XTread_socket): Store language-change event if keyboard script 236 (XTread_socket): Store language-change event if keyboard script change
17 change is detected. Don't convert input to 237 is detected. Don't convert input to `mac_keyboard_text_encoding'.
18 `mac_keyboard_text_encoding'.
19 (syms_of_macterm): Delete DEFVAR_INT for mac-keyboard-text-encoding. 238 (syms_of_macterm): Delete DEFVAR_INT for mac-keyboard-text-encoding.
20 239
21 * termhooks.h (enum event_kind) [MAC_OS]: 240 * termhooks.h (enum event_kind) [MAC_OS]: Add LANGUAGE_CHANGE_EVENT.
22 Add LANGUAGE_CHANGE_EVENT.
23 241
242005-04-10 Richard M. Stallman <rms@gnu.org> 2422005-04-10 Richard M. Stallman <rms@gnu.org>
25 243
@@ -34,7 +252,6 @@
34 into "(any string)". 252 into "(any string)".
35 253
36 * lread.c (Vloads_in_progress): Not static. 254 * lread.c (Vloads_in_progress): Not static.
37
38 * fns.c (Vloads_in_progress): Add extern. 255 * fns.c (Vloads_in_progress): Add extern.
39 (Frequire): Don't do LOADHIST_ATTACH if Vloads_in_progress is nil. 256 (Frequire): Don't do LOADHIST_ATTACH if Vloads_in_progress is nil.
40 257
@@ -908,9 +1125,9 @@
908 1125
9092005-02-02 Steven Tamm <steventamm@mac.com> 11262005-02-02 Steven Tamm <steventamm@mac.com>
910 1127
911 * macfns.c (unwind_create_frame): Fixing compile error due to 1128 * macfns.c (unwind_create_frame): Fix compile error due to
912 xassert being uncondition, but predicate is. 1129 xassert being uncondition, but predicate is.
913 * dispnew.c (update_window): Fixing compile error due to 1130 * dispnew.c (update_window): Fix compile error due to
914 xassert being uncondition, but predicate is. 1131 xassert being uncondition, but predicate is.
915 1132
9162005-02-02 Miles Bader <miles@gnu.org> 11332005-02-02 Miles Bader <miles@gnu.org>
@@ -1054,6 +1271,7 @@
1054 1271
1055 * s/darwin.h: Removed PTY_ITERATION from here. 1272 * s/darwin.h: Removed PTY_ITERATION from here.
1056 (DARWIN): Define. 1273 (DARWIN): Define.
1274
1057 * process.c (init_process): Default process-connection-type to 1275 * process.c (init_process): Default process-connection-type to
1058 nil on darwin 6 or less, t if it is 7 or higher. This way the 1276 nil on darwin 6 or less, t if it is 7 or higher. This way the
1059 broken pty behavior is still allowed on darwin 6 for interactive 1277 broken pty behavior is still allowed on darwin 6 for interactive
@@ -3554,8 +3772,8 @@
35542004-08-26 Steven Tamm <steventamm@mac.com> 37722004-08-26 Steven Tamm <steventamm@mac.com>
3555 3773
3556 * fileio.c (Fread_file_name): Call x_file_dialog on carbon on 3774 * fileio.c (Fread_file_name): Call x_file_dialog on carbon on
3557 tool-bar/menu click 3775 tool-bar/menu click.
3558 * macfns.c (Fx_file_dialog): Implemented using NavServices 3776 * macfns.c (Fx_file_dialog): Implement using NavServices.
3559 3777
35602004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 37782004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
3561 3779
@@ -5042,7 +5260,7 @@
5042 5260
50432004-04-26 Steven Tamm <tamm@Steven-Tamms-Computer.local> 52612004-04-26 Steven Tamm <tamm@Steven-Tamms-Computer.local>
5044 5262
5045 * lread.c (init_lread): Fixing typo HAVE_CARBON test logic 5263 * lread.c (init_lread): Fix typo in HAVE_CARBON test logic.
5046 5264
50472004-04-26 Miles Bader <miles@gnu.org> 52652004-04-26 Miles Bader <miles@gnu.org>
5048 5266
@@ -5497,10 +5715,10 @@
5497 5715
54982004-03-11 Steven Tamm <steventamm@mac.com> 57162004-03-11 Steven Tamm <steventamm@mac.com>
5499 5717
5500 * image.c [MAC_OSX]: Include sys/stat.h 5718 * image.c [MAC_OSX]: Include sys/stat.h.
5501 5719
5502 * macfns.c (syms_of_macfns): Remove definitions of things now 5720 * macfns.c (syms_of_macfns): Remove definitions of things now
5503 defined in image.c 5721 defined in image.c.
5504 5722
55052004-03-11 Kim F. Storm <storm@cua.dk> 57232004-03-11 Kim F. Storm <storm@cua.dk>
5506 5724
@@ -6210,7 +6428,7 @@
6210 * macterm.c (Vmac_emulate_three_button_mouse): New variable for 6428 * macterm.c (Vmac_emulate_three_button_mouse): New variable for
6211 controlling emulation of a three button mouse with option and 6429 controlling emulation of a three button mouse with option and
6212 command keys. 6430 command keys.
6213 (Qreverse, mac_get_enumlated_btn): Handle the emulation 6431 (Qreverse, mac_get_enumlated_btn): Handle the emulation.
6214 (mac_event_to_emacs_modifiers, XTread_socket): Ditto. 6432 (mac_event_to_emacs_modifiers, XTread_socket): Ditto.
6215 6433
62162004-02-15 Kim F. Storm <storm@cua.dk> 64342004-02-15 Kim F. Storm <storm@cua.dk>
@@ -11150,7 +11368,7 @@
11150 11368
111512003-01-20 Steven Tamm <steventamm@mac.com> 113692003-01-20 Steven Tamm <steventamm@mac.com>
11152 11370
11153 * macterm.c (XTread_socket): Checks for valid, visible window 11371 * macterm.c (XTread_socket): Check for valid, visible window
11154 before sending a scroll-wheel event. 11372 before sending a scroll-wheel event.
11155 11373
111562003-01-20 Richard M. Stallman <rms@gnu.org> 113742003-01-20 Richard M. Stallman <rms@gnu.org>
@@ -11509,7 +11727,7 @@
11509 11727
115102002-12-28 Steven Tamm <steventamm@mac.com> 117282002-12-28 Steven Tamm <steventamm@mac.com>
11511 11729
11512 * Makefile.in (macosx-bundle): Fixes to Mac OS X/Carbon port to 11730 * Makefile.in (macosx-bundle): Fix Mac OS X/Carbon port to
11513 allow building in a different directory than source. Uses some 11731 allow building in a different directory than source. Uses some
11514 GNU Make extensions, but there is no other make on Mac OS X. 11732 GNU Make extensions, but there is no other make on Mac OS X.
11515 11733
@@ -11552,7 +11770,7 @@
11552 11770
11553 * macterm.c (XTread_socket): Call KeyTranslate for control and 11771 * macterm.c (XTread_socket): Call KeyTranslate for control and
11554 meta to deal correctly shifted non-alpha characters, like C-S-5 11772 meta to deal correctly shifted non-alpha characters, like C-S-5
11555 being treated like C-%. Does not look for shift key to deal 11773 being treated like C-%. Do not look for shift key to deal
11556 with masking off control-key with mac-reverse-ctrl-meta. 11774 with masking off control-key with mac-reverse-ctrl-meta.
11557 11775
115582002-12-21 Richard M. Stallman <rms@gnu.org> 117762002-12-21 Richard M. Stallman <rms@gnu.org>
diff --git a/src/Makefile.in b/src/Makefile.in
index c1f036e7b96..2afdbb4771e 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -686,6 +686,12 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(allocaobj) $(widgetobj) $(LIBO
686#define WINNT_SUPPORT 686#define WINNT_SUPPORT
687#endif 687#endif
688 688
689#ifdef HAVE_WINDOW_SYSTEM
690#define TOOLTIP_SUPPORT ${lispsource}tooltip.elc
691#else
692#define TOOLTIP_SUPPORT
693#endif
694
689/* List of Lisp files loaded into the dumped Emacs. It's arranged 695/* List of Lisp files loaded into the dumped Emacs. It's arranged
690 like this because it's easier to generate it semi-mechanically from 696 like this because it's easier to generate it semi-mechanically from
691 loadup.el this way. 697 loadup.el this way.
@@ -771,6 +777,7 @@ lisp= \
771 ${lispsource}emacs-lisp/timer.elc \ 777 ${lispsource}emacs-lisp/timer.elc \
772 ${lispsource}vc-hooks.elc \ 778 ${lispsource}vc-hooks.elc \
773 ${lispsource}ediff-hook.elc \ 779 ${lispsource}ediff-hook.elc \
780 TOOLTIP_SUPPORT \
774 VMS_SUPPORT \ 781 VMS_SUPPORT \
775 MSDOS_SUPPORT \ 782 MSDOS_SUPPORT \
776 WINNT_SUPPORT \ 783 WINNT_SUPPORT \
@@ -868,6 +875,7 @@ SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \
868 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \ 875 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \
869 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \ 876 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \
870 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \ 877 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \
878 ${dotdot}/lisp/tooltip.elc \
871 ${dotdot}/lisp/international/ccl.elc \ 879 ${dotdot}/lisp/international/ccl.elc \
872 ${dotdot}/lisp/international/codepage.elc 880 ${dotdot}/lisp/international/codepage.elc
873 881
@@ -1221,7 +1229,8 @@ abbrev.o buffer.o callint.o cmds.o dispnew.o editfns.o fileio.o frame.o \
1221 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \ 1229 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \
1222 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \ 1230 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \
1223 xterm.o xselect.o sound.o: macgui.h 1231 xterm.o xselect.o sound.o: macgui.h
1224mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h $(config_h) 1232mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h charset.h \
1233 coding.h $(config_h)
1225macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \ 1234macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \
1226 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \ 1235 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
1227 atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h) 1236 atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h)
diff --git a/src/config.in b/src/config.in
index 34ba3a061df..6939ff2577c 100644
--- a/src/config.in
+++ b/src/config.in
@@ -451,6 +451,9 @@ Boston, MA 02111-1307, USA. */
451/* Define to 1 if you have the <pty.h> header file. */ 451/* Define to 1 if you have the <pty.h> header file. */
452#undef HAVE_PTY_H 452#undef HAVE_PTY_H
453 453
454/* Define to 1 if you have the <pwd.h> header file. */
455#undef HAVE_PWD_H
456
454/* Define to 1 if you have the `random' function. */ 457/* Define to 1 if you have the `random' function. */
455#undef HAVE_RANDOM 458#undef HAVE_RANDOM
456 459
@@ -779,9 +782,9 @@ Boston, MA 02111-1307, USA. */
779/* If using the C implementation of alloca, define if you know the 782/* If using the C implementation of alloca, define if you know the
780 direction of stack growth for your system; otherwise it will be 783 direction of stack growth for your system; otherwise it will be
781 automatically deduced at run-time. 784 automatically deduced at run-time.
782 STACK_DIRECTION > 0 => grows toward higher addresses 785 STACK_DIRECTION > 0 => grows toward higher addresses
783 STACK_DIRECTION < 0 => grows toward lower addresses 786 STACK_DIRECTION < 0 => grows toward lower addresses
784 STACK_DIRECTION = 0 => direction of growth unknown */ 787 STACK_DIRECTION = 0 => direction of growth unknown */
785#undef STACK_DIRECTION 788#undef STACK_DIRECTION
786 789
787/* Define to 1 if you have the ANSI C header files. */ 790/* Define to 1 if you have the ANSI C header files. */
diff --git a/src/dired.c b/src/dired.c
index 032040222da..ad064f96dec 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -26,10 +26,10 @@ Boston, MA 02111-1307, USA. */
26#include <sys/types.h> 26#include <sys/types.h>
27#include <sys/stat.h> 27#include <sys/stat.h>
28 28
29#ifdef VMS 29#ifdef HAVE_PWD_H
30#include "vms-pwd.h"
31#else
32#include <pwd.h> 30#include <pwd.h>
31#endif
32#ifndef VMS
33#include <grp.h> 33#include <grp.h>
34#endif 34#endif
35 35
diff --git a/src/dispextern.h b/src/dispextern.h
index 36f570bd99c..0ce8c612e9c 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -726,6 +726,11 @@ struct glyph_row
726 position of the next row. */ 726 position of the next row. */
727 struct display_pos end; 727 struct display_pos end;
728 728
729 /* Non-zero means the overlay arrow bitmap is on this line.
730 -1 means use default overlay arrow bitmap, else
731 it specifies actual fringe bitmap number. */
732 int overlay_arrow_bitmap;
733
729 /* Left fringe bitmap number (enum fringe_bitmap_type). */ 734 /* Left fringe bitmap number (enum fringe_bitmap_type). */
730 unsigned left_user_fringe_bitmap : FRINGE_ID_BITS; 735 unsigned left_user_fringe_bitmap : FRINGE_ID_BITS;
731 736
@@ -764,9 +769,6 @@ struct glyph_row
764 unsigned truncated_on_left_p : 1; 769 unsigned truncated_on_left_p : 1;
765 unsigned truncated_on_right_p : 1; 770 unsigned truncated_on_right_p : 1;
766 771
767 /* 1 means the overlay arrow is on this line. */
768 unsigned overlay_arrow_p : 1;
769
770 /* 1 means that this row displays a continued line, i.e. it has a 772 /* 1 means that this row displays a continued line, i.e. it has a
771 continuation mark at the right side. */ 773 continuation mark at the right side. */
772 unsigned continued_p : 1; 774 unsigned continued_p : 1;
diff --git a/src/dispnew.c b/src/dispnew.c
index cdd7f694ceb..70186e279b1 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1519,7 +1519,7 @@ row_equal_p (w, a, b, mouse_face_p)
1519 || a->left_fringe_face_id != b->left_fringe_face_id 1519 || a->left_fringe_face_id != b->left_fringe_face_id
1520 || a->right_fringe_bitmap != b->right_fringe_bitmap 1520 || a->right_fringe_bitmap != b->right_fringe_bitmap
1521 || a->right_fringe_face_id != b->right_fringe_face_id 1521 || a->right_fringe_face_id != b->right_fringe_face_id
1522 || a->overlay_arrow_p != b->overlay_arrow_p 1522 || a->overlay_arrow_bitmap != b->overlay_arrow_bitmap
1523 || a->exact_window_width_line_p != b->exact_window_width_line_p 1523 || a->exact_window_width_line_p != b->exact_window_width_line_p
1524 || a->overlapped_p != b->overlapped_p 1524 || a->overlapped_p != b->overlapped_p
1525 || (MATRIX_ROW_CONTINUATION_LINE_P (a) 1525 || (MATRIX_ROW_CONTINUATION_LINE_P (a)
@@ -4521,7 +4521,7 @@ update_window_line (w, vpos, mouse_face_overwritten_p)
4521 || desired_row->y != current_row->y 4521 || desired_row->y != current_row->y
4522 || desired_row->visible_height != current_row->visible_height 4522 || desired_row->visible_height != current_row->visible_height
4523 || desired_row->cursor_in_fringe_p != current_row->cursor_in_fringe_p 4523 || desired_row->cursor_in_fringe_p != current_row->cursor_in_fringe_p
4524 || desired_row->overlay_arrow_p != current_row->overlay_arrow_p 4524 || desired_row->overlay_arrow_bitmap != current_row->overlay_arrow_bitmap
4525 || current_row->redraw_fringe_bitmaps_p 4525 || current_row->redraw_fringe_bitmaps_p
4526 || desired_row->mode_line_p != current_row->mode_line_p 4526 || desired_row->mode_line_p != current_row->mode_line_p
4527 || desired_row->exact_window_width_line_p != current_row->exact_window_width_line_p 4527 || desired_row->exact_window_width_line_p != current_row->exact_window_width_line_p
@@ -5031,7 +5031,7 @@ scrolling_window (w, header_line_p)
5031 || to->right_fringe_bitmap != from->right_fringe_bitmap 5031 || to->right_fringe_bitmap != from->right_fringe_bitmap
5032 || to->left_fringe_face_id != from->left_fringe_face_id 5032 || to->left_fringe_face_id != from->left_fringe_face_id
5033 || to->right_fringe_face_id != from->right_fringe_face_id 5033 || to->right_fringe_face_id != from->right_fringe_face_id
5034 || to->overlay_arrow_p != from->overlay_arrow_p)) 5034 || to->overlay_arrow_bitmap != from->overlay_arrow_bitmap))
5035 from->redraw_fringe_bitmaps_p = 1; 5035 from->redraw_fringe_bitmaps_p = 1;
5036 assign_row (to, from); 5036 assign_row (to, from);
5037 to->enabled_p = 1, from->enabled_p = 0; 5037 to->enabled_p = 1, from->enabled_p = 0;
diff --git a/src/editfns.c b/src/editfns.c
index 1cbd28dd109..df43937d13a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -24,9 +24,7 @@ Boston, MA 02111-1307, USA. */
24#include <sys/types.h> 24#include <sys/types.h>
25#include <stdio.h> 25#include <stdio.h>
26 26
27#ifdef VMS 27#ifdef HAVE_PWD_H
28#include "vms-pwd.h"
29#else
30#include <pwd.h> 28#include <pwd.h>
31#endif 29#endif
32 30
diff --git a/src/fileio.c b/src/fileio.c
index 9b3360a7fa8..2a2703ba7a1 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -45,9 +45,7 @@ Boston, MA 02111-1307, USA. */
45# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 45# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
46#endif 46#endif
47 47
48#ifdef VMS 48#ifdef HAVE_PWD_H
49#include "vms-pwd.h"
50#else
51#include <pwd.h> 49#include <pwd.h>
52#endif 50#endif
53 51
diff --git a/src/filelock.c b/src/filelock.c
index fc214b5a34a..9cdaea4ef13 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -26,11 +26,9 @@ Boston, MA 02111-1307, USA. */
26#include <signal.h> 26#include <signal.h>
27#include <stdio.h> 27#include <stdio.h>
28 28
29#ifdef VMS 29#ifdef HAVE_PWD_H
30#include "vms-pwd.h"
31#else
32#include <pwd.h> 30#include <pwd.h>
33#endif /* not VMS */ 31#endif
34 32
35#include <sys/file.h> 33#include <sys/file.h>
36#ifdef HAVE_FCNTL_H 34#ifdef HAVE_FCNTL_H
diff --git a/src/fns.c b/src/fns.c
index d90630b7f30..f1788bd88e1 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -66,7 +66,7 @@ int use_file_dialog;
66extern int minibuffer_auto_raise; 66extern int minibuffer_auto_raise;
67extern Lisp_Object minibuf_window; 67extern Lisp_Object minibuf_window;
68extern Lisp_Object Vlocale_coding_system; 68extern Lisp_Object Vlocale_coding_system;
69extern Lisp_Object Vloads_in_progress; 69extern int load_in_progress;
70 70
71Lisp_Object Qstring_lessp, Qprovide, Qrequire; 71Lisp_Object Qstring_lessp, Qprovide, Qrequire;
72Lisp_Object Qyes_or_no_p_history; 72Lisp_Object Qyes_or_no_p_history;
@@ -1971,6 +1971,18 @@ This is the last value stored with `(put SYMBOL PROPNAME VALUE)'. */)
1971 return Fplist_get (XSYMBOL (symbol)->plist, propname); 1971 return Fplist_get (XSYMBOL (symbol)->plist, propname);
1972} 1972}
1973 1973
1974DEFUN ("safe-get", Fsafe_get, Ssafe_get, 2, 2, 0,
1975 doc: /* Return the value of SYMBOL's PROPNAME property.
1976This is the last value stored with `(put SYMBOL PROPNAME VALUE)'.
1977This function never signals an error. */)
1978 (symbol, propname)
1979 Lisp_Object symbol, propname;
1980{
1981 if (!SYMBOLP (symbol))
1982 return Qnil;
1983 return Fsafe_plist_get (XSYMBOL (symbol)->plist, propname);
1984}
1985
1974DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0, 1986DEFUN ("plist-put", Fplist_put, Splist_put, 3, 3, 0,
1975 doc: /* Change value in PLIST of PROP to VAL. 1987 doc: /* Change value in PLIST of PROP to VAL.
1976PLIST is a property list, which is a list of the form 1988PLIST is a property list, which is a list of the form
@@ -2916,7 +2928,7 @@ The normal messages at start and end of loading FILENAME are suppressed. */)
2916 even if the feature specified is already loaded. 2928 even if the feature specified is already loaded.
2917 But not more than once in any file, 2929 But not more than once in any file,
2918 and not when we aren't loading a file. */ 2930 and not when we aren't loading a file. */
2919 if (! NILP (Vloads_in_progress)) 2931 if (load_in_progress)
2920 { 2932 {
2921 tem = Fcons (Qrequire, feature); 2933 tem = Fcons (Qrequire, feature);
2922 if (NILP (Fmember (tem, Vcurrent_load_list))) 2934 if (NILP (Fmember (tem, Vcurrent_load_list)))
@@ -5253,6 +5265,7 @@ used if both `use-dialog-box' and this variable are non-nil. */);
5253 defsubr (&Splist_get); 5265 defsubr (&Splist_get);
5254 defsubr (&Ssafe_plist_get); 5266 defsubr (&Ssafe_plist_get);
5255 defsubr (&Sget); 5267 defsubr (&Sget);
5268 defsubr (&Ssafe_get);
5256 defsubr (&Splist_put); 5269 defsubr (&Splist_put);
5257 defsubr (&Sput); 5270 defsubr (&Sput);
5258 defsubr (&Slax_plist_get); 5271 defsubr (&Slax_plist_get);
diff --git a/src/fringe.c b/src/fringe.c
index ed732326809..3a9d8d306ea 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -699,11 +699,11 @@ draw_fringe_bitmap (w, row, left_p)
699 699
700 draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP); 700 draw_fringe_bitmap_1 (w, row, left_p, overlay, NO_FRINGE_BITMAP);
701 701
702 if (left_p && row->overlay_arrow_p) 702 if (left_p && row->overlay_arrow_bitmap != NO_FRINGE_BITMAP)
703 draw_fringe_bitmap_1 (w, row, 1, 1, 703 draw_fringe_bitmap_1 (w, row, 1, 1,
704 (w->overlay_arrow_bitmap 704 (row->overlay_arrow_bitmap < 0
705 ? w->overlay_arrow_bitmap 705 ? OVERLAY_ARROW_BITMAP
706 : OVERLAY_ARROW_BITMAP)); 706 : row->overlay_arrow_bitmap));
707} 707}
708 708
709 709
@@ -959,10 +959,10 @@ update_window_fringes (w, force_p)
959 cur->right_fringe_face_id = right_face_id; 959 cur->right_fringe_face_id = right_face_id;
960 } 960 }
961 961
962 if (row->overlay_arrow_p != cur->overlay_arrow_p) 962 if (row->overlay_arrow_bitmap != cur->overlay_arrow_bitmap)
963 { 963 {
964 redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1; 964 redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
965 cur->overlay_arrow_p = row->overlay_arrow_p; 965 cur->overlay_arrow_bitmap = row->overlay_arrow_bitmap;
966 } 966 }
967 967
968 row->left_fringe_bitmap = left; 968 row->left_fringe_bitmap = left;
@@ -1408,7 +1408,9 @@ Return nil if POS is not visible in WINDOW. */)
1408 if (row) 1408 if (row)
1409 return list3 (get_fringe_bitmap_name (row->left_fringe_bitmap), 1409 return list3 (get_fringe_bitmap_name (row->left_fringe_bitmap),
1410 get_fringe_bitmap_name (row->right_fringe_bitmap), 1410 get_fringe_bitmap_name (row->right_fringe_bitmap),
1411 (row->overlay_arrow_p ? Qt : Qnil)); 1411 (row->overlay_arrow_bitmap == 0 ? Qnil
1412 : row->overlay_arrow_bitmap < 0 ? Qt
1413 : get_fringe_bitmap_name (row->overlay_arrow_bitmap)));
1412 else 1414 else
1413 return Qnil; 1415 return Qnil;
1414} 1416}
diff --git a/src/image.c b/src/image.c
index 0e48b1d2bcb..6a1fc7aa795 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2423,7 +2423,7 @@ image_load_quartz2d (f, img, png_p)
2423 UNGCPRO; 2423 UNGCPRO;
2424 return 0; 2424 return 0;
2425 } 2425 }
2426 path = cfstring_create_with_utf8_cstring (SDATA (file)); 2426 path = cfstring_create_with_string (file);
2427 url = CFURLCreateWithFileSystemPath (NULL, path, 2427 url = CFURLCreateWithFileSystemPath (NULL, path,
2428 kCFURLPOSIXPathStyle, 0); 2428 kCFURLPOSIXPathStyle, 0);
2429 CFRelease (path); 2429 CFRelease (path);
diff --git a/src/lisp.h b/src/lisp.h
index ca8795fb1e1..d5b0bad8bf9 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2346,6 +2346,7 @@ EXFUN (Fsort, 2);
2346EXFUN (Freverse, 1); 2346EXFUN (Freverse, 1);
2347EXFUN (Fnreverse, 1); 2347EXFUN (Fnreverse, 1);
2348EXFUN (Fget, 2); 2348EXFUN (Fget, 2);
2349EXFUN (Fsafe_get, 2);
2349EXFUN (Fput, 3); 2350EXFUN (Fput, 3);
2350EXFUN (Fequal, 2); 2351EXFUN (Fequal, 2);
2351EXFUN (Ffillarray, 2); 2352EXFUN (Ffillarray, 2);
diff --git a/src/lread.c b/src/lread.c
index 7fe626fa07c..6ada3ba4a95 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1,6 +1,6 @@
1/* Lisp parsing and input streams. 1/* Lisp parsing and input streams.
2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, 1998, 2 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1993, 1994, 1995, 1997, 1998,
3 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. 3 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -97,7 +97,7 @@ static Lisp_Object Qload_force_doc_strings;
97extern Lisp_Object Qevent_symbol_element_mask; 97extern Lisp_Object Qevent_symbol_element_mask;
98extern Lisp_Object Qfile_exists_p; 98extern Lisp_Object Qfile_exists_p;
99 99
100/* non-zero if inside `load' */ 100/* non-zero iff inside `load' */
101int load_in_progress; 101int load_in_progress;
102 102
103/* Directory in which the sources were found. */ 103/* Directory in which the sources were found. */
@@ -203,7 +203,7 @@ static int new_backquote_flag;
203/* A list of file names for files being loaded in Fload. Used to 203/* A list of file names for files being loaded in Fload. Used to
204 check for recursive loads. */ 204 check for recursive loads. */
205 205
206Lisp_Object Vloads_in_progress; 206static Lisp_Object Vloads_in_progress;
207 207
208/* Non-zero means load dangerous compiled Lisp files. */ 208/* Non-zero means load dangerous compiled Lisp files. */
209 209
diff --git a/src/mac.c b/src/mac.c
index da6a61633dc..68e3bdfa065 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -31,6 +31,8 @@ Boston, MA 02111-1307, USA. */
31#include "sysselect.h" 31#include "sysselect.h"
32#include "systime.h" 32#include "systime.h"
33#include "blockinput.h" 33#include "blockinput.h"
34#include "charset.h"
35#include "coding.h"
34 36
35#include "macterm.h" 37#include "macterm.h"
36 38
@@ -49,6 +51,7 @@ Boston, MA 02111-1307, USA. */
49#include <Events.h> 51#include <Events.h>
50#include <Processes.h> 52#include <Processes.h>
51#include <EPPC.h> 53#include <EPPC.h>
54#include <MacLocales.h>
52#endif /* not HAVE_CARBON */ 55#endif /* not HAVE_CARBON */
53 56
54#include <utime.h> 57#include <utime.h>
@@ -67,6 +70,12 @@ Boston, MA 02111-1307, USA. */
67 70
68Lisp_Object QCLIPBOARD; 71Lisp_Object QCLIPBOARD;
69 72
73/* The system script code. */
74static int mac_system_script_code;
75
76/* The system locale identifier string. */
77static Lisp_Object Vmac_system_locale;
78
70/* An instance of the AppleScript component. */ 79/* An instance of the AppleScript component. */
71static ComponentInstance as_scripting_component; 80static ComponentInstance as_scripting_component;
72/* The single script context used for all script executions. */ 81/* The single script context used for all script executions. */
@@ -258,7 +267,6 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
258#if TARGET_API_MAC_CARBON 267#if TARGET_API_MAC_CARBON
259static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; 268static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
260static Lisp_Object Qarray, Qdictionary; 269static Lisp_Object Qarray, Qdictionary;
261extern Lisp_Object Qutf_8;
262#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) 270#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0)
263 271
264struct cfdict_context 272struct cfdict_context
@@ -267,7 +275,7 @@ struct cfdict_context
267 int with_tag, hash_bound; 275 int with_tag, hash_bound;
268}; 276};
269 277
270/* C string to CFString. */ 278/* C string to CFString. */
271 279
272CFStringRef 280CFStringRef
273cfstring_create_with_utf8_cstring (c_str) 281cfstring_create_with_utf8_cstring (c_str)
@@ -284,6 +292,37 @@ cfstring_create_with_utf8_cstring (c_str)
284} 292}
285 293
286 294
295/* Lisp string to CFString. */
296
297CFStringRef
298cfstring_create_with_string (s)
299 Lisp_Object s;
300{
301 CFStringRef string = NULL;
302
303 if (STRING_MULTIBYTE (s))
304 {
305 char *p, *end = SDATA (s) + SBYTES (s);
306
307 for (p = SDATA (s); p < end; p++)
308 if (!isascii (*p))
309 {
310 s = ENCODE_UTF_8 (s);
311 break;
312 }
313 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
314 kCFStringEncodingUTF8, false);
315 }
316
317 if (string == NULL)
318 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
319 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
320 kCFStringEncodingMacRoman, false);
321
322 return string;
323}
324
325
287/* From CFData to a lisp string. Always returns a unibyte string. */ 326/* From CFData to a lisp string. Always returns a unibyte string. */
288 327
289Lisp_Object 328Lisp_Object
@@ -3704,11 +3743,11 @@ otherwise. */)
3704 app_id = kCFPreferencesCurrentApplication; 3743 app_id = kCFPreferencesCurrentApplication;
3705 if (!NILP (application)) 3744 if (!NILP (application))
3706 { 3745 {
3707 app_id = cfstring_create_with_utf8_cstring (SDATA (application)); 3746 app_id = cfstring_create_with_string (application);
3708 if (app_id == NULL) 3747 if (app_id == NULL)
3709 goto out; 3748 goto out;
3710 } 3749 }
3711 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3750 key_str = cfstring_create_with_string (XCAR (key));
3712 if (key_str == NULL) 3751 if (key_str == NULL)
3713 goto out; 3752 goto out;
3714 app_plist = CFPreferencesCopyAppValue (key_str, app_id); 3753 app_plist = CFPreferencesCopyAppValue (key_str, app_id);
@@ -3721,7 +3760,7 @@ otherwise. */)
3721 { 3760 {
3722 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) 3761 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
3723 break; 3762 break;
3724 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3763 key_str = cfstring_create_with_string (XCAR (key));
3725 if (key_str == NULL) 3764 if (key_str == NULL)
3726 goto out; 3765 goto out;
3727 plist = CFDictionaryGetValue (plist, key_str); 3766 plist = CFDictionaryGetValue (plist, key_str);
@@ -4167,6 +4206,29 @@ init_mac_osx_environment ()
4167} 4206}
4168#endif /* MAC_OSX */ 4207#endif /* MAC_OSX */
4169 4208
4209
4210static Lisp_Object
4211mac_get_system_locale ()
4212{
4213 OSErr err;
4214 LangCode lang;
4215 RegionCode region;
4216 LocaleRef locale;
4217 Str255 str;
4218
4219 lang = GetScriptVariable (smSystemScript, smScriptLang);
4220 region = GetScriptManagerVariable (smRegionCode);
4221 err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
4222 if (err == noErr)
4223 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
4224 sizeof (str), str);
4225 if (err == noErr)
4226 return build_string (str);
4227 else
4228 return Qnil;
4229}
4230
4231
4170void 4232void
4171syms_of_mac () 4233syms_of_mac ()
4172{ 4234{
@@ -4197,6 +4259,16 @@ syms_of_mac ()
4197 defsubr (&Sdo_applescript); 4259 defsubr (&Sdo_applescript);
4198 defsubr (&Smac_file_name_to_posix); 4260 defsubr (&Smac_file_name_to_posix);
4199 defsubr (&Sposix_file_name_to_mac); 4261 defsubr (&Sposix_file_name_to_mac);
4262
4263 DEFVAR_INT ("mac-system-script-code", &mac_system_script_code,
4264 doc: /* The system script code. */);
4265 mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript);
4266
4267 DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale,
4268 doc: /* The system locale identifier string.
4269This is not a POSIX locale ID, but an ICU locale ID. So encoding
4270information is not included. */);
4271 Vmac_system_locale = mac_get_system_locale ();
4200} 4272}
4201 4273
4202/* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff 4274/* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff
diff --git a/src/macfns.c b/src/macfns.c
index 78365ce3c0c..0243e35e94b 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1895,7 +1895,7 @@ x_set_name (f, name, explicit)
1895#if TARGET_API_MAC_CARBON 1895#if TARGET_API_MAC_CARBON
1896 name = ENCODE_UTF_8 (name); 1896 name = ENCODE_UTF_8 (name);
1897#else 1897#else
1898 return; 1898 name = ENCODE_SYSTEM (name);
1899#endif 1899#endif
1900 1900
1901 BLOCK_INPUT; 1901 BLOCK_INPUT;
@@ -1977,7 +1977,7 @@ x_set_title (f, name, old_name)
1977#if TARGET_API_MAC_CARBON 1977#if TARGET_API_MAC_CARBON
1978 name = ENCODE_UTF_8 (name); 1978 name = ENCODE_UTF_8 (name);
1979#else 1979#else
1980 return; 1980 name = ENCODE_SYSTEM (name);
1981#endif 1981#endif
1982 1982
1983 BLOCK_INPUT; 1983 BLOCK_INPUT;
@@ -3637,9 +3637,6 @@ x_create_tip_frame (dpyinfo, parms, text)
3637 3637
3638 check_mac (); 3638 check_mac ();
3639 3639
3640 /* Use this general default value to start with until we know if
3641 this frame has a specified name. */
3642 Vx_resource_name = Vinvocation_name;
3643 3640
3644#ifdef MULTI_KBOARD 3641#ifdef MULTI_KBOARD
3645 kb = dpyinfo->kboard; 3642 kb = dpyinfo->kboard;
@@ -3653,7 +3650,6 @@ x_create_tip_frame (dpyinfo, parms, text)
3653 && !EQ (name, Qunbound) 3650 && !EQ (name, Qunbound)
3654 && !NILP (name)) 3651 && !NILP (name))
3655 error ("Invalid frame name--not a string or nil"); 3652 error ("Invalid frame name--not a string or nil");
3656 Vx_resource_name = name;
3657 3653
3658 frame = Qnil; 3654 frame = Qnil;
3659 GCPRO3 (parms, name, frame); 3655 GCPRO3 (parms, name, frame);
@@ -4252,8 +4248,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4252 options.optionFlags |= kNavSelectAllReadableItem; 4248 options.optionFlags |= kNavSelectAllReadableItem;
4253 if (!NILP(prompt)) 4249 if (!NILP(prompt))
4254 { 4250 {
4255 message = 4251 message = cfstring_create_with_string (prompt);
4256 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt)));
4257 options.message = message; 4252 options.message = message;
4258 } 4253 }
4259 /* Don't set the application, let it use default. 4254 /* Don't set the application, let it use default.
@@ -4362,7 +4357,12 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4362 filename[len++] = '/'; 4357 filename[len++] = '/';
4363 CFStringGetCString(reply.saveFileName, filename+len, 4358 CFStringGetCString(reply.saveFileName, filename+len,
4364 sizeof (filename) - len, 4359 sizeof (filename) - len,
4365 kCFStringEncodingUTF8); 4360#if MAC_OSX
4361 kCFStringEncodingUTF8
4362#else
4363 CFStringGetSystemEncoding ()
4364#endif
4365 );
4366 } 4366 }
4367 file = DECODE_FILE (make_unibyte_string (filename, 4367 file = DECODE_FILE (make_unibyte_string (filename,
4368 strlen (filename))); 4368 strlen (filename)));
diff --git a/src/macgui.h b/src/macgui.h
index 96fd54a603b..5d4f1894e2e 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -101,12 +101,16 @@ typedef struct _XCharStruct
101 (xcs).descent = (bds).bottom) 101 (xcs).descent = (bds).bottom)
102 102
103struct MacFontStruct { 103struct MacFontStruct {
104 char *fontname; 104 char *full_name;
105 105
106 short mac_fontnum; /* font number of font used in this window */ 106 short mac_fontnum; /* font number of font used in this window */
107 int mac_fontsize; /* size of font */ 107 int mac_fontsize; /* size of font */
108 short mac_fontface; /* plain, bold, italics, etc. */ 108 short mac_fontface; /* plain, bold, italics, etc. */
109#if TARGET_API_MAC_CARBON
110 int mac_scriptcode; /* Mac OS script code for font used */
111#else
109 short mac_scriptcode; /* Mac OS script code for font used */ 112 short mac_scriptcode; /* Mac OS script code for font used */
113#endif
110 114
111#if 0 115#if 0
112 SInt16 mFontNum; /* font number of font used in this window */ 116 SInt16 mFontNum; /* font number of font used in this window */
diff --git a/src/macterm.c b/src/macterm.c
index 614158309dd..d98b6d2b784 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -97,6 +97,7 @@ Boston, MA 02111-1307, USA. */
97 : controlKey) 97 : controlKey)
98#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) 98#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
99 99
100#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
100 101
101 102
102/* Non-nil means Emacs uses toolkit scroll bars. */ 103/* Non-nil means Emacs uses toolkit scroll bars. */
@@ -112,9 +113,8 @@ Lisp_Object Vmac_use_core_graphics;
112 113
113static int any_help_event_p; 114static int any_help_event_p;
114 115
115/* Non-zero means autoselect window with the mouse cursor. */ 116/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
116 117static Lisp_Object last_window;
117int x_autoselect_window_p;
118 118
119/* Non-zero means make use of UNDERLINE_POSITION font properties. */ 119/* Non-zero means make use of UNDERLINE_POSITION font properties. */
120 120
@@ -275,14 +275,16 @@ static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
275static int x_compute_min_glyph_bounds P_ ((struct frame *)); 275static int x_compute_min_glyph_bounds P_ ((struct frame *));
276static void x_update_end P_ ((struct frame *)); 276static void x_update_end P_ ((struct frame *));
277static void XTframe_up_to_date P_ ((struct frame *)); 277static void XTframe_up_to_date P_ ((struct frame *));
278static void XTreassert_line_highlight P_ ((int, int));
279static void x_change_line_highlight P_ ((int, int, int, int));
280static void XTset_terminal_modes P_ ((void)); 278static void XTset_terminal_modes P_ ((void));
281static void XTreset_terminal_modes P_ ((void)); 279static void XTreset_terminal_modes P_ ((void));
282static void x_clear_frame P_ ((void)); 280static void x_clear_frame P_ ((void));
283static void frame_highlight P_ ((struct frame *)); 281static void frame_highlight P_ ((struct frame *));
284static void frame_unhighlight P_ ((struct frame *)); 282static void frame_unhighlight P_ ((struct frame *));
285static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); 283static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
284static void mac_focus_changed P_ ((int, struct mac_display_info *,
285 struct frame *, struct input_event *));
286static void x_detect_focus_change P_ ((struct mac_display_info *,
287 EventRecord *, struct input_event *));
286static void XTframe_rehighlight P_ ((struct frame *)); 288static void XTframe_rehighlight P_ ((struct frame *));
287static void x_frame_rehighlight P_ ((struct x_display_info *)); 289static void x_frame_rehighlight P_ ((struct x_display_info *));
288static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 290static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
@@ -1200,15 +1202,6 @@ XSetFont (display, gc, font)
1200} 1202}
1201 1203
1202 1204
1203static void
1204XTextExtents16 (XFontStruct *font, XChar2b *text, int nchars,
1205 int *direction,int *font_ascent,
1206 int *font_descent, XCharStruct *cs)
1207{
1208 /* MAC_TODO: Use GetTextMetrics to do this and inline it below. */
1209}
1210
1211
1212/* x_sync is a no-op on Mac. */ 1205/* x_sync is a no-op on Mac. */
1213void 1206void
1214x_sync (f) 1207x_sync (f)
@@ -3500,6 +3493,14 @@ static void
3500frame_highlight (f) 3493frame_highlight (f)
3501 struct frame *f; 3494 struct frame *f;
3502{ 3495{
3496 OSErr err;
3497 ControlRef root_control;
3498
3499 BLOCK_INPUT;
3500 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3501 if (err == noErr)
3502 ActivateControl (root_control);
3503 UNBLOCK_INPUT;
3503 x_update_cursor (f, 1); 3504 x_update_cursor (f, 1);
3504} 3505}
3505 3506
@@ -3507,6 +3508,14 @@ static void
3507frame_unhighlight (f) 3508frame_unhighlight (f)
3508 struct frame *f; 3509 struct frame *f;
3509{ 3510{
3511 OSErr err;
3512 ControlRef root_control;
3513
3514 BLOCK_INPUT;
3515 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3516 if (err == noErr)
3517 DeactivateControl (root_control);
3518 UNBLOCK_INPUT;
3510 x_update_cursor (f, 1); 3519 x_update_cursor (f, 1);
3511} 3520}
3512 3521
@@ -3549,6 +3558,68 @@ x_new_focus_frame (dpyinfo, frame)
3549 x_frame_rehighlight (dpyinfo); 3558 x_frame_rehighlight (dpyinfo);
3550} 3559}
3551 3560
3561/* Handle FocusIn and FocusOut state changes for FRAME.
3562 If FRAME has focus and there exists more than one frame, puts
3563 a FOCUS_IN_EVENT into *BUFP. */
3564
3565static void
3566mac_focus_changed (type, dpyinfo, frame, bufp)
3567 int type;
3568 struct mac_display_info *dpyinfo;
3569 struct frame *frame;
3570 struct input_event *bufp;
3571{
3572 if (type == activeFlag)
3573 {
3574 if (dpyinfo->x_focus_event_frame != frame)
3575 {
3576 x_new_focus_frame (dpyinfo, frame);
3577 dpyinfo->x_focus_event_frame = frame;
3578
3579 /* Don't stop displaying the initial startup message
3580 for a switch-frame event we don't need. */
3581 if (GC_NILP (Vterminal_frame)
3582 && GC_CONSP (Vframe_list)
3583 && !GC_NILP (XCDR (Vframe_list)))
3584 {
3585 bufp->kind = FOCUS_IN_EVENT;
3586 XSETFRAME (bufp->frame_or_window, frame);
3587 }
3588 }
3589 }
3590 else
3591 {
3592 if (dpyinfo->x_focus_event_frame == frame)
3593 {
3594 dpyinfo->x_focus_event_frame = 0;
3595 x_new_focus_frame (dpyinfo, 0);
3596 }
3597 }
3598}
3599
3600/* The focus may have changed. Figure out if it is a real focus change,
3601 by checking both FocusIn/Out and Enter/LeaveNotify events.
3602
3603 Returns FOCUS_IN_EVENT event in *BUFP. */
3604
3605static void
3606x_detect_focus_change (dpyinfo, event, bufp)
3607 struct mac_display_info *dpyinfo;
3608 EventRecord *event;
3609 struct input_event *bufp;
3610{
3611 struct frame *frame;
3612
3613 frame = mac_window_to_frame ((WindowPtr) event->message);
3614 if (! frame)
3615 return;
3616
3617 /* On Mac, this is only called from focus events, so no switch needed. */
3618 mac_focus_changed ((event->modifiers & activeFlag),
3619 dpyinfo, frame, bufp);
3620}
3621
3622
3552/* Handle an event saying the mouse has moved out of an Emacs frame. */ 3623/* Handle an event saying the mouse has moved out of an Emacs frame. */
3553 3624
3554void 3625void
@@ -3986,25 +4057,19 @@ remember_mouse_glyph (f1, gx, gy)
3986} 4057}
3987 4058
3988 4059
3989static WindowPtr 4060static struct frame *
3990front_emacs_window () 4061mac_focus_frame (dpyinfo)
4062 struct mac_display_info *dpyinfo;
3991{ 4063{
3992#if TARGET_API_MAC_CARBON 4064 if (dpyinfo->x_focus_frame)
3993 WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true); 4065 return dpyinfo->x_focus_frame;
3994 4066 else
3995 while (wp && !is_emacs_window (wp)) 4067 /* Mac version may get events, such as a menu bar click, even when
3996 wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true); 4068 all the frames are invisible. In this case, we regard the
3997#else 4069 event came to the selected frame. */
3998 WindowPtr wp = FrontWindow (); 4070 return SELECTED_FRAME ();
3999
4000 while (wp && (wp == tip_window || !is_emacs_window (wp)))
4001 wp = GetNextWindow (wp);
4002#endif
4003
4004 return wp;
4005} 4071}
4006 4072
4007#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
4008 4073
4009/* Return the current position of the mouse. 4074/* Return the current position of the mouse.
4010 *fp should be a frame which indicates which display to ask about. 4075 *fp should be a frame which indicates which display to ask about.
@@ -4037,13 +4102,10 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4037{ 4102{
4038 Point mouse_pos; 4103 Point mouse_pos;
4039 int ignore1, ignore2; 4104 int ignore1, ignore2;
4040 WindowPtr wp = front_emacs_window (); 4105 struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
4041 struct frame *f; 4106 WindowPtr wp = FRAME_MAC_WINDOW (f);
4042 Lisp_Object frame, tail; 4107 Lisp_Object frame, tail;
4043 4108
4044 if (is_emacs_window(wp))
4045 f = mac_window_to_frame (wp);
4046
4047 BLOCK_INPUT; 4109 BLOCK_INPUT;
4048 4110
4049 if (! NILP (last_mouse_scroll_bar) && insist == 0) 4111 if (! NILP (last_mouse_scroll_bar) && insist == 0)
@@ -4610,7 +4672,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4610 unsigned long *time; 4672 unsigned long *time;
4611{ 4673{
4612 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4674 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4613 WindowPtr wp = front_emacs_window (); 4675 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4676#if TARGET_API_MAC_CARBON
4677 WindowPtr wp = GetControlOwner (ch);
4678#else
4679 WindowPtr wp = (*ch)->contrlOwner;
4680#endif
4614 Point mouse_pos; 4681 Point mouse_pos;
4615 struct frame *f = mac_window_to_frame (wp); 4682 struct frame *f = mac_window_to_frame (wp);
4616 int win_y, top_range; 4683 int win_y, top_range;
@@ -5067,7 +5134,7 @@ x_new_fontset (f, fontsetname)
5067 fontset = new_fontset_from_font_name (result); 5134 fontset = new_fontset_from_font_name (result);
5068 5135
5069 /* Since x_new_font doesn't update any fontset information, do it now. */ 5136 /* Since x_new_font doesn't update any fontset information, do it now. */
5070 FRAME_FONTSET(f) = fontset; 5137 FRAME_FONTSET (f) = fontset;
5071 5138
5072 return fontset_name (fontset); 5139 return fontset_name (fontset);
5073} 5140}
@@ -5515,6 +5582,13 @@ x_make_frame_invisible (f)
5515 5582
5516 BLOCK_INPUT; 5583 BLOCK_INPUT;
5517 5584
5585 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
5586 that the current position of the window is user-specified, rather than
5587 program-specified, so that when the window is mapped again, it will be
5588 placed at the same location, without forcing the user to position it
5589 by hand again (they have already done that once for this window.) */
5590 x_wm_set_size_hint (f, (long) 0, 1);
5591
5518 HideWindow (FRAME_MAC_WINDOW (f)); 5592 HideWindow (FRAME_MAC_WINDOW (f));
5519 5593
5520 /* We can't distinguish this from iconification 5594 /* We can't distinguish this from iconification
@@ -5784,121 +5858,59 @@ char **font_name_table = NULL;
5784int font_name_table_size = 0; 5858int font_name_table_size = 0;
5785int font_name_count = 0; 5859int font_name_count = 0;
5786 5860
5787#if 0 5861/* Alist linking character set strings to Mac text encoding and Emacs
5788/* compare two strings ignoring case */ 5862 coding system. */
5789static int 5863static Lisp_Object Vmac_charset_info_alist;
5790stricmp (const char *s, const char *t)
5791{
5792 for ( ; tolower (*s) == tolower (*t); s++, t++)
5793 if (*s == '\0')
5794 return 0;
5795 return tolower (*s) - tolower (*t);
5796}
5797 5864
5798/* compare two strings ignoring case and handling wildcard */ 5865static Lisp_Object
5799static int 5866create_text_encoding_info_alist ()
5800wildstrieq (char *s1, char *s2)
5801{
5802 if (strcmp (s1, "*") == 0 || strcmp (s2, "*") == 0)
5803 return true;
5804
5805 return stricmp (s1, s2) == 0;
5806}
5807
5808/* Assume parameter 1 is fully qualified, no wildcards. */
5809static int
5810mac_font_pattern_match (fontname, pattern)
5811 char * fontname;
5812 char * pattern;
5813{ 5867{
5814 char *regex = (char *) alloca (strlen (pattern) * 2 + 3); 5868 Lisp_Object result = Qnil, rest;
5815 char *font_name_copy = (char *) alloca (strlen (fontname) + 1);
5816 char *ptr;
5817 5869
5818 /* Copy fontname so we can modify it during comparison. */ 5870 for (rest = Vmac_charset_info_alist; CONSP (rest); rest = XCDR (rest))
5819 strcpy (font_name_copy, fontname); 5871 {
5872 Lisp_Object charset_info = XCAR (rest);
5873 Lisp_Object charset, coding_system, text_encoding;
5874 Lisp_Object existing_info;
5820 5875
5821 ptr = regex; 5876 if (!(CONSP (charset_info)
5822 *ptr++ = '^'; 5877 && STRINGP (charset = XCAR (charset_info))
5878 && CONSP (XCDR (charset_info))
5879 && INTEGERP (text_encoding = XCAR (XCDR (charset_info)))
5880 && CONSP (XCDR (XCDR (charset_info)))
5881 && SYMBOLP (coding_system = XCAR (XCDR (XCDR (charset_info))))))
5882 continue;
5823 5883
5824 /* Turn pattern into a regexp and do a regexp match. */ 5884 existing_info = assq_no_quit (text_encoding, result);
5825 for (; *pattern; pattern++) 5885 if (NILP (existing_info))
5826 { 5886 result = Fcons (list3 (text_encoding, coding_system, charset),
5827 if (*pattern == '?') 5887 result);
5828 *ptr++ = '.';
5829 else if (*pattern == '*')
5830 {
5831 *ptr++ = '.';
5832 *ptr++ = '*';
5833 }
5834 else 5888 else
5835 *ptr++ = *pattern; 5889 if (NILP (Fmember (charset, XCDR (XCDR (existing_info)))))
5890 XSETCDR (XCDR (existing_info),
5891 Fcons (charset, XCDR (XCDR (existing_info))));
5836 } 5892 }
5837 *ptr = '$';
5838 *(ptr + 1) = '\0';
5839
5840 return (fast_c_string_match_ignore_case (build_string (regex),
5841 font_name_copy) >= 0);
5842}
5843
5844/* Two font specs are considered to match if their foundry, family,
5845 weight, slant, and charset match. */
5846static int
5847mac_font_match (char *mf, char *xf)
5848{
5849 char m_foundry[50], m_family[50], m_weight[20], m_slant[2], m_charset[20];
5850 char x_foundry[50], x_family[50], x_weight[20], x_slant[2], x_charset[20];
5851
5852 if (sscanf (mf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s",
5853 m_foundry, m_family, m_weight, m_slant, m_charset) != 5)
5854 return mac_font_pattern_match (mf, xf);
5855 5893
5856 if (sscanf (xf, "-%49[^-]-%49[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%19s", 5894 return result;
5857 x_foundry, x_family, x_weight, x_slant, x_charset) != 5)
5858 return mac_font_pattern_match (mf, xf);
5859
5860 return (wildstrieq (m_foundry, x_foundry)
5861 && wildstrieq (m_family, x_family)
5862 && wildstrieq (m_weight, x_weight)
5863 && wildstrieq (m_slant, x_slant)
5864 && wildstrieq (m_charset, x_charset))
5865 || mac_font_pattern_match (mf, xf);
5866} 5895}
5867#endif
5868 5896
5869static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
5870 5897
5871static void 5898static void
5872decode_mac_font_name (name, size, scriptcode) 5899decode_mac_font_name (name, size, coding_system)
5873 char *name; 5900 char *name;
5874 int size; 5901 int size;
5875#if TARGET_API_MAC_CARBON 5902 Lisp_Object coding_system;
5876 int scriptcode;
5877#else
5878 short scriptcode;
5879#endif
5880{ 5903{
5881 Lisp_Object coding_system;
5882 struct coding_system coding; 5904 struct coding_system coding;
5883 char *buf; 5905 char *buf, *p;
5884 5906
5885 switch (scriptcode) 5907 for (p = name; *p; p++)
5886 { 5908 if (!isascii (*p) || iscntrl (*p))
5887 case smTradChinese:
5888 coding_system = Qbig5;
5889 break; 5909 break;
5890 case smSimpChinese: 5910
5891 coding_system = Qcn_gb; 5911 if (*p == '\0'
5892 break; 5912 || NILP (coding_system) || NILP (Fcoding_system_p (coding_system)))
5893 case smJapanese: 5913 return;
5894 coding_system = Qsjis;
5895 break;
5896 case smKorean:
5897 coding_system = Qeuc_kr;
5898 break;
5899 default:
5900 return;
5901 }
5902 5914
5903 #if 0 5915 #if 0
5904 /* MAC_TODO: Fix encoding system... */ 5916 /* MAC_TODO: Fix encoding system... */
@@ -5918,68 +5930,26 @@ decode_mac_font_name (name, size, scriptcode)
5918 5930
5919 5931
5920static char * 5932static char *
5921mac_to_x_fontname (name, size, style, scriptcode) 5933mac_to_x_fontname (name, size, style, charset)
5922 char *name; 5934 char *name;
5923 int size; 5935 int size;
5924 Style style; 5936 Style style;
5925#if TARGET_API_MAC_CARBON 5937 char *charset;
5926 int scriptcode;
5927#else
5928 short scriptcode;
5929#endif
5930{ 5938{
5931 char foundry[32], family[32], cs[32]; 5939 char foundry[32], family[32], cs[32];
5932 char xf[256], *result, *p; 5940 char xf[256], *result, *p;
5933 5941
5934 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) != 3) 5942 if (sscanf (name, "%31[^-]-%31[^-]-%31s", foundry, family, cs) == 3)
5943 charset = cs;
5944 else
5935 { 5945 {
5936 strcpy(foundry, "Apple"); 5946 strcpy(foundry, "Apple");
5937 strcpy(family, name); 5947 strcpy(family, name);
5938
5939 switch (scriptcode)
5940 {
5941 case smTradChinese: /* == kTextEncodingMacChineseTrad */
5942 strcpy(cs, "big5-0");
5943 break;
5944 case smSimpChinese: /* == kTextEncodingMacChineseSimp */
5945 strcpy(cs, "gb2312.1980-0");
5946 break;
5947 case smJapanese: /* == kTextEncodingMacJapanese */
5948 strcpy(cs, "jisx0208.1983-sjis");
5949 break;
5950 case -smJapanese:
5951 /* Each Apple Japanese font is entered into the font table
5952 twice: once as a jisx0208.1983-sjis font and once as a
5953 jisx0201.1976-0 font. The latter can be used to display
5954 the ascii charset and katakana-jisx0201 charset. A
5955 negative script code signals that the name of this latter
5956 font is being built. */
5957 strcpy(cs, "jisx0201.1976-0");
5958 break;
5959 case smKorean: /* == kTextEncodingMacKorean */
5960 strcpy(cs, "ksc5601.1989-0");
5961 break;
5962#if TARGET_API_MAC_CARBON
5963 case kTextEncodingMacCyrillic:
5964 strcpy(cs, "mac-cyrillic");
5965 break;
5966 case kTextEncodingMacCentralEurRoman:
5967 strcpy(cs, "mac-centraleurroman");
5968 break;
5969 case kTextEncodingMacSymbol:
5970 case kTextEncodingMacDingbats:
5971 strcpy(cs, "adobe-fontspecific");
5972 break;
5973#endif
5974 default:
5975 strcpy(cs, "mac-roman");
5976 break;
5977 }
5978 } 5948 }
5979 5949
5980 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s", 5950 sprintf(xf, "-%s-%s-%s-%c-normal--%d-%d-75-75-m-%d-%s",
5981 foundry, family, style & bold ? "bold" : "medium", 5951 foundry, family, style & bold ? "bold" : "medium",
5982 style & italic ? 'i' : 'r', size, size * 10, size * 10, cs); 5952 style & italic ? 'i' : 'r', size, size * 10, size * 10, charset);
5983 5953
5984 result = (char *) xmalloc (strlen (xf) + 1); 5954 result = (char *) xmalloc (strlen (xf) + 1);
5985 strcpy (result, xf); 5955 strcpy (result, xf);
@@ -5997,10 +5967,13 @@ mac_to_x_fontname (name, size, style, scriptcode)
5997 "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font 5967 "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font
5998 names are handled accordingly. */ 5968 names are handled accordingly. */
5999static void 5969static void
6000x_font_name_to_mac_font_name (char *xf, char *mf) 5970x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs)
5971 char *xf, *mf, *mf_decoded;
5972 Style *style;
5973 char *cs;
6001{ 5974{
6002 char foundry[32], family[32], weight[20], slant[2], cs[32]; 5975 char foundry[32], family[32], weight[20], slant[2], *p;
6003 Lisp_Object coding_system = Qnil; 5976 Lisp_Object charset_info, coding_system = Qnil;
6004 struct coding_system coding; 5977 struct coding_system coding;
6005 5978
6006 strcpy (mf, ""); 5979 strcpy (mf, "");
@@ -6011,22 +5984,20 @@ x_font_name_to_mac_font_name (char *xf, char *mf)
6011 foundry, family, weight, slant, cs) != 5) 5984 foundry, family, weight, slant, cs) != 5)
6012 return; 5985 return;
6013 5986
6014 if (strcmp (cs, "big5-0") == 0) 5987 *style = normal;
6015 coding_system = Qbig5; 5988 if (strcmp (weight, "bold") == 0)
6016 else if (strcmp (cs, "gb2312.1980-0") == 0) 5989 *style |= bold;
6017 coding_system = Qcn_gb; 5990 if (*slant == 'i')
6018 else if (strcmp (cs, "jisx0208.1983-sjis") == 0 5991 *style |= italic;
6019 || strcmp (cs, "jisx0201.1976-0") == 0) 5992
6020 coding_system = Qsjis; 5993 charset_info = Fassoc (build_string (cs), Vmac_charset_info_alist);
6021 else if (strcmp (cs, "ksc5601.1989-0") == 0) 5994 if (!NILP (charset_info))
6022 coding_system = Qeuc_kr; 5995 {
6023 else if (strcmp (cs, "mac-roman") == 0 5996 strcpy (mf_decoded, family);
6024 || strcmp (cs, "mac-cyrillic") == 0 5997 coding_system = Fcar (Fcdr (Fcdr (charset_info)));
6025 || strcmp (cs, "mac-centraleurroman") == 0 5998 }
6026 || strcmp (cs, "adobe-fontspecific") == 0)
6027 strcpy (mf, family);
6028 else 5999 else
6029 sprintf (mf, "%s-%s-%s", foundry, family, cs); 6000 sprintf (mf_decoded, "%s-%s-%s", foundry, family, cs);
6030 6001
6031#if 0 6002#if 0
6032 /* MAC_TODO: Fix coding system to use objects */ 6003 /* MAC_TODO: Fix coding system to use objects */
@@ -6072,181 +6043,180 @@ static void
6072init_font_name_table () 6043init_font_name_table ()
6073{ 6044{
6074#if TARGET_API_MAC_CARBON 6045#if TARGET_API_MAC_CARBON
6075 SInt32 sv; 6046 FMFontFamilyIterator ffi;
6047 FMFontFamilyInstanceIterator ffii;
6048 FMFontFamily ff;
6049 Lisp_Object text_encoding_info_alist;
6050 struct gcpro gcpro1;
6051
6052 /* Create a dummy instance iterator here to avoid creating and
6053 destroying it in the loop. */
6054 if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr)
6055 return;
6056 /* Create an iterator to enumerate the font families. */
6057 if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
6058 != noErr)
6059 {
6060 FMDisposeFontFamilyInstanceIterator (&ffii);
6061 return;
6062 }
6076 6063
6077 if (Gestalt (gestaltSystemVersion, &sv) == noErr && sv >= 0x1000) 6064 text_encoding_info_alist = create_text_encoding_info_alist ();
6065
6066 GCPRO1 (text_encoding_info_alist);
6067
6068 while (FMGetNextFontFamily (&ffi, &ff) == noErr)
6078 { 6069 {
6079 FMFontFamilyIterator ffi; 6070 Str255 name;
6080 FMFontFamilyInstanceIterator ffii; 6071 FMFont font;
6081 FMFontFamily ff; 6072 FMFontStyle style;
6073 FMFontSize size;
6074 TextEncoding encoding;
6075 TextEncodingBase sc;
6076 Lisp_Object text_encoding_info;
6082 6077
6083 /* Create a dummy instance iterator here to avoid creating and 6078 if (FMGetFontFamilyName (ff, name) != noErr)
6084 destroying it in the loop. */ 6079 break;
6085 if (FMCreateFontFamilyInstanceIterator (0, &ffii) != noErr) 6080 p2cstr (name);
6086 return; 6081 if (*name == '.')
6087 /* Create an iterator to enumerate the font families. */ 6082 continue;
6088 if (FMCreateFontFamilyIterator (NULL, NULL, kFMDefaultOptions, &ffi)
6089 != noErr)
6090 {
6091 FMDisposeFontFamilyInstanceIterator (&ffii);
6092 return;
6093 }
6094 6083
6095 while (FMGetNextFontFamily (&ffi, &ff) == noErr) 6084 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr)
6096 { 6085 break;
6097 Str255 name; 6086 sc = GetTextEncodingBase (encoding);
6098 FMFont font; 6087 text_encoding_info = assq_no_quit (make_number (sc),
6099 FMFontStyle style; 6088 text_encoding_info_alist);
6100 FMFontSize size; 6089 if (!NILP (text_encoding_info))
6101 TextEncoding encoding; 6090 decode_mac_font_name (name, sizeof (name),
6102 TextEncodingBase sc; 6091 XCAR (XCDR (text_encoding_info)));
6103 6092 else
6104 if (FMGetFontFamilyName (ff, name) != noErr) 6093 text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman),
6105 break; 6094 text_encoding_info_alist);
6106 p2cstr (name);
6107 if (*name == '.')
6108 continue;
6109 6095
6110 if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) 6096 /* Point the instance iterator at the current font family. */
6111 break; 6097 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6112 sc = GetTextEncodingBase (encoding); 6098 break;
6113 decode_mac_font_name (name, sizeof (name), sc);
6114 6099
6115 /* Point the instance iterator at the current font family. */ 6100 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size)
6116 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 6101 == noErr)
6117 break; 6102 {
6103 Lisp_Object rest = XCDR (XCDR (text_encoding_info));
6118 6104
6119 while (FMGetNextFontFamilyInstance (&ffii, &font, &style, &size) 6105 for (; !NILP (rest); rest = XCDR (rest))
6120 == noErr)
6121 { 6106 {
6122 /* Both jisx0208.1983-sjis and jisx0201.1976-0 parts are 6107 char *cs = SDATA (XCAR (rest));
6123 contained in Apple Japanese (SJIS) font. */ 6108
6124 again:
6125 if (size == 0) 6109 if (size == 0)
6126 { 6110 {
6127 add_font_name_table_entry (mac_to_x_fontname (name, size, 6111 add_font_name_table_entry (mac_to_x_fontname (name, size,
6128 style, sc)); 6112 style, cs));
6129 add_font_name_table_entry (mac_to_x_fontname (name, size, 6113 add_font_name_table_entry (mac_to_x_fontname (name, size,
6130 italic, sc)); 6114 italic, cs));
6131 add_font_name_table_entry (mac_to_x_fontname (name, size, 6115 add_font_name_table_entry (mac_to_x_fontname (name, size,
6132 bold, sc)); 6116 bold, cs));
6133 add_font_name_table_entry (mac_to_x_fontname (name, size, 6117 add_font_name_table_entry (mac_to_x_fontname (name, size,
6134 italic | bold, 6118 italic | bold,
6135 sc)); 6119 cs));
6136 } 6120 }
6137 else 6121 else
6138 add_font_name_table_entry (mac_to_x_fontname (name, size,
6139 style, sc));
6140 if (sc == smJapanese)
6141 { 6122 {
6142 sc = -smJapanese; 6123 add_font_name_table_entry (mac_to_x_fontname (name, size,
6143 goto again; 6124 style, cs));
6144 } 6125 }
6145 else if (sc == -smJapanese)
6146 sc = smJapanese;
6147 } 6126 }
6148 } 6127 }
6149
6150 /* Dispose of the iterators. */
6151 FMDisposeFontFamilyIterator (&ffi);
6152 FMDisposeFontFamilyInstanceIterator (&ffii);
6153 } 6128 }
6154 else 6129
6130 UNGCPRO;
6131
6132 /* Dispose of the iterators. */
6133 FMDisposeFontFamilyIterator (&ffi);
6134 FMDisposeFontFamilyInstanceIterator (&ffii);
6135#else /* !TARGET_API_MAC_CARBON */
6136 GrafPtr port;
6137 SInt16 fontnum, old_fontnum;
6138 int num_mac_fonts = CountResources('FOND');
6139 int i, j;
6140 Handle font_handle, font_handle_2;
6141 short id, scriptcode;
6142 ResType type;
6143 Str32 name;
6144 struct FontAssoc *fat;
6145 struct AsscEntry *assc_entry;
6146 Lisp_Object text_encoding_info_alist, text_encoding_info;
6147 struct gcpro gcpro1;
6148
6149 GetPort (&port); /* save the current font number used */
6150 old_fontnum = port->txFont;
6151
6152 text_encoding_info_alist = create_text_encoding_info_alist ();
6153
6154 GCPRO1 (text_encoding_info_alist);
6155
6156 for (i = 1; i <= num_mac_fonts; i++) /* get all available fonts */
6155 { 6157 {
6156#endif /* TARGET_API_MAC_CARBON */ 6158 font_handle = GetIndResource ('FOND', i);
6157 GrafPtr port; 6159 if (!font_handle)
6158 SInt16 fontnum, old_fontnum; 6160 continue;
6159 int num_mac_fonts = CountResources('FOND');
6160 int i, j;
6161 Handle font_handle, font_handle_2;
6162 short id, scriptcode;
6163 ResType type;
6164 Str32 name;
6165 struct FontAssoc *fat;
6166 struct AsscEntry *assc_entry;
6167
6168 GetPort (&port); /* save the current font number used */
6169#if TARGET_API_MAC_CARBON
6170 old_fontnum = GetPortTextFont (port);
6171#else
6172 old_fontnum = port->txFont;
6173#endif
6174 6161
6175 for (i = 1; i <= num_mac_fonts; i++) /* get all available fonts */ 6162 GetResInfo (font_handle, &id, &type, name);
6176 { 6163 GetFNum (name, &fontnum);
6177 font_handle = GetIndResource ('FOND', i); 6164 p2cstr (name);
6178 if (!font_handle) 6165 if (fontnum == 0)
6179 continue; 6166 continue;
6180 6167
6181 GetResInfo (font_handle, &id, &type, name); 6168 TextFont (fontnum);
6182 GetFNum (name, &fontnum); 6169 scriptcode = FontToScript (fontnum);
6183 p2cstr (name); 6170 text_encoding_info = assq_no_quit (make_number (scriptcode),
6184 if (fontnum == 0) 6171 text_encoding_info_alist);
6185 continue; 6172 if (!NILP (text_encoding_info))
6173 decode_mac_font_name (name, sizeof (name),
6174 XCAR (XCDR (text_encoding_info)));
6175 else
6176 text_encoding_info = assq_no_quit (make_number (smRoman),
6177 text_encoding_info_alist);
6178 do
6179 {
6180 HLock (font_handle);
6186 6181
6187 TextFont (fontnum); 6182 if (GetResourceSizeOnDisk (font_handle)
6188 scriptcode = FontToScript (fontnum); 6183 >= sizeof (struct FamRec))
6189 decode_mac_font_name (name, sizeof (name), scriptcode);
6190 do
6191 { 6184 {
6192 HLock (font_handle); 6185 fat = (struct FontAssoc *) (*font_handle
6193 6186 + sizeof (struct FamRec));
6194 if (GetResourceSizeOnDisk (font_handle) 6187 assc_entry
6195 >= sizeof (struct FamRec)) 6188 = (struct AsscEntry *) (*font_handle
6189 + sizeof (struct FamRec)
6190 + sizeof (struct FontAssoc));
6191
6192 for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
6196 { 6193 {
6197 fat = (struct FontAssoc *) (*font_handle 6194 Lisp_Object rest = XCDR (XCDR (text_encoding_info));
6198 + sizeof (struct FamRec)); 6195
6199 assc_entry 6196 for (; !NILP (rest); rest = XCDR (rest))
6200 = (struct AsscEntry *) (*font_handle
6201 + sizeof (struct FamRec)
6202 + sizeof (struct FontAssoc));
6203
6204 for (j = 0; j <= fat->numAssoc; j++, assc_entry++)
6205 { 6197 {
6206 if (font_name_table_size == 0) 6198 char *cs = SDATA (XCAR (rest));
6207 { 6199
6208 font_name_table_size = 16; 6200 add_font_name_table_entry (mac_to_x_fontname (name,
6209 font_name_table = (char **) 6201 assc_entry->fontSize,
6210 xmalloc (font_name_table_size * sizeof (char *)); 6202 assc_entry->fontStyle,
6211 } 6203 cs));
6212 else if (font_name_count >= font_name_table_size)
6213 {
6214 font_name_table_size += 16;
6215 font_name_table = (char **)
6216 xrealloc (font_name_table,
6217 font_name_table_size * sizeof (char *));
6218 }
6219 font_name_table[font_name_count++]
6220 = mac_to_x_fontname (name,
6221 assc_entry->fontSize,
6222 assc_entry->fontStyle,
6223 scriptcode);
6224 /* Both jisx0208.1983-sjis and jisx0201.1976-0
6225 parts are contained in Apple Japanese (SJIS)
6226 font. */
6227 if (smJapanese == scriptcode)
6228 {
6229 font_name_table[font_name_count++]
6230 = mac_to_x_fontname (name,
6231 assc_entry->fontSize,
6232 assc_entry->fontStyle,
6233 -smJapanese);
6234 }
6235 } 6204 }
6236 } 6205 }
6237
6238 HUnlock (font_handle);
6239 font_handle_2 = GetNextFOND (font_handle);
6240 ReleaseResource (font_handle);
6241 font_handle = font_handle_2;
6242 } 6206 }
6243 while (ResError () == noErr && font_handle);
6244 }
6245 6207
6246 TextFont (old_fontnum); 6208 HUnlock (font_handle);
6247#if TARGET_API_MAC_CARBON 6209 font_handle_2 = GetNextFOND (font_handle);
6210 ReleaseResource (font_handle);
6211 font_handle = font_handle_2;
6212 }
6213 while (ResError () == noErr && font_handle);
6248 } 6214 }
6249#endif /* TARGET_API_MAC_CARBON */ 6215
6216 UNGCPRO;
6217
6218 TextFont (old_fontnum);
6219#endif /* !TARGET_API_MAC_CARBON */
6250} 6220}
6251 6221
6252 6222
@@ -6334,7 +6304,7 @@ mac_do_list_fonts (pattern, maxnames)
6334 ptr++; 6304 ptr++;
6335 if (i == *field) 6305 if (i == *field)
6336 { 6306 {
6337 if ('1' <= *ptr && *ptr <= '9') 6307 if ('0' <= *ptr && *ptr <= '9')
6338 { 6308 {
6339 *val = *ptr++ - '0'; 6309 *val = *ptr++ - '0';
6340 while ('0' <= *ptr && *ptr <= '9' && *val < 10000) 6310 while ('0' <= *ptr && *ptr <= '9' && *val < 10000)
@@ -6352,21 +6322,21 @@ mac_do_list_fonts (pattern, maxnames)
6352 6322
6353 if (i == 14 && ptr == NULL) 6323 if (i == 14 && ptr == NULL)
6354 { 6324 {
6355 if (scl_val[XLFD_SCL_POINT_SIZE] > 0) 6325 if (scl_val[XLFD_SCL_PIXEL_SIZE] < 0)
6356 { 6326 scl_val[XLFD_SCL_PIXEL_SIZE] =
6357 scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_POINT_SIZE] / 10; 6327 (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE] / 10
6358 scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_POINT_SIZE]; 6328 : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH] / 10
6359 } 6329 : -1));
6360 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0) 6330 if (scl_val[XLFD_SCL_POINT_SIZE] < 0)
6361 { 6331 scl_val[XLFD_SCL_POINT_SIZE] =
6362 scl_val[XLFD_SCL_POINT_SIZE] = 6332 (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
6363 scl_val[XLFD_SCL_AVGWIDTH] = scl_val[XLFD_SCL_PIXEL_SIZE] * 10; 6333 : (scl_val[XLFD_SCL_AVGWIDTH] > 0 ? scl_val[XLFD_SCL_AVGWIDTH]
6364 } 6334 : -1));
6365 else if (scl_val[XLFD_SCL_AVGWIDTH] > 0) 6335 if (scl_val[XLFD_SCL_AVGWIDTH] < 0)
6366 { 6336 scl_val[XLFD_SCL_AVGWIDTH] =
6367 scl_val[XLFD_SCL_PIXEL_SIZE] = scl_val[XLFD_SCL_AVGWIDTH] / 10; 6337 (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 ? scl_val[XLFD_SCL_PIXEL_SIZE] * 10
6368 scl_val[XLFD_SCL_POINT_SIZE] = scl_val[XLFD_SCL_AVGWIDTH]; 6338 : (scl_val[XLFD_SCL_POINT_SIZE] > 0 ? scl_val[XLFD_SCL_POINT_SIZE]
6369 } 6339 : -1));
6370 } 6340 }
6371 else 6341 else
6372 scl_val[XLFD_SCL_PIXEL_SIZE] = -1; 6342 scl_val[XLFD_SCL_PIXEL_SIZE] = -1;
@@ -6457,49 +6427,62 @@ mac_do_list_fonts (pattern, maxnames)
6457 return font_list; 6427 return font_list;
6458} 6428}
6459 6429
6460/* Return a list of at most MAXNAMES font specs matching the one in 6430/* Return a list of names of available fonts matching PATTERN on frame F.
6461 PATTERN. Cache matching fonts for patterns in 6431
6462 dpyinfo->name_list_element to avoid looking them up again by 6432 Frame F null means we have not yet created any frame on Mac, and
6463 calling mac_font_pattern_match (slow). Return as many matching 6433 consult the first display in x_display_list. MAXNAMES sets a limit
6464 fonts as possible if MAXNAMES = -1. */ 6434 on how many fonts to match. */
6465 6435
6466Lisp_Object 6436Lisp_Object
6467x_list_fonts (struct frame *f, 6437x_list_fonts (f, pattern, size, maxnames)
6468 Lisp_Object pattern, 6438 struct frame *f;
6469 int size, 6439 Lisp_Object pattern;
6470 int maxnames) 6440 int size, maxnames;
6471{ 6441{
6472 Lisp_Object newlist = Qnil, tem, key; 6442 Lisp_Object list = Qnil, patterns, tem, key;
6473 struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL; 6443 struct mac_display_info *dpyinfo
6444 = f ? FRAME_MAC_DISPLAY_INFO (f) : x_display_list;
6445
6446 xassert (size <= 0);
6447
6448 patterns = Fassoc (pattern, Valternate_fontname_alist);
6449 if (NILP (patterns))
6450 patterns = Fcons (pattern, Qnil);
6474 6451
6475 if (dpyinfo) 6452 for (; CONSP (patterns); patterns = XCDR (patterns))
6476 { 6453 {
6454 pattern = XCAR (patterns);
6455
6456 if (!STRINGP (pattern))
6457 continue;
6458
6477 tem = XCAR (XCDR (dpyinfo->name_list_element)); 6459 tem = XCAR (XCDR (dpyinfo->name_list_element));
6478 key = Fcons (pattern, make_number (maxnames)); 6460 key = Fcons (pattern, make_number (maxnames));
6479 6461
6480 newlist = Fassoc (key, tem); 6462 list = Fassoc (key, tem);
6481 if (!NILP (newlist)) 6463 if (!NILP (list))
6482 { 6464 {
6483 newlist = Fcdr_safe (newlist); 6465 list = Fcdr_safe (list);
6466 /* We have a cashed list. Don't have to get the list again. */
6484 goto label_cached; 6467 goto label_cached;
6485 } 6468 }
6486 }
6487 6469
6488 BLOCK_INPUT; 6470 BLOCK_INPUT;
6489 newlist = mac_do_list_fonts (SDATA (pattern), maxnames); 6471 list = mac_do_list_fonts (SDATA (pattern), maxnames);
6490 UNBLOCK_INPUT; 6472 UNBLOCK_INPUT;
6491 6473
6492 /* MAC_TODO: add code for matching outline fonts here */ 6474 /* MAC_TODO: add code for matching outline fonts here */
6493 6475
6494 if (dpyinfo) 6476 /* Now store the result in the cache. */
6495 {
6496 XSETCAR (XCDR (dpyinfo->name_list_element), 6477 XSETCAR (XCDR (dpyinfo->name_list_element),
6497 Fcons (Fcons (key, newlist), 6478 Fcons (Fcons (key, list),
6498 XCAR (XCDR (dpyinfo->name_list_element)))); 6479 XCAR (XCDR (dpyinfo->name_list_element))));
6480
6481 label_cached:
6482 if (NILP (list)) continue; /* Try the remaining alternatives. */
6499 } 6483 }
6500 label_cached:
6501 6484
6502 return newlist; 6485 return list;
6503} 6486}
6504 6487
6505 6488
@@ -6618,7 +6601,7 @@ is_fully_specified_xlfd (char *p)
6618} 6601}
6619 6602
6620 6603
6621const int kDefaultFontSize = 9; 6604const int kDefaultFontSize = 12;
6622 6605
6623 6606
6624/* XLoadQueryFont creates and returns an internal representation for a 6607/* XLoadQueryFont creates and returns an internal representation for a
@@ -6630,17 +6613,25 @@ const int kDefaultFontSize = 9;
6630static MacFontStruct * 6613static MacFontStruct *
6631XLoadQueryFont (Display *dpy, char *fontname) 6614XLoadQueryFont (Display *dpy, char *fontname)
6632{ 6615{
6633 int i, size, is_two_byte_font, char_width; 6616 int i, size, point_size, avgwidth, is_two_byte_font, char_width;
6634 char *name; 6617 char *name;
6635 GrafPtr port; 6618 GrafPtr port;
6636 SInt16 old_fontnum, old_fontsize; 6619 SInt16 old_fontnum, old_fontsize;
6637 Style old_fontface; 6620 Style old_fontface;
6638 Str32 mfontname; 6621 Str32 mfontname, mfontname_decoded, charset;
6639 SInt16 fontnum; 6622 SInt16 fontnum;
6640 Style fontface = normal; 6623 Style fontface;
6624#if TARGET_API_MAC_CARBON
6625 TextEncoding encoding;
6626 int scriptcode;
6627#else
6628 short scriptcode;
6629#endif
6641 MacFontStruct *font; 6630 MacFontStruct *font;
6642 FontInfo the_fontinfo; 6631 FontInfo the_fontinfo;
6643 char s_weight[7], c_slant; 6632#ifdef MAC_OSX
6633 UInt32 old_flags, new_flags;
6634#endif
6644 6635
6645 if (is_fully_specified_xlfd (fontname)) 6636 if (is_fully_specified_xlfd (fontname))
6646 name = fontname; 6637 name = fontname;
@@ -6665,46 +6656,50 @@ XLoadQueryFont (Display *dpy, char *fontname)
6665 old_fontface = port->txFace; 6656 old_fontface = port->txFace;
6666#endif 6657#endif
6667 6658
6668 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &size) != 1) 6659 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%*s", &size, &point_size, &avgwidth) != 3)
6660 size = 0;
6661 else
6662 {
6663 if (size == 0)
6664 if (point_size > 0)
6665 size = point_size / 10;
6666 else if (avgwidth > 0)
6667 size = avgwidth / 10;
6668 }
6669 if (size == 0)
6669 size = kDefaultFontSize; 6670 size = kDefaultFontSize;
6670 6671
6671 if (sscanf (name, "-%*[^-]-%*[^-]-%6[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", s_weight) == 1) 6672 x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded,
6672 if (strcmp (s_weight, "bold") == 0) 6673 &fontface, charset);
6673 fontface |= bold;
6674
6675 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%*s", &c_slant) == 1)
6676 if (c_slant == 'i')
6677 fontface |= italic;
6678
6679 x_font_name_to_mac_font_name (name, mfontname);
6680 c2pstr (mfontname); 6674 c2pstr (mfontname);
6675#if TARGET_API_MAC_CARBON
6676 fontnum = FMGetFontFamilyFromName (mfontname);
6677 if (fontnum == kInvalidFontFamily
6678 || FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr)
6679 return NULL;
6680 scriptcode = GetTextEncodingBase (encoding);
6681#else
6681 GetFNum (mfontname, &fontnum); 6682 GetFNum (mfontname, &fontnum);
6682 if (fontnum == 0) 6683 if (fontnum == 0)
6683 return NULL; 6684 return NULL;
6685 scriptcode = FontToScript (fontnum);
6686#endif
6684 6687
6685 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct)); 6688 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
6686 6689
6687 font->fontname = (char *) xmalloc (strlen (name) + 1);
6688 bcopy (name, font->fontname, strlen (name) + 1);
6689
6690 font->mac_fontnum = fontnum; 6690 font->mac_fontnum = fontnum;
6691 font->mac_fontsize = size; 6691 font->mac_fontsize = size;
6692 font->mac_fontface = fontface; 6692 font->mac_fontface = fontface;
6693 font->mac_scriptcode = FontToScript (fontnum); 6693 font->mac_scriptcode = scriptcode;
6694 6694
6695 /* Apple Japanese (SJIS) font is listed as both 6695 /* Apple Japanese (SJIS) font is listed as both
6696 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0" 6696 "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
6697 (Roman script) in init_font_name_table (). The latter should be 6697 (Roman script) in init_font_name_table (). The latter should be
6698 treated as a one-byte font. */ 6698 treated as a one-byte font. */
6699 { 6699 if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0)
6700 char cs[32]; 6700 font->mac_scriptcode = smRoman;
6701 6701
6702 if (sscanf (name, 6702 font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset);
6703 "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
6704 cs) == 1
6705 && 0 == strcmp (cs, "jisx0201.1976-0"))
6706 font->mac_scriptcode = smRoman;
6707 }
6708 6703
6709 is_two_byte_font = font->mac_scriptcode == smJapanese || 6704 is_two_byte_font = font->mac_scriptcode == smJapanese ||
6710 font->mac_scriptcode == smTradChinese || 6705 font->mac_scriptcode == smTradChinese ||
@@ -6829,7 +6824,7 @@ mac_unload_font (dpyinfo, font)
6829 struct mac_display_info *dpyinfo; 6824 struct mac_display_info *dpyinfo;
6830 XFontStruct *font; 6825 XFontStruct *font;
6831{ 6826{
6832 xfree (font->fontname); 6827 xfree (font->full_name);
6833 if (font->per_char) 6828 if (font->per_char)
6834 xfree (font->per_char); 6829 xfree (font->per_char);
6835 xfree (font); 6830 xfree (font);
@@ -6869,6 +6864,8 @@ x_load_font (f, fontname, size)
6869 SDATA (XCAR (tail))))) 6864 SDATA (XCAR (tail)))))
6870 return (dpyinfo->font_table + i); 6865 return (dpyinfo->font_table + i);
6871 } 6866 }
6867 else
6868 return NULL;
6872 6869
6873 /* Load the font and add it to the table. */ 6870 /* Load the font and add it to the table. */
6874 { 6871 {
@@ -6878,13 +6875,7 @@ x_load_font (f, fontname, size)
6878 unsigned long value; 6875 unsigned long value;
6879 int i; 6876 int i;
6880 6877
6881 /* If we have found fonts by x_list_font, load one of them. If 6878 fontname = (char *) SDATA (XCAR (font_names));
6882 not, we still try to load a font by the name given as FONTNAME
6883 because XListFonts (called in x_list_font) of some X server has
6884 a bug of not finding a font even if the font surely exists and
6885 is loadable by XLoadQueryFont. */
6886 if (size > 0 && !NILP (font_names))
6887 fontname = (char *) SDATA (XCAR (font_names));
6888 6879
6889 BLOCK_INPUT; 6880 BLOCK_INPUT;
6890 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname); 6881 font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);
@@ -6917,8 +6908,8 @@ x_load_font (f, fontname, size)
6917 bzero (fontp, sizeof (*fontp)); 6908 bzero (fontp, sizeof (*fontp));
6918 fontp->font = font; 6909 fontp->font = font;
6919 fontp->font_idx = i; 6910 fontp->font_idx = i;
6920 fontp->name = (char *) xmalloc (strlen (font->fontname) + 1); 6911 fontp->name = (char *) xmalloc (strlen (fontname) + 1);
6921 bcopy (font->fontname, fontp->name, strlen (font->fontname) + 1); 6912 bcopy (fontname, fontp->name, strlen (fontname) + 1);
6922 6913
6923 if (font->min_bounds.width == font->max_bounds.width) 6914 if (font->min_bounds.width == font->max_bounds.width)
6924 { 6915 {
@@ -6949,7 +6940,8 @@ x_load_font (f, fontname, size)
6949 fontp->average_width = FONT_WIDTH (font); 6940 fontp->average_width = FONT_WIDTH (font);
6950 } 6941 }
6951 6942
6952 fontp->full_name = fontp->name; 6943 fontp->full_name = (char *) xmalloc (strlen (font->full_name) + 1);
6944 bcopy (font->full_name, fontp->full_name, strlen (font->full_name) + 1);
6953 6945
6954 fontp->size = font->max_bounds.width; 6946 fontp->size = font->max_bounds.width;
6955 fontp->height = FONT_HEIGHT (font); 6947 fontp->height = FONT_HEIGHT (font);
@@ -7096,7 +7088,6 @@ x_find_ccl_program (fontp)
7096#include <Dialogs.h> 7088#include <Dialogs.h>
7097#include <Script.h> 7089#include <Script.h>
7098#include <Types.h> 7090#include <Types.h>
7099#include <TextEncodingConverter.h>
7100#include <Resources.h> 7091#include <Resources.h>
7101 7092
7102#if __MWERKS__ 7093#if __MWERKS__
@@ -7481,21 +7472,6 @@ do_app_resume ()
7481{ 7472{
7482 /* Window-activate events will do the job. */ 7473 /* Window-activate events will do the job. */
7483#if 0 7474#if 0
7484 WindowPtr wp;
7485 struct frame *f;
7486
7487 wp = front_emacs_window ();
7488 if (wp)
7489 {
7490 f = mac_window_to_frame (wp);
7491
7492 if (f)
7493 {
7494 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
7495 activate_scroll_bars (f);
7496 }
7497 }
7498
7499 app_is_suspended = false; 7475 app_is_suspended = false;
7500 app_sleep_time = WNE_SLEEP_AT_RESUME; 7476 app_sleep_time = WNE_SLEEP_AT_RESUME;
7501#endif 7477#endif
@@ -7506,21 +7482,6 @@ do_app_suspend ()
7506{ 7482{
7507 /* Window-deactivate events will do the job. */ 7483 /* Window-deactivate events will do the job. */
7508#if 0 7484#if 0
7509 WindowPtr wp;
7510 struct frame *f;
7511
7512 wp = front_emacs_window ();
7513 if (wp)
7514 {
7515 f = mac_window_to_frame (wp);
7516
7517 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7518 {
7519 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
7520 deactivate_scroll_bars (f);
7521 }
7522 }
7523
7524 app_is_suspended = true; 7485 app_is_suspended = true;
7525 app_sleep_time = WNE_SLEEP_AT_SUSPEND; 7486 app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7526#endif 7487#endif
@@ -7528,40 +7489,6 @@ do_app_suspend ()
7528 7489
7529 7490
7530static void 7491static void
7531do_mouse_moved (mouse_pos, f)
7532 Point mouse_pos;
7533 FRAME_PTR *f;
7534{
7535 WindowPtr wp = front_emacs_window ();
7536 struct x_display_info *dpyinfo;
7537
7538 if (wp)
7539 {
7540 *f = mac_window_to_frame (wp);
7541 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
7542
7543 if (dpyinfo->mouse_face_hidden)
7544 {
7545 dpyinfo->mouse_face_hidden = 0;
7546 clear_mouse_face (dpyinfo);
7547 }
7548
7549 SetPortWindowPort (wp);
7550
7551 GlobalToLocal (&mouse_pos);
7552
7553 if (dpyinfo->grabbed && tracked_scroll_bar)
7554 x_scroll_bar_note_movement (tracked_scroll_bar,
7555 mouse_pos.v
7556 - XINT (tracked_scroll_bar->top),
7557 TickCount() * (1000 / 60));
7558 else
7559 note_mouse_movement (*f, &mouse_pos);
7560 }
7561}
7562
7563
7564static void
7565do_apple_menu (SInt16 menu_item) 7492do_apple_menu (SInt16 menu_item)
7566{ 7493{
7567#if !TARGET_API_MAC_CARBON 7494#if !TARGET_API_MAC_CARBON
@@ -7597,7 +7524,7 @@ do_menu_choice (SInt32 menu_choice)
7597 7524
7598 default: 7525 default:
7599 { 7526 {
7600 struct frame *f = mac_window_to_frame (front_emacs_window ()); 7527 struct frame *f = mac_focus_frame (&one_mac_display_info);
7601 MenuHandle menu = GetMenuHandle (menu_id); 7528 MenuHandle menu = GetMenuHandle (menu_id);
7602 if (menu) 7529 if (menu)
7603 { 7530 {
@@ -7675,13 +7602,14 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7675 Point top_left; 7602 Point top_left;
7676 int w_title_height, columns, rows, width, height; 7603 int w_title_height, columns, rows, width, height;
7677 struct frame *f = mac_window_to_frame (w); 7604 struct frame *f = mac_window_to_frame (w);
7605 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
7678 7606
7679#if TARGET_API_MAC_CARBON 7607#if TARGET_API_MAC_CARBON
7680 { 7608 {
7681 Point standard_size; 7609 Point standard_size;
7682 7610
7683 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); 7611 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
7684 standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height; 7612 standard_size.v = dpyinfo->height;
7685 7613
7686 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) 7614 if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
7687 zoom_in_or_out = inZoomIn; 7615 zoom_in_or_out = inZoomIn;
@@ -7737,7 +7665,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7737 = zoom_rect; 7665 = zoom_rect;
7738 } 7666 }
7739 7667
7740 ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ()); 7668 ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
7741 7669
7742 SetPort (save_port); 7670 SetPort (save_port);
7743#endif /* not TARGET_API_MAC_CARBON */ 7671#endif /* not TARGET_API_MAC_CARBON */
@@ -8603,13 +8531,18 @@ XTread_socket (sd, expected, hold_quit)
8603 { 8531 {
8604 SInt32 delta; 8532 SInt32 delta;
8605 Point point; 8533 Point point;
8606 WindowPtr window_ptr = front_emacs_window (); 8534 struct frame *f = mac_focus_frame (dpyinfo);
8535 WindowPtr window_ptr;
8607 8536
8608 if (!IsValidWindowPtr (window_ptr)) 8537#if 0
8538 if (dpyinfo->x_focus_frame == NULL)
8609 { 8539 {
8540 /* Beep if wheel move occurs when all the frames
8541 are invisible. */
8610 SysBeep(1); 8542 SysBeep(1);
8611 break; 8543 break;
8612 } 8544 }
8545#endif
8613 8546
8614 GetEventParameter(eventRef, kEventParamMouseWheelDelta, 8547 GetEventParameter(eventRef, kEventParamMouseWheelDelta,
8615 typeSInt32, NULL, sizeof (SInt32), 8548 typeSInt32, NULL, sizeof (SInt32),
@@ -8622,6 +8555,7 @@ XTread_socket (sd, expected, hold_quit)
8622 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) 8555 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8623 | ((delta < 0) ? down_modifier 8556 | ((delta < 0) ? down_modifier
8624 : up_modifier)); 8557 : up_modifier));
8558 window_ptr = FRAME_MAC_WINDOW (f);
8625 SetPortWindowPort (window_ptr); 8559 SetPortWindowPort (window_ptr);
8626 GlobalToLocal (&point); 8560 GlobalToLocal (&point);
8627 XSETINT (inev.x, point.h); 8561 XSETINT (inev.x, point.h);
@@ -8680,14 +8614,14 @@ XTread_socket (sd, expected, hold_quit)
8680 switch (part_code) 8614 switch (part_code)
8681 { 8615 {
8682 case inMenuBar: 8616 case inMenuBar:
8683 f = mac_window_to_frame (front_emacs_window ()); 8617 f = mac_focus_frame (dpyinfo);
8684 saved_menu_event_location = er.where; 8618 saved_menu_event_location = er.where;
8685 inev.kind = MENU_BAR_ACTIVATE_EVENT; 8619 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8686 XSETFRAME (inev.frame_or_window, f); 8620 XSETFRAME (inev.frame_or_window, f);
8687 break; 8621 break;
8688 8622
8689 case inContent: 8623 case inContent:
8690 if (window_ptr != front_emacs_window ()) 8624 if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo)))
8691 SelectWindow (window_ptr); 8625 SelectWindow (window_ptr);
8692 else 8626 else
8693 { 8627 {
@@ -8878,7 +8812,61 @@ XTread_socket (sd, expected, hold_quit)
8878 help_echo_string = help_echo_object = help_echo_window = Qnil; 8812 help_echo_string = help_echo_object = help_echo_window = Qnil;
8879 help_echo_pos = -1; 8813 help_echo_pos = -1;
8880 8814
8881 do_mouse_moved (er.where, &f); 8815 if (dpyinfo->grabbed && last_mouse_frame
8816 && FRAME_LIVE_P (last_mouse_frame))
8817 f = last_mouse_frame;
8818 else
8819 f = dpyinfo->x_focus_frame;
8820
8821 if (dpyinfo->mouse_face_hidden)
8822 {
8823 dpyinfo->mouse_face_hidden = 0;
8824 clear_mouse_face (dpyinfo);
8825 }
8826
8827 if (f)
8828 {
8829 WindowPtr wp = FRAME_MAC_WINDOW (f);
8830 Point mouse_pos = er.where;
8831
8832 SetPortWindowPort (wp);
8833
8834 GlobalToLocal (&mouse_pos);
8835
8836 if (dpyinfo->grabbed && tracked_scroll_bar)
8837 x_scroll_bar_note_movement (tracked_scroll_bar,
8838 mouse_pos.v
8839 - XINT (tracked_scroll_bar->top),
8840 TickCount() * (1000 / 60));
8841 else
8842 {
8843 /* Generate SELECT_WINDOW_EVENTs when needed. */
8844 if (mouse_autoselect_window)
8845 {
8846 Lisp_Object window;
8847
8848 window = window_from_coordinates (f,
8849 mouse_pos.h,
8850 mouse_pos.v,
8851 0, 0, 0, 0);
8852
8853 /* Window will be selected only when it is
8854 not selected now and last mouse movement
8855 event was not in it. Minibuffer window
8856 will be selected iff it is active. */
8857 if (WINDOWP (window)
8858 && !EQ (window, last_window)
8859 && !EQ (window, selected_window))
8860 {
8861 inev.kind = SELECT_WINDOW_EVENT;
8862 inev.frame_or_window = window;
8863 }
8864
8865 last_window=window;
8866 }
8867 note_mouse_movement (f, &mouse_pos);
8868 }
8869 }
8882 8870
8883 /* If the contents of the global variable 8871 /* If the contents of the global variable
8884 help_echo_string has changed, generate a 8872 help_echo_string has changed, generate a
@@ -8892,7 +8880,6 @@ XTread_socket (sd, expected, hold_quit)
8892 case activateEvt: 8880 case activateEvt:
8893 { 8881 {
8894 WindowPtr window_ptr = (WindowPtr) er.message; 8882 WindowPtr window_ptr = (WindowPtr) er.message;
8895 ControlRef root_control;
8896 8883
8897#if USE_CARBON_EVENTS 8884#if USE_CARBON_EVENTS
8898 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 8885 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
@@ -8908,16 +8895,12 @@ XTread_socket (sd, expected, hold_quit)
8908 if (!is_emacs_window (window_ptr)) 8895 if (!is_emacs_window (window_ptr))
8909 break; 8896 break;
8910 8897
8911 f = mac_window_to_frame (window_ptr);
8912 GetRootControl (window_ptr, &root_control);
8913
8914 if ((er.modifiers & activeFlag) != 0) 8898 if ((er.modifiers & activeFlag) != 0)
8915 { 8899 {
8916 /* A window has been activated */ 8900 /* A window has been activated */
8917 Point mouse_loc = er.where; 8901 Point mouse_loc = er.where;
8918 8902
8919 x_new_focus_frame (dpyinfo, f); 8903 x_detect_focus_change (dpyinfo, &er, &inev);
8920 ActivateControl (root_control);
8921 8904
8922 SetPortWindowPort (window_ptr); 8905 SetPortWindowPort (window_ptr);
8923 GlobalToLocal (&mouse_loc); 8906 GlobalToLocal (&mouse_loc);
@@ -8931,13 +8914,9 @@ XTread_socket (sd, expected, hold_quit)
8931 /* A window has been deactivated */ 8914 /* A window has been deactivated */
8932 dpyinfo->grabbed = 0; 8915 dpyinfo->grabbed = 0;
8933 8916
8934 if (f == dpyinfo->x_focus_frame) 8917 x_detect_focus_change (dpyinfo, &er, &inev);
8935 {
8936 x_new_focus_frame (dpyinfo, 0);
8937 DeactivateControl (root_control);
8938 }
8939
8940 8918
8919 f = mac_window_to_frame (window_ptr);
8941 if (f == dpyinfo->mouse_face_mouse_frame) 8920 if (f == dpyinfo->mouse_face_mouse_frame)
8942 { 8921 {
8943 /* If we move outside the frame, then we're 8922 /* If we move outside the frame, then we're
@@ -8978,13 +8957,16 @@ XTread_socket (sd, expected, hold_quit)
8978 break; 8957 break;
8979#endif 8958#endif
8980 8959
8981#if TARGET_API_MAC_CARBON 8960#if 0
8982 if (!IsValidWindowPtr (front_emacs_window ())) 8961 if (dpyinfo->x_focus_frame == NULL)
8983 { 8962 {
8963 /* Beep if keyboard input occurs when all the frames
8964 are invisible. */
8984 SysBeep (1); 8965 SysBeep (1);
8985 break; 8966 break;
8986 } 8967 }
8987#endif 8968#endif
8969
8988 { 8970 {
8989 static SInt16 last_key_script = -1; 8971 static SInt16 last_key_script = -1;
8990 SInt16 current_key_script = GetScriptManagerVariable (smKeyScript); 8972 SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
@@ -8992,7 +8974,7 @@ XTread_socket (sd, expected, hold_quit)
8992 if (last_key_script != current_key_script) 8974 if (last_key_script != current_key_script)
8993 { 8975 {
8994 struct input_event event; 8976 struct input_event event;
8995 8977
8996 EVENT_INIT (event); 8978 EVENT_INIT (event);
8997 event.kind = LANGUAGE_CHANGE_EVENT; 8979 event.kind = LANGUAGE_CHANGE_EVENT;
8998 event.arg = Qnil; 8980 event.arg = Qnil;
@@ -9036,18 +9018,20 @@ XTread_socket (sd, expected, hold_quit)
9036 unsigned long some_state = 0; 9018 unsigned long some_state = 0;
9037 inev.code = KeyTranslate (kchr_ptr, new_keycode, 9019 inev.code = KeyTranslate (kchr_ptr, new_keycode,
9038 &some_state) & 0xff; 9020 &some_state) & 0xff;
9039 } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) 9021 }
9040 { 9022 else if (!NILP (Vmac_option_modifier)
9041 /* When using the option key as an emacs modifier, convert 9023 && (er.modifiers & optionKey))
9042 the pressed key code back to one without the Mac option 9024 {
9043 modifier applied. */ 9025 /* When using the option key as an emacs modifier,
9044 int new_modifiers = er.modifiers & ~optionKey; 9026 convert the pressed key code back to one
9045 int new_keycode = keycode | new_modifiers; 9027 without the Mac option modifier applied. */
9046 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); 9028 int new_modifiers = er.modifiers & ~optionKey;
9047 unsigned long some_state = 0; 9029 int new_keycode = keycode | new_modifiers;
9048 inev.code = KeyTranslate (kchr_ptr, new_keycode, 9030 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9049 &some_state) & 0xff; 9031 unsigned long some_state = 0;
9050 } 9032 inev.code = KeyTranslate (kchr_ptr, new_keycode,
9033 &some_state) & 0xff;
9034 }
9051 else 9035 else
9052 inev.code = er.message & charCodeMask; 9036 inev.code = er.message & charCodeMask;
9053 inev.kind = ASCII_KEYSTROKE_EVENT; 9037 inev.kind = ASCII_KEYSTROKE_EVENT;
@@ -9059,8 +9043,7 @@ XTread_socket (sd, expected, hold_quit)
9059#else 9043#else
9060 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 9044 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9061#endif 9045#endif
9062 XSETFRAME (inev.frame_or_window, 9046 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
9063 mac_window_to_frame (front_emacs_window ()));
9064 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ 9047 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
9065 break; 9048 break;
9066 9049
@@ -9073,22 +9056,10 @@ XTread_socket (sd, expected, hold_quit)
9073 constuct_drag_n_drop in w32term.c. */ 9056 constuct_drag_n_drop in w32term.c. */
9074 if (!NILP (drag_and_drop_file_list)) 9057 if (!NILP (drag_and_drop_file_list))
9075 { 9058 {
9076 struct frame *f = NULL; 9059 struct frame *f = mac_focus_frame (dpyinfo);
9077 WindowPtr wp; 9060 WindowPtr wp;
9078 Lisp_Object frame; 9061 Lisp_Object frame;
9079 9062
9080 wp = front_emacs_window ();
9081
9082 if (!wp)
9083 {
9084 struct frame *f = XFRAME (XCAR (Vframe_list));
9085 CollapseWindow (FRAME_MAC_WINDOW (f), false);
9086 wp = front_emacs_window ();
9087 }
9088
9089 if (wp)
9090 f = mac_window_to_frame (wp);
9091
9092 inev.kind = DRAG_N_DROP_EVENT; 9063 inev.kind = DRAG_N_DROP_EVENT;
9093 inev.code = 0; 9064 inev.code = 0;
9094 inev.timestamp = er.when * (1000 / 60); 9065 inev.timestamp = er.when * (1000 / 60);
@@ -9105,10 +9076,12 @@ XTread_socket (sd, expected, hold_quit)
9105 XSETFRAME (frame, f); 9076 XSETFRAME (frame, f);
9106 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); 9077 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
9107 9078
9079#if 0
9108 /* Regardless of whether Emacs was suspended or in the 9080 /* Regardless of whether Emacs was suspended or in the
9109 foreground, ask it to redraw its entire screen. 9081 foreground, ask it to redraw its entire screen.
9110 Otherwise parts of the screen can be left in an 9082 Otherwise parts of the screen can be left in an
9111 inconsistent state. */ 9083 inconsistent state. */
9084 wp = FRAME_MAC_WINDOW (f);
9112 if (wp) 9085 if (wp)
9113#if TARGET_API_MAC_CARBON 9086#if TARGET_API_MAC_CARBON
9114 { 9087 {
@@ -9120,6 +9093,7 @@ XTread_socket (sd, expected, hold_quit)
9120#else /* not TARGET_API_MAC_CARBON */ 9093#else /* not TARGET_API_MAC_CARBON */
9121 InvalRect (&(wp->portRect)); 9094 InvalRect (&(wp->portRect));
9122#endif /* not TARGET_API_MAC_CARBON */ 9095#endif /* not TARGET_API_MAC_CARBON */
9096#endif
9123 } 9097 }
9124 default: 9098 default:
9125 break; 9099 break;
@@ -9599,7 +9573,7 @@ mac_check_for_quit_char ()
9599 e.arg = Qnil; 9573 e.arg = Qnil;
9600 e.modifiers = NULL; 9574 e.modifiers = NULL;
9601 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); 9575 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
9602 XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ())); 9576 XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info));
9603 /* Remove event from queue to prevent looping. */ 9577 /* Remove event from queue to prevent looping. */
9604 RemoveEventFromQueue (GetMainEventQueue (), event); 9578 RemoveEventFromQueue (GetMainEventQueue (), event);
9605 ReleaseEvent (event); 9579 ReleaseEvent (event);
@@ -9780,22 +9754,6 @@ syms_of_macterm ()
9780 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); 9754 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
9781 staticpro (&Qmac_ready_for_drag_n_drop); 9755 staticpro (&Qmac_ready_for_drag_n_drop);
9782 9756
9783 Qbig5 = intern ("big5");
9784 staticpro (&Qbig5);
9785
9786 Qcn_gb = intern ("cn-gb");
9787 staticpro (&Qcn_gb);
9788
9789 Qsjis = intern ("sjis");
9790 staticpro (&Qsjis);
9791
9792 Qeuc_kr = intern ("euc-kr");
9793 staticpro (&Qeuc_kr);
9794
9795 DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p,
9796 doc: /* *Non-nil means autoselect window with mouse pointer. */);
9797 x_autoselect_window_p = 0;
9798
9799 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 9757 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
9800 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 9758 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
9801 Vx_toolkit_scroll_bars = Qt; 9759 Vx_toolkit_scroll_bars = Qt;
@@ -9855,10 +9813,6 @@ Toolbox for processing before Emacs sees it. */);
9855Toolbox for processing before Emacs sees it. */); 9813Toolbox for processing before Emacs sees it. */);
9856 Vmac_pass_control_to_system = Qt; 9814 Vmac_pass_control_to_system = Qt;
9857 9815
9858 DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system,
9859 doc: /* If non-nil, the Mac \"Control\" key is passed on to the Mac
9860Toolbox for processing before Emacs sees it. */);
9861 Vmac_pass_control_to_system = Qt;
9862#endif 9816#endif
9863 9817
9864 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics, 9818 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,
@@ -9866,6 +9820,22 @@ Toolbox for processing before Emacs sees it. */);
9866The text will be rendered using Core Graphics text rendering which 9820The text will be rendered using Core Graphics text rendering which
9867may anti-alias the text. */); 9821may anti-alias the text. */);
9868 Vmac_use_core_graphics = Qnil; 9822 Vmac_use_core_graphics = Qnil;
9823
9824 /* Register an entry for `mac-roman' so that it can be used when
9825 creating the terminal frame on Mac OS 9 before loading
9826 term/mac-win.elc. */
9827 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,
9828 doc: /* Alist linking Emacs character sets to Mac text encoding and Emacs coding system.
9829Each entry should be of the form:
9830
9831 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM)
9832
9833where CHARSET-NAME is a string used in font names to identify the
9834charset, TEXT-ENCODING is a TextEncodingBase value, and CODING_SYSTEM
9835is a coding system corresponding to TEXT-ENCODING. */);
9836 Vmac_charset_info_alist =
9837 Fcons (list3 (build_string ("mac-roman"),
9838 make_number (smRoman), Qnil), Qnil);
9869} 9839}
9870 9840
9871/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b 9841/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
diff --git a/src/macterm.h b/src/macterm.h
index cc0ab1a4e2b..48e028f9064 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -195,14 +195,14 @@ struct mac_display_info
195 int bitmaps_last; 195 int bitmaps_last;
196 196
197 /* The frame (if any) which has the window that has keyboard focus. 197 /* The frame (if any) which has the window that has keyboard focus.
198 Zero if none. This is examined by Ffocus_frame in w32fns.c. Note 198 Zero if none. This is examined by Ffocus_frame in macfns.c. Note
199 that a mere EnterNotify event can set this; if you need to know the 199 that a mere EnterNotify event can set this; if you need to know the
200 last frame specified in a FocusIn or FocusOut event, use 200 last frame specified in a FocusIn or FocusOut event, use
201 w32_focus_event_frame. */ 201 x_focus_event_frame. */
202 struct frame *x_focus_frame; 202 struct frame *x_focus_frame;
203 203
204 /* The last frame mentioned in a FocusIn or FocusOut event. This is 204 /* The last frame mentioned in a FocusIn or FocusOut event. This is
205 separate from w32_focus_frame, because whether or not LeaveNotify 205 separate from x_focus_frame, because whether or not LeaveNotify
206 events cause us to lose focus depends on whether or not we have 206 events cause us to lose focus depends on whether or not we have
207 received a FocusIn event for it. */ 207 received a FocusIn event for it. */
208 struct frame *x_focus_event_frame; 208 struct frame *x_focus_event_frame;
@@ -210,7 +210,7 @@ struct mac_display_info
210 /* The frame which currently has the visual highlight, and should get 210 /* The frame which currently has the visual highlight, and should get
211 keyboard input (other sorts of input have the frame encoded in the 211 keyboard input (other sorts of input have the frame encoded in the
212 event). It points to the focus frame's selected window's 212 event). It points to the focus frame's selected window's
213 frame. It differs from w32_focus_frame when we're using a global 213 frame. It differs from x_focus_frame when we're using a global
214 minibuffer. */ 214 minibuffer. */
215 struct frame *x_highlight_frame; 215 struct frame *x_highlight_frame;
216 216
@@ -421,7 +421,7 @@ typedef struct mac_output mac_output;
421 421
422#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints) 422#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints)
423 423
424/* This gives the w32_display_info structure for the display F is on. */ 424/* This gives the mac_display_info structure for the display F is on. */
425#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info) 425#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info)
426#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info) 426#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info)
427 427
@@ -627,6 +627,7 @@ extern OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int));
627extern void mac_clear_font_name_table P_ ((void)); 627extern void mac_clear_font_name_table P_ ((void));
628#if TARGET_API_MAC_CARBON 628#if TARGET_API_MAC_CARBON
629extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); 629extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
630extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
630extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); 631extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
631extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef)); 632extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef));
632extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef)); 633extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef));
diff --git a/src/sysdep.c b/src/sysdep.c
index f1345e591ab..e7494a2755d 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3803,7 +3803,6 @@ rmdir (dpath)
3803 3803
3804/* Functions for VMS */ 3804/* Functions for VMS */
3805#ifdef VMS 3805#ifdef VMS
3806#include "vms-pwd.h"
3807#include <acldef.h> 3806#include <acldef.h>
3808#include <chpdef.h> 3807#include <chpdef.h>
3809#include <jpidef.h> 3808#include <jpidef.h>
diff --git a/src/term.c b/src/term.c
index d53ba74c781..02099759b7a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1476,7 +1476,26 @@ static struct fkey_table keys[] =
1476 {"k6", "f6"}, 1476 {"k6", "f6"},
1477 {"k7", "f7"}, 1477 {"k7", "f7"},
1478 {"k8", "f8"}, 1478 {"k8", "f8"},
1479 {"k9", "f9"} 1479 {"k9", "f9"},
1480
1481 {"&0", "S-cancel"}, /*shifted cancel key*/
1482 {"&9", "S-begin"}, /*shifted begin key*/
1483 {"*0", "S-find"}, /*shifted find key*/
1484 {"*1", "S-execute"}, /*shifted execute? actually shifted command key*/
1485 {"*4", "S-delete"}, /*shifted delete-character key*/
1486 {"*7", "S-end"}, /*shifted end key*/
1487 {"*8", "S-clearline"}, /*shifted clear-to end-of-line key*/
1488 {"#1", "S-help"}, /*shifted help key*/
1489 {"#2", "S-home"}, /*shifted home key*/
1490 {"#3", "S-insert"}, /*shifted insert-character key*/
1491 {"#4", "S-left"}, /*shifted left-arrow key*/
1492 {"%d", "S-menu"}, /*shifted menu? actually shifted options key*/
1493 {"%c", "S-next"}, /*shifted next key*/
1494 {"%e", "S-prior"}, /*shifted previous key*/
1495 {"%f", "S-print"}, /*shifted print key*/
1496 {"%g", "S-redo"}, /*shifted redo key*/
1497 {"%i", "S-right"}, /*shifted right-arrow key*/
1498 {"!3", "S-undo"} /*shifted undo key*/
1480 }; 1499 };
1481 1500
1482static char **term_get_fkeys_arg; 1501static char **term_get_fkeys_arg;
diff --git a/src/window.c b/src/window.c
index ec69c5b9aa5..0cfd4162fd7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -286,7 +286,6 @@ make_window ()
286 p->fringes_outside_margins = Qnil; 286 p->fringes_outside_margins = Qnil;
287 p->scroll_bar_width = Qnil; 287 p->scroll_bar_width = Qnil;
288 p->vertical_scroll_bar_type = Qt; 288 p->vertical_scroll_bar_type = Qt;
289 p->overlay_arrow_bitmap = 0;
290 289
291 Vwindow_list = Qnil; 290 Vwindow_list = Qnil;
292 return val; 291 return val;
diff --git a/src/window.h b/src/window.h
index d8f98444ae9..d77e0a6f56f 100644
--- a/src/window.h
+++ b/src/window.h
@@ -259,9 +259,6 @@ struct window
259 /* This is handy for undrawing the cursor. */ 259 /* This is handy for undrawing the cursor. */
260 int phys_cursor_ascent, phys_cursor_height; 260 int phys_cursor_ascent, phys_cursor_height;
261 261
262 /* Alternate overlay-arrow-bitmap in this window. */
263 int overlay_arrow_bitmap;
264
265 /* Non-zero means the cursor is currently displayed. This can be 262 /* Non-zero means the cursor is currently displayed. This can be
266 set to zero by functions overpainting the cursor image. */ 263 set to zero by functions overpainting the cursor image. */
267 unsigned phys_cursor_on_p : 1; 264 unsigned phys_cursor_on_p : 1;
diff --git a/src/xdisp.c b/src/xdisp.c
index 13ef9b00abf..c1bd7acb2a0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -568,12 +568,21 @@ Lisp_Object Vmessage_log_max;
568 568
569static Lisp_Object Vmessages_buffer_name; 569static Lisp_Object Vmessages_buffer_name;
570 570
571/* Current, index 0, and last displayed echo area message. Either 571/* Index 0 is the buffer that holds the current (desired) echo area message,
572 buffers from echo_buffers, or nil to indicate no message. */ 572 or nil if none is desired right now.
573
574 Index 1 is the buffer that holds the previously displayed echo area message,
575 or nil to indicate no message. This is normally what's on the screen now.
576
577 These two can point to the same buffer. That happens when the last
578 message output by the user (or made by echoing) has been displayed. */
573 579
574Lisp_Object echo_area_buffer[2]; 580Lisp_Object echo_area_buffer[2];
575 581
576/* The buffers referenced from echo_area_buffer. */ 582/* Permanent pointers to the two buffers that are used for echo area
583 purposes. Once the two buffers are made, and their pointers are
584 placed here, these two slots remain unchanged unless those buffers
585 need to be created afresh. */
577 586
578static Lisp_Object echo_buffer[2]; 587static Lisp_Object echo_buffer[2];
579 588
@@ -2700,6 +2709,10 @@ handle_stop (it)
2700 it->dpvec = NULL; 2709 it->dpvec = NULL;
2701 it->current.dpvec_index = -1; 2710 it->current.dpvec_index = -1;
2702 2711
2712 /* Use face of preceding text for ellipsis (if invisible) */
2713 if (it->selective_display_ellipsis_p)
2714 it->saved_face_id = it->face_id;
2715
2703 do 2716 do
2704 { 2717 {
2705 handled = HANDLED_NORMALLY; 2718 handled = HANDLED_NORMALLY;
@@ -3377,8 +3390,11 @@ setup_for_ellipsis (it, len)
3377 it->dpvec_face_id = -1; 3390 it->dpvec_face_id = -1;
3378 3391
3379 /* Remember the current face id in case glyphs specify faces. 3392 /* Remember the current face id in case glyphs specify faces.
3380 IT's face is restored in set_iterator_to_next. */ 3393 IT's face is restored in set_iterator_to_next.
3381 it->saved_face_id = it->face_id; 3394 saved_face_id was set to preceding char's face in handle_stop. */
3395 if (it->saved_face_id < 0 || it->saved_face_id != it->face_id)
3396 it->saved_face_id = it->face_id = DEFAULT_FACE_ID;
3397
3382 it->method = GET_FROM_DISPLAY_VECTOR; 3398 it->method = GET_FROM_DISPLAY_VECTOR;
3383 it->ellipsis_p = 1; 3399 it->ellipsis_p = 1;
3384} 3400}
@@ -5514,6 +5530,8 @@ next_element_from_display_vector (it)
5514 /* Precondition. */ 5530 /* Precondition. */
5515 xassert (it->dpvec && it->current.dpvec_index >= 0); 5531 xassert (it->dpvec && it->current.dpvec_index >= 0);
5516 5532
5533 it->face_id = it->saved_face_id;
5534
5517 if (INTEGERP (*it->dpvec) 5535 if (INTEGERP (*it->dpvec)
5518 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec))) 5536 && GLYPH_CHAR_VALID_P (XFASTINT (*it->dpvec)))
5519 { 5537 {
@@ -7328,10 +7346,6 @@ ensure_echo_area_buffers ()
7328 WHICH > 0 means use echo_area_buffer[1]. If that is nil, choose a 7346 WHICH > 0 means use echo_area_buffer[1]. If that is nil, choose a
7329 suitable buffer from echo_buffer[] and clear it. 7347 suitable buffer from echo_buffer[] and clear it.
7330 7348
7331 If WHICH < 0, set echo_area_buffer[1] to echo_area_buffer[0], so
7332 that the current message becomes the last displayed one, make
7333 choose a suitable buffer for echo_area_buffer[0], and clear it.
7334
7335 Value is what FN returns. */ 7349 Value is what FN returns. */
7336 7350
7337static int 7351static int
@@ -7356,17 +7370,6 @@ with_echo_area_buffer (w, which, fn, a1, a2, a3, a4)
7356 this_one = 0, the_other = 1; 7370 this_one = 0, the_other = 1;
7357 else if (which > 0) 7371 else if (which > 0)
7358 this_one = 1, the_other = 0; 7372 this_one = 1, the_other = 0;
7359 else
7360 {
7361 this_one = 0, the_other = 1;
7362 clear_buffer_p = 1;
7363
7364 /* We need a fresh one in case the current echo buffer equals
7365 the one containing the last displayed echo area message. */
7366 if (!NILP (echo_area_buffer[this_one])
7367 && EQ (echo_area_buffer[this_one], echo_area_buffer[the_other]))
7368 echo_area_buffer[this_one] = Qnil;
7369 }
7370 7373
7371 /* Choose a suitable buffer from echo_buffer[] is we don't 7374 /* Choose a suitable buffer from echo_buffer[] is we don't
7372 have one. */ 7375 have one. */
@@ -7986,7 +7989,7 @@ set_message (s, string, nbytes, multibyte_p)
7986 = ((s && multibyte_p) 7989 = ((s && multibyte_p)
7987 || (STRINGP (string) && STRING_MULTIBYTE (string))); 7990 || (STRINGP (string) && STRING_MULTIBYTE (string)));
7988 7991
7989 with_echo_area_buffer (0, -1, set_message_1, 7992 with_echo_area_buffer (0, 0, set_message_1,
7990 (EMACS_INT) s, string, nbytes, multibyte_p); 7993 (EMACS_INT) s, string, nbytes, multibyte_p);
7991 message_buf_print = 0; 7994 message_buf_print = 0;
7992 help_echo_showing_p = 0; 7995 help_echo_showing_p = 0;
@@ -8018,6 +8021,7 @@ set_message_1 (a1, a2, nbytes, multibyte_p)
8018 8021
8019 /* Insert new message at BEG. */ 8022 /* Insert new message at BEG. */
8020 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); 8023 TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
8024 Ferase_buffer ();
8021 8025
8022 if (STRINGP (string)) 8026 if (STRINGP (string))
8023 { 8027 {
@@ -8235,10 +8239,8 @@ echo_area_display (update_frame_p)
8235 else if (!EQ (mini_window, selected_window)) 8239 else if (!EQ (mini_window, selected_window))
8236 windows_or_buffers_changed++; 8240 windows_or_buffers_changed++;
8237 8241
8238 /* Last displayed message is now the current message. */ 8242 /* The current message is now also the last one displayed. */
8239 echo_area_buffer[1] = echo_area_buffer[0]; 8243 echo_area_buffer[1] = echo_area_buffer[0];
8240 /* Inform read_char that we're not echoing. */
8241 echo_message_buffer = Qnil;
8242 8244
8243 /* Prevent redisplay optimization in redisplay_internal by resetting 8245 /* Prevent redisplay optimization in redisplay_internal by resetting
8244 this_line_start_pos. This is done because the mini-buffer now 8246 this_line_start_pos. This is done because the mini-buffer now
@@ -9762,22 +9764,14 @@ redisplay ()
9762 9764
9763 9765
9764static Lisp_Object 9766static Lisp_Object
9765overlay_arrow_string_or_property (var, pbitmap) 9767overlay_arrow_string_or_property (var)
9766 Lisp_Object var; 9768 Lisp_Object var;
9767 int *pbitmap;
9768{ 9769{
9769 Lisp_Object pstr = Fget (var, Qoverlay_arrow_string); 9770 Lisp_Object val;
9770 Lisp_Object bitmap;
9771 9771
9772 if (pbitmap) 9772 if (val = Fget (var, Qoverlay_arrow_string), STRINGP (val))
9773 { 9773 return val;
9774 *pbitmap = 0;
9775 if (bitmap = Fget (var, Qoverlay_arrow_bitmap), INTEGERP (bitmap))
9776 *pbitmap = XINT (bitmap);
9777 }
9778 9774
9779 if (!NILP (pstr))
9780 return pstr;
9781 return Voverlay_arrow_string; 9775 return Voverlay_arrow_string;
9782} 9776}
9783 9777
@@ -9827,7 +9821,7 @@ overlay_arrows_changed_p ()
9827 continue; 9821 continue;
9828 if (! EQ (COERCE_MARKER (val), 9822 if (! EQ (COERCE_MARKER (val),
9829 Fget (var, Qlast_arrow_position)) 9823 Fget (var, Qlast_arrow_position))
9830 || ! (pstr = overlay_arrow_string_or_property (var, 0), 9824 || ! (pstr = overlay_arrow_string_or_property (var),
9831 EQ (pstr, Fget (var, Qlast_arrow_string)))) 9825 EQ (pstr, Fget (var, Qlast_arrow_string))))
9832 return 1; 9826 return 1;
9833 } 9827 }
@@ -9857,7 +9851,7 @@ update_overlay_arrows (up_to_date)
9857 Fput (var, Qlast_arrow_position, 9851 Fput (var, Qlast_arrow_position,
9858 COERCE_MARKER (val)); 9852 COERCE_MARKER (val));
9859 Fput (var, Qlast_arrow_string, 9853 Fput (var, Qlast_arrow_string,
9860 overlay_arrow_string_or_property (var, 0)); 9854 overlay_arrow_string_or_property (var));
9861 } 9855 }
9862 else if (up_to_date < 0 9856 else if (up_to_date < 0
9863 || !NILP (Fget (var, Qlast_arrow_position))) 9857 || !NILP (Fget (var, Qlast_arrow_position)))
@@ -9870,14 +9864,13 @@ update_overlay_arrows (up_to_date)
9870 9864
9871 9865
9872/* Return overlay arrow string to display at row. 9866/* Return overlay arrow string to display at row.
9873 Return t if display as bitmap in left fringe. 9867 Return integer (bitmap number) for arrow bitmap in left fringe.
9874 Return nil if no overlay arrow. */ 9868 Return nil if no overlay arrow. */
9875 9869
9876static Lisp_Object 9870static Lisp_Object
9877overlay_arrow_at_row (it, row, pbitmap) 9871overlay_arrow_at_row (it, row)
9878 struct it *it; 9872 struct it *it;
9879 struct glyph_row *row; 9873 struct glyph_row *row;
9880 int *pbitmap;
9881{ 9874{
9882 Lisp_Object vlist; 9875 Lisp_Object vlist;
9883 9876
@@ -9897,17 +9890,21 @@ overlay_arrow_at_row (it, row, pbitmap)
9897 && current_buffer == XMARKER (val)->buffer 9890 && current_buffer == XMARKER (val)->buffer
9898 && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val))) 9891 && (MATRIX_ROW_START_CHARPOS (row) == marker_position (val)))
9899 { 9892 {
9900 val = overlay_arrow_string_or_property (var, pbitmap);
9901 if (FRAME_WINDOW_P (it->f) 9893 if (FRAME_WINDOW_P (it->f)
9902 && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0) 9894 && WINDOW_LEFT_FRINGE_WIDTH (it->w) > 0)
9903 return Qt; 9895 {
9904 if (STRINGP (val)) 9896 if (val = Fget (var, Qoverlay_arrow_bitmap), SYMBOLP (val))
9905 return val; 9897 {
9906 break; 9898 int fringe_bitmap;
9899 if ((fringe_bitmap = lookup_fringe_bitmap (val)) != 0)
9900 return make_number (fringe_bitmap);
9901 }
9902 return make_number (-1); /* Use default arrow bitmap */
9903 }
9904 return overlay_arrow_string_or_property (var);
9907 } 9905 }
9908 } 9906 }
9909 9907
9910 *pbitmap = 0;
9911 return Qnil; 9908 return Qnil;
9912} 9909}
9913 9910
@@ -14954,7 +14951,6 @@ display_line (it)
14954 struct it *it; 14951 struct it *it;
14955{ 14952{
14956 struct glyph_row *row = it->glyph_row; 14953 struct glyph_row *row = it->glyph_row;
14957 int overlay_arrow_bitmap;
14958 Lisp_Object overlay_arrow_string; 14954 Lisp_Object overlay_arrow_string;
14959 14955
14960 /* We always start displaying at hpos zero even if hscrolled. */ 14956 /* We always start displaying at hpos zero even if hscrolled. */
@@ -15362,9 +15358,9 @@ display_line (it)
15362 mark this glyph row as the one containing the overlay arrow. 15358 mark this glyph row as the one containing the overlay arrow.
15363 This is clearly a mess with variable size fonts. It would be 15359 This is clearly a mess with variable size fonts. It would be
15364 better to let it be displayed like cursors under X. */ 15360 better to let it be displayed like cursors under X. */
15365 if ((overlay_arrow_string 15361 if ((row->displays_text_p || !overlay_arrow_seen)
15366 = overlay_arrow_at_row (it, row, &overlay_arrow_bitmap), 15362 && (overlay_arrow_string = overlay_arrow_at_row (it, row),
15367 !NILP (overlay_arrow_string))) 15363 !NILP (overlay_arrow_string)))
15368 { 15364 {
15369 /* Overlay arrow in window redisplay is a fringe bitmap. */ 15365 /* Overlay arrow in window redisplay is a fringe bitmap. */
15370 if (STRINGP (overlay_arrow_string)) 15366 if (STRINGP (overlay_arrow_string))
@@ -15394,8 +15390,8 @@ display_line (it)
15394 } 15390 }
15395 else 15391 else
15396 { 15392 {
15397 it->w->overlay_arrow_bitmap = overlay_arrow_bitmap; 15393 xassert (INTEGERP (overlay_arrow_string));
15398 row->overlay_arrow_p = 1; 15394 row->overlay_arrow_bitmap = XINT (overlay_arrow_string);
15399 } 15395 }
15400 overlay_arrow_seen = 1; 15396 overlay_arrow_seen = 1;
15401 } 15397 }
diff --git a/src/xfaces.c b/src/xfaces.c
index dfe17b9513e..4709d1cb285 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -3274,17 +3274,19 @@ resolve_face_name (face_name)
3274 Lisp_Object face_name; 3274 Lisp_Object face_name;
3275{ 3275{
3276 Lisp_Object aliased; 3276 Lisp_Object aliased;
3277 int alias_loop_max = 10;
3277 3278
3278 if (STRINGP (face_name)) 3279 if (STRINGP (face_name))
3279 face_name = intern (SDATA (face_name)); 3280 face_name = intern (SDATA (face_name));
3280 3281
3281 while (SYMBOLP (face_name)) 3282 while (SYMBOLP (face_name))
3282 { 3283 {
3283 aliased = Fget (face_name, Qface_alias); 3284 aliased = Fsafe_get (face_name, Qface_alias);
3284 if (NILP (aliased)) 3285 if (NILP (aliased))
3285 break; 3286 break;
3286 else 3287 if (--alias_loop_max == 0)
3287 face_name = aliased; 3288 break;
3289 face_name = aliased;
3288 } 3290 }
3289 3291
3290 return face_name; 3292 return face_name;
@@ -7301,8 +7303,9 @@ realize_x_face (cache, attrs)
7301 struct face_cache *cache; 7303 struct face_cache *cache;
7302 Lisp_Object *attrs; 7304 Lisp_Object *attrs;
7303{ 7305{
7306 struct face *face = NULL;
7304#ifdef HAVE_WINDOW_SYSTEM 7307#ifdef HAVE_WINDOW_SYSTEM
7305 struct face *face, *default_face; 7308 struct face *default_face;
7306 struct frame *f; 7309 struct frame *f;
7307 Lisp_Object stipple, overline, strike_through, box; 7310 Lisp_Object stipple, overline, strike_through, box;
7308 7311
@@ -7476,9 +7479,9 @@ realize_x_face (cache, attrs)
7476 stipple = attrs[LFACE_STIPPLE_INDEX]; 7479 stipple = attrs[LFACE_STIPPLE_INDEX];
7477 if (!NILP (stipple)) 7480 if (!NILP (stipple))
7478 face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h); 7481 face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h);
7482#endif /* HAVE_WINDOW_SYSTEM */
7479 7483
7480 return face; 7484 return face;
7481#endif /* HAVE_WINDOW_SYSTEM */
7482} 7485}
7483 7486
7484 7487
diff --git a/src/xmenu.c b/src/xmenu.c
index e369d04743c..7d34c627692 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -771,7 +771,7 @@ cached information about equivalent key sequences. */)
771 Lisp_Object keymap, tem; 771 Lisp_Object keymap, tem;
772 int xpos = 0, ypos = 0; 772 int xpos = 0, ypos = 0;
773 Lisp_Object title; 773 Lisp_Object title;
774 char *error_name; 774 char *error_name = NULL;
775 Lisp_Object selection; 775 Lisp_Object selection;
776 FRAME_PTR f = NULL; 776 FRAME_PTR f = NULL;
777 Lisp_Object x, y, window; 777 Lisp_Object x, y, window;
@@ -2483,7 +2483,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2483 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i)) 2483 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
2484 break; 2484 break;
2485 } 2485 }
2486 2486
2487 /* Display the menu. */ 2487 /* Display the menu. */
2488 gtk_widget_show_all (menu); 2488 gtk_widget_show_all (menu);
2489 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0); 2489 gtk_menu_popup (GTK_MENU (menu), 0, 0, pos_func, &popup_x_y, i, 0);
@@ -2601,7 +2601,7 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click)
2601 /* Display the menu. */ 2601 /* Display the menu. */
2602 lw_popup_menu (menu, (XEvent *) &dummy); 2602 lw_popup_menu (menu, (XEvent *) &dummy);
2603 popup_activated_flag = 1; 2603 popup_activated_flag = 1;
2604 2604
2605 { 2605 {
2606 int fact = 4 * sizeof (LWLIB_ID); 2606 int fact = 4 * sizeof (LWLIB_ID);
2607 int specpdl_count = SPECPDL_INDEX (); 2607 int specpdl_count = SPECPDL_INDEX ();
@@ -3225,7 +3225,7 @@ pop_down_menu (arg)
3225{ 3225{
3226 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg)); 3226 struct Lisp_Save_Value *p1 = XSAVE_VALUE (Fcar (arg));
3227 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg)); 3227 struct Lisp_Save_Value *p2 = XSAVE_VALUE (Fcdr (arg));
3228 3228
3229 FRAME_PTR f = p1->pointer; 3229 FRAME_PTR f = p1->pointer;
3230 XMenu *menu = p2->pointer; 3230 XMenu *menu = p2->pointer;
3231 3231
@@ -3459,7 +3459,7 @@ xmenu_show (f, x, y, for_click, keymaps, title, error)
3459#ifndef MSDOS 3459#ifndef MSDOS
3460 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f)); 3460 XMenuActivateSetWaitFunction (x_menu_wait_for_event, FRAME_X_DISPLAY (f));
3461#endif 3461#endif
3462 3462
3463 record_unwind_protect (pop_down_menu, 3463 record_unwind_protect (pop_down_menu,
3464 Fcons (make_save_value (f, 0), 3464 Fcons (make_save_value (f, 0),
3465 make_save_value (menu, 0))); 3465 make_save_value (menu, 0)));
diff --git a/src/xrdb.c b/src/xrdb.c
index 852fa2b808c..957227b7942 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -53,9 +53,7 @@ Boston, MA 02111-1307, USA. */
53#include <X11/X.h> 53#include <X11/X.h>
54#include <X11/Xutil.h> 54#include <X11/Xutil.h>
55#include <X11/Xresource.h> 55#include <X11/Xresource.h>
56#ifdef VMS 56#ifdef HAVE_PWD_H
57#include "vms-pwd.h"
58#else
59#include <pwd.h> 57#include <pwd.h>
60#endif 58#endif
61#include <sys/stat.h> 59#include <sys/stat.h>