aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-04-19 16:23:46 +0000
committerKaroly Lorentey2006-04-19 16:23:46 +0000
commit447b0165acd09060977e05c843f81c0bee4aa4df (patch)
tree70cf2d254760a2cf68a10b67f8a3570c05fff9a5 /src
parent4c57cca724993ab1334cc5c0b35c22b06daee0c3 (diff)
parent0fea1d10293b4c6d35c1e55b68cd26e91445213c (diff)
downloademacs-447b0165acd09060977e05c843f81c0bee4aa4df.tar.gz
emacs-447b0165acd09060977e05c843f81c0bee4aa4df.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-216 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-217 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-218 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-219 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-220 Improve tq.el. * emacs@sv.gnu.org/emacs--devo--0--patch-221 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-222 Update from CVS: src/puresize.h (PURESIZE_RATIO): Reduce to 10/6. * emacs@sv.gnu.org/emacs--devo--0--patch-223 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-224 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-225 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-226 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-227 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-228 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-229 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-230 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-231 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-232 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-233 Update from CVS: lisp/progmodes/python.el (python-mode): Fix typo. * emacs@sv.gnu.org/gnus--rel--5.10--patch-84 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-85 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-86 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-550
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog191
-rw-r--r--src/abbrev.c26
-rw-r--r--src/coding.c19
-rw-r--r--src/dispnew.c2
-rw-r--r--src/eval.c1
-rw-r--r--src/fns.c7
-rw-r--r--src/image.c29
-rw-r--r--src/keyboard.c1
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h33
-rw-r--r--src/mac.c125
-rw-r--r--src/macfns.c49
-rw-r--r--src/macmenu.c2
-rw-r--r--src/macselect.c121
-rw-r--r--src/macterm.c516
-rw-r--r--src/macterm.h28
-rw-r--r--src/print.c3
-rw-r--r--src/process.c14
-rw-r--r--src/puresize.h2
-rw-r--r--src/s/ms-w32.h6
-rw-r--r--src/unexmacosx.c9
-rw-r--r--src/window.c63
-rw-r--r--src/xdisp.c7
-rw-r--r--src/xfaces.c40
-rw-r--r--src/xmenu.c66
25 files changed, 759 insertions, 603 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 936b14089b4..f0f504e6e64 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,194 @@
12006-04-18 Richard Stallman <rms@gnu.org>
2
3 * xmenu.c (restore_menu_items, save_menu_items): New fns.
4 (set_frame_menubar): Use save_menu_items. Save updated vector in
5 the frame before unwinding it. Don't use unuse_menu_items. Don't
6 use discard_menu_items.
7 (digest_single_submenu): Abort if an item is not in a pane.
8 (init_menu_items): Put the error check at the top.
9
10 * keymap.c (describe_map): Make "shadowed" warning more verbose.
11
12 * window.c (adjust_window_trailing_edge): Correctly distinguish
13 series vs parallel cases, even when window has no parent.
14
15 * abbrev.c (record_symbol): New function.
16 (Finsert_abbrev_table_description): Sort the abbrevs alphabetically.
17
182006-04-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
19
20 * image.c (x_create_bitmap_from_data) [MAC_OS]: Don't check return
21 value of xmalloc.
22
23 * mac.c (mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
24 (create_apple_event_from_event_ref, xrm_get_preference_database)
25 (cfstring_create_normalized): Don't check return value of xmalloc.
26
27 * macselect.c (get_scrap_target_type_list, defer_apple_events)
28 (copy_scrap_flavor_data, mac_handle_service_event): Don't check
29 return value of xmalloc/xrealloc.
30
31 * macterm.c (XCreateGC, x_per_char_metric, xlfdpat_create)
32 (init_font_name_table, init_font_name_table, mac_do_list_fonts)
33 (XLoadQueryFont, mac_store_apple_event): Don't check
34 return value of xmalloc.
35
362006-04-17 Kim F. Storm <storm@cua.dk>
37
38 * window.c (coordinates_in_window): On the vertical border,
39 calculate the row number measured from the top of the window, not
40 the top of the frame.
41 (window_loop): Test w->dedicated with !NILP instead of EQ Qt.
42 (window_scroll_pixel_based): Fix off-by-one bug in 2002-12-23 change.
43
442006-04-16 Eli Zaretskii <eliz@gnu.org>
45
46 * s/ms-w32.h (SYSTEM_PURESIZE_EXTRA): Reduce to 24000.
47
482006-04-16 Romain Francoise <romain@orebokech.com>
49
50 * puresize.h (BASE_PURESIZE): Decrement back to 1200000.
51
522006-04-16 Andreas Schwab <schwab@suse.de>
53
54 * puresize.h (PURESIZE_RATIO): Reduce to 10/6.
55
562006-04-15 Romain Francoise <romain@orebokech.com>
57
58 * puresize.h (BASE_PURESIZE): Increment to 1210000.
59
602006-04-13 Micha,Ak(Bl Cadilhac <michael.cadilhac@lrde.org> (tiny change)
61
62 * print.c (Fprin1_to_string): Mention in the `doc' that the
63 behavior is modified by `print-level' and `print-length'.
64
652006-04-13 Kenichi Handa <handa@m17n.org>
66
67 * coding.c (setup_coding_system): If eol-type is not yet decided
68 and system_eol_type is not LF, set CODING_REQUIRE_ENCODING_MASK.
69 If coding_system is nil, return 0.
70 (code_convert_region1): Even if coding_system is nil, don't skip
71 conversion if system_eol_type is not LF.
72 (code_convert_string1): Likewise.
73 (code_convert_string_norecord): Likewise.
74
752006-04-13 Kenichi Handa <handa@m17n.org>
76
77 * coding.c (setup_coding_system): Fix previous change.
78 (encode_coding): If eol_type is not yet decided, use
79 system_eol_type.
80 (shrink_encoding_region): If eol_type is not yet decided and
81 system_eol_type is not LF, don't shrink.
82
832006-04-13 Nick Roberts <nickrob@snap.net.nz>
84
85 * xdisp.c (note_mouse_highlight): Add help echo for dragging vertical
86 line.
87
882006-04-12 Richard Stallman <rms@gnu.org>
89
90 * keyboard.c (read_key_sequence): Explicitly avoid keybuf[-1].
91
92 * process.c (conv_lisp_to_sockaddr): If FAMILY unknown, just return.
93 (Fprocess_send_eof): Abort if fail to open null device.
94
952006-04-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
96
97 * fns.c [HAVE_MENUS && MAC_OS]: Include macterm.h.
98
99 * image.c [MAC_OS] (xpm_load_image): Add parentheses around
100 assignment used as truth value. Add explicit braces to avoid
101 ambiguous `else'.
102 [MAC_OS] (gif_load): Remove unused variable `gcpro1'.
103
104 * lisp.h (syms_of_fontset, Fset_fontset_font): Put extern and
105 EXFUN in #ifdef HAVE_WINDOW_SYSTEM.
106 (syms_of_xfns, syms_of_xsmfns, syms_of_xselect, syms_of_xterm):
107 Put externs in #ifdef HAVE_X_WINDOWS.
108 (syms_of_macfns, syms_of_macselect, syms_of_macterm)
109 (syms_of_macmenu, syms_of_mac) [MAC_OS]: Add externs.
110 (init_mac_osx_environment) [MAC_OSX]: Add extern.
111
112 * mac.c (init_process): Remove undef.
113 (select) [MAC_OSX]: Undefine before including sysselect.h.
114 (posix_pathname_to_fsspec, fsspec_to_posix_pathname) [MAC_OSX]:
115 Remove functions and prototypes.
116 (parse_value): Add parentheses around + inside shift.
117 (path_from_vol_dir_name): Make static.
118 (get_temp_dir_name): Remove unused variables `cpb' and `dir_name'.
119 [!MAC_OSX] (get_path_to_system_folder): Likewise.
120 (Fmac_get_file_creator, Fmac_get_file_type): Remove unused
121 variable `cCode'.
122 (Fmac_coerce_ae_data): Remove unused variables `fref' and `fs'.
123 (Fmac_get_preference): Add explicit braces to avoid ambiguous `else'.
124
125 * macfns.c (x_to_mac_color): Remove unused variable `tail'.
126 (x_set_mouse_color): Remove unused variable `dpy'.
127 (Fx_create_frame): Remove unused variable `x_frame_count'.
128 (Fx_server_version): Add explicit braces to avoid ambiguous `else'.
129 (x_sync): Move from macterm.c.
130 (Fx_file_dialog): Remove unused variable `default_filter_index'.
131
132 * macmenu.c (min_menu_id): Make element type explicit.
133
134 * macselect.c (get_flavor_type_from_symbol): Remove unused
135 variable `val'.
136 (get_scrap_private_timestamp, x_get_foreign_selection)
137 (copy_scrap_flavor_data): Add explicit braces to avoid ambiguous `else'.
138 (Fmac_process_deferred_apple_events): Remove unused variables
139 `keyword', `reply', `apple_event', `count', and `err'.
140
141 * macterm.c: Don't include gnu.h.
142 (x_io_error_quitter, x_draw_image_foreground_1): Remove prototypes.
143 (x_sync): Move to macfns.c.
144 [USE_CG_DRAWING] (mac_define_fringe_bitmap): Remove unused
145 variable `mask_bits'.
146 (mac_compute_glyph_string_overhangs): Avoid ambiguous `else'.
147 (x_draw_image_glyph_string): Remove unused variable `pixmap'.
148 (x_mac_to_emacs_modifiers): Remove function.
149 (XTset_vertical_scroll_bar, mac_handle_visibility_change)
150 (x_make_frame_visible, xlfdpat_create, mac_handle_command_event):
151 Add explicit braces to avoid ambiguous `else'.
152 (x_make_frame_visible): Remove unused variables `type',
153 `original_top', and `original_left'.
154 (mac_do_list_fonts, XTread_socket): Add parentheses around && within ||.
155 (x_load_font): Remove unused variables `full_name', and `value'.
156 (do_get_menus, do_init_managers, do_check_ram_size) [!MAC_OS8]:
157 Remove functions.
158 (do_zoom_window): Reorganize variables with respect to conditionals.
159 (init_command_handler): Remove unused variable `err'.
160 [MAC_OSX] (mac_check_bundle): Remove unused variable `child'.
161
162 * macterm.h (x_set_mouse_position, x_set_mouse_pixel_position)
163 (x_make_frame_invisible, x_iconify_frame, x_free_frame_resources)
164 (x_destroy_window, x_wm_set_size_hint, x_delete_display, XFreeGC)
165 (do_menu_choice, have_menus_p, x_real_positions)
166 (x_set_menu_bar_lines, x_pixel_width, x_pixel_height, x_char_width)
167 (x_char_height, x_sync, x_set_tool_bar_lines, x_activate_menubar)
168 (free_frame_menubar): Add externs.
169
170 * unexmacosx.c: Include config.h before using HAVE_MALLOC_MALLOC_H.
171 (malloc, realloc, free): Add undefs.
172 (read_load_commands): Remove unused variable `n' and `j'.
173 (copy_data_segment): Remove unused variable `r'.
174
175 * xdisp.c (get_glyph_string_clip_rects): Add parentheses around &&
176 within ||. Add explicit braces to avoid ambiguous `else'.
177 (dump_glyph_row): Remove label for `inverse_p' from legend.
178
179 * xfaces.c (Finternal_merge_in_global_face, try_font_list): Add
180 explicit braces to avoid ambiguous `else'.
181
1822006-04-11 Micha,Ak(Bl Cadilhac <michael.cadilhac@lrde.org> (tiny change)
183
184 * dispnew.c (init_display): Don't init X display if the user asked
185 for a non-X display.
186
1872006-04-12 Kenichi Handa <handa@m17n.org>
188
189 * coding.c (setup_coding_system): Use system_eol_type for default
190 coding->eol_type.
191
12006-04-11 Dan Nicolaescu <dann@ics.uci.edu> 1922006-04-11 Dan Nicolaescu <dann@ics.uci.edu>
2 193
3 * lisp.h (wrong_type_argument): Mark as NO_RETURN. 194 * lisp.h (wrong_type_argument): Mark as NO_RETURN.
diff --git a/src/abbrev.c b/src/abbrev.c
index e7dcec3a43a..e371797f139 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -531,6 +531,13 @@ describe_abbrev (sym, stream)
531 Fterpri (stream); 531 Fterpri (stream);
532} 532}
533 533
534static void
535record_symbol (sym, list)
536 Lisp_Object sym, list;
537{
538 XSETCDR (list, Fcons (sym, XCDR (list)));
539}
540
534DEFUN ("insert-abbrev-table-description", Finsert_abbrev_table_description, 541DEFUN ("insert-abbrev-table-description", Finsert_abbrev_table_description,
535 Sinsert_abbrev_table_description, 1, 2, 0, 542 Sinsert_abbrev_table_description, 1, 2, 0,
536 doc: /* Insert before point a full description of abbrev table named NAME. 543 doc: /* Insert before point a full description of abbrev table named NAME.
@@ -546,6 +553,7 @@ READABLE is non-nil, they are listed. */)
546 Lisp_Object name, readable; 553 Lisp_Object name, readable;
547{ 554{
548 Lisp_Object table; 555 Lisp_Object table;
556 Lisp_Object symbols;
549 Lisp_Object stream; 557 Lisp_Object stream;
550 558
551 CHECK_SYMBOL (name); 559 CHECK_SYMBOL (name);
@@ -554,12 +562,22 @@ READABLE is non-nil, they are listed. */)
554 562
555 XSETBUFFER (stream, current_buffer); 563 XSETBUFFER (stream, current_buffer);
556 564
565 symbols = Fcons (Qnil, Qnil);
566 map_obarray (table, record_symbol, symbols);
567 symbols = XCDR (symbols);
568 symbols = Fsort (symbols, Qstring_lessp);
569
557 if (!NILP (readable)) 570 if (!NILP (readable))
558 { 571 {
559 insert_string ("("); 572 insert_string ("(");
560 Fprin1 (name, stream); 573 Fprin1 (name, stream);
561 insert_string (")\n\n"); 574 insert_string (")\n\n");
562 map_obarray (table, describe_abbrev, stream); 575 while (! NILP (symbols))
576 {
577 describe_abbrev (XCAR (symbols), stream);
578 symbols = XCDR (symbols);
579 }
580
563 insert_string ("\n\n"); 581 insert_string ("\n\n");
564 } 582 }
565 else 583 else
@@ -567,7 +585,11 @@ READABLE is non-nil, they are listed. */)
567 insert_string ("(define-abbrev-table '"); 585 insert_string ("(define-abbrev-table '");
568 Fprin1 (name, stream); 586 Fprin1 (name, stream);
569 insert_string (" '(\n"); 587 insert_string (" '(\n");
570 map_obarray (table, write_abbrev, stream); 588 while (! NILP (symbols))
589 {
590 write_abbrev (XCAR (symbols), stream);
591 symbols = XCDR (symbols);
592 }
571 insert_string (" ))\n\n"); 593 insert_string (" ))\n\n");
572 } 594 }
573 595
diff --git a/src/coding.c b/src/coding.c
index 26d47da9317..d261418def5 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -3603,6 +3603,8 @@ setup_coding_system (coding_system, coding)
3603 { 3603 {
3604 coding->eol_type = CODING_EOL_UNDECIDED; 3604 coding->eol_type = CODING_EOL_UNDECIDED;
3605 coding->common_flags = CODING_REQUIRE_DETECTION_MASK; 3605 coding->common_flags = CODING_REQUIRE_DETECTION_MASK;
3606 if (system_eol_type != CODING_EOL_LF)
3607 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK;
3606 } 3608 }
3607 else if (XFASTINT (eol_type) == 1) 3609 else if (XFASTINT (eol_type) == 1)
3608 { 3610 {
@@ -3918,9 +3920,12 @@ setup_coding_system (coding_system, coding)
3918 coding->type = coding_type_no_conversion; 3920 coding->type = coding_type_no_conversion;
3919 coding->category_idx = CODING_CATEGORY_IDX_BINARY; 3921 coding->category_idx = CODING_CATEGORY_IDX_BINARY;
3920 coding->common_flags = 0; 3922 coding->common_flags = 0;
3921 coding->eol_type = CODING_EOL_LF; 3923 coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF;
3924 if (coding->eol_type != CODING_EOL_LF)
3925 coding->common_flags
3926 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK;
3922 coding->pre_write_conversion = coding->post_read_conversion = Qnil; 3927 coding->pre_write_conversion = coding->post_read_conversion = Qnil;
3923 return -1; 3928 return NILP (coding_system) ? 0 : -1;
3924} 3929}
3925 3930
3926/* Free memory blocks allocated for storing composition information. */ 3931/* Free memory blocks allocated for storing composition information. */
@@ -4994,6 +4999,8 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes)
4994 coding->consumed = coding->consumed_char = 0; 4999 coding->consumed = coding->consumed_char = 0;
4995 coding->errors = 0; 5000 coding->errors = 0;
4996 coding->result = CODING_FINISH_NORMAL; 5001 coding->result = CODING_FINISH_NORMAL;
5002 if (coding->eol_type == CODING_EOL_UNDECIDED)
5003 coding->eol_type = system_eol_type;
4997 5004
4998 switch (coding->type) 5005 switch (coding->type)
4999 { 5006 {
@@ -5250,6 +5257,8 @@ shrink_encoding_region (beg, end, coding, str)
5250 if (coding->type == coding_type_ccl 5257 if (coding->type == coding_type_ccl
5251 || coding->eol_type == CODING_EOL_CRLF 5258 || coding->eol_type == CODING_EOL_CRLF
5252 || coding->eol_type == CODING_EOL_CR 5259 || coding->eol_type == CODING_EOL_CR
5260 || (coding->eol_type == CODING_EOL_UNDECIDED
5261 && system_eol_type != CODING_EOL_LF)
5253 || (coding->cmp_data && coding->cmp_data->used > 0)) 5262 || (coding->cmp_data && coding->cmp_data->used > 0))
5254 { 5263 {
5255 /* We can't skip any data. */ 5264 /* We can't skip any data. */
@@ -7105,7 +7114,7 @@ code_convert_region1 (start, end, coding_system, encodep)
7105 from = XFASTINT (start); 7114 from = XFASTINT (start);
7106 to = XFASTINT (end); 7115 to = XFASTINT (end);
7107 7116
7108 if (NILP (coding_system)) 7117 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
7109 return make_number (to - from); 7118 return make_number (to - from);
7110 7119
7111 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7120 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7160,7 +7169,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep)
7160 CHECK_STRING (string); 7169 CHECK_STRING (string);
7161 CHECK_SYMBOL (coding_system); 7170 CHECK_SYMBOL (coding_system);
7162 7171
7163 if (NILP (coding_system)) 7172 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
7164 return (NILP (nocopy) ? Fcopy_sequence (string) : string); 7173 return (NILP (nocopy) ? Fcopy_sequence (string) : string);
7165 7174
7166 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7175 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7219,7 +7228,7 @@ code_convert_string_norecord (string, coding_system, encodep)
7219 CHECK_STRING (string); 7228 CHECK_STRING (string);
7220 CHECK_SYMBOL (coding_system); 7229 CHECK_SYMBOL (coding_system);
7221 7230
7222 if (NILP (coding_system)) 7231 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF)
7223 return string; 7232 return string;
7224 7233
7225 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7234 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
diff --git a/src/dispnew.c b/src/dispnew.c
index 296dbece477..9b4dbf1d992 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6695,7 +6695,7 @@ init_display ()
6695 try to use X, and die with an error message if that doesn't work. */ 6695 try to use X, and die with an error message if that doesn't work. */
6696 6696
6697#ifdef HAVE_X_WINDOWS 6697#ifdef HAVE_X_WINDOWS
6698 if (! display_arg) 6698 if (! inhibit_window_system && ! display_arg)
6699 { 6699 {
6700 char *display; 6700 char *display;
6701#ifdef VMS 6701#ifdef VMS
diff --git a/src/eval.c b/src/eval.c
index 86ee384896c..20f29b5f06b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -204,6 +204,7 @@ init_eval_once ()
204 specpdl_size = 50; 204 specpdl_size = 50;
205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding)); 205 specpdl = (struct specbinding *) xmalloc (specpdl_size * sizeof (struct specbinding));
206 specpdl_ptr = specpdl; 206 specpdl_ptr = specpdl;
207 /* Don't forget to update docs (lispref node "Local Variables"). */
207 max_specpdl_size = 1000; 208 max_specpdl_size = 1000;
208 max_lisp_eval_depth = 300; 209 max_lisp_eval_depth = 300;
209 210
diff --git a/src/fns.c b/src/fns.c
index 0608fee2df6..f06f39fae04 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -48,9 +48,12 @@ Boston, MA 02110-1301, USA. */
48#include "frame.h" 48#include "frame.h"
49#include "window.h" 49#include "window.h"
50#include "blockinput.h" 50#include "blockinput.h"
51#include "termhooks.h" /* For display->kboard reference in terminal-local-value. */ 51#ifdef HAVE_MENUS
52#if defined (HAVE_MENUS) && defined (HAVE_X_WINDOWS) 52#if defined (HAVE_X_WINDOWS)
53#include "xterm.h" 53#include "xterm.h"
54#elif defined (MAC_OS)
55#include "macterm.h"
56#endif
54#endif 57#endif
55 58
56#ifndef NULL 59#ifndef NULL
diff --git a/src/image.c b/src/image.c
index 0d52399327e..a6b3c8f19c5 100644
--- a/src/image.c
+++ b/src/image.c
@@ -201,7 +201,7 @@ XPutPixel (ximage, x, y, pixel)
201 } 201 }
202 else 202 else
203#endif 203#endif
204 if (depth == 1) 204 if (depth == 1)
205 { 205 {
206 char *base_addr = GetPixBaseAddr (pixmap); 206 char *base_addr = GetPixBaseAddr (pixmap);
207 short row_bytes = GetPixRowBytes (pixmap); 207 short row_bytes = GetPixRowBytes (pixmap);
@@ -444,8 +444,6 @@ x_create_bitmap_from_data (f, bits, width, height)
444 id = x_allocate_bitmap_record (f); 444 id = x_allocate_bitmap_record (f);
445#ifdef MAC_OS 445#ifdef MAC_OS
446 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width); 446 dpyinfo->bitmaps[id - 1].bitmap_data = (char *) xmalloc (height * width);
447 if (! dpyinfo->bitmaps[id - 1].bitmap_data)
448 return -1;
449 bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width); 447 bcopy (bits, dpyinfo->bitmaps[id - 1].bitmap_data, height * width);
450#endif /* MAC_OS */ 448#endif /* MAC_OS */
451 449
@@ -4381,7 +4379,7 @@ xpm_load_image (f, img, contents, end)
4381 if (color == NULL) 4379 if (color == NULL)
4382 goto failure; 4380 goto failure;
4383 4381
4384 while (str = strtok (NULL, " \t")) 4382 while ((str = strtok (NULL, " \t")) != NULL)
4385 { 4383 {
4386 next_key = xpm_str_to_color_key (str); 4384 next_key = xpm_str_to_color_key (str);
4387 if (next_key >= 0) 4385 if (next_key >= 0)
@@ -4409,17 +4407,21 @@ xpm_load_image (f, img, contents, end)
4409 Lisp_Object specified_color = Fassoc (symbol_color, color_symbols); 4407 Lisp_Object specified_color = Fassoc (symbol_color, color_symbols);
4410 4408
4411 if (CONSP (specified_color) && STRINGP (XCDR (specified_color))) 4409 if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
4412 if (xstricmp (SDATA (XCDR (specified_color)), "None") == 0) 4410 {
4413 color_val = Qt; 4411 if (xstricmp (SDATA (XCDR (specified_color)), "None") == 0)
4414 else if (x_defined_color (f, SDATA (XCDR (specified_color)), 4412 color_val = Qt;
4415 &cdef, 0)) 4413 else if (x_defined_color (f, SDATA (XCDR (specified_color)),
4416 color_val = make_number (cdef.pixel); 4414 &cdef, 0))
4415 color_val = make_number (cdef.pixel);
4416 }
4417 } 4417 }
4418 if (NILP (color_val) && max_key > 0) 4418 if (NILP (color_val) && max_key > 0)
4419 if (xstricmp (max_color, "None") == 0) 4419 {
4420 color_val = Qt; 4420 if (xstricmp (max_color, "None") == 0)
4421 else if (x_defined_color (f, max_color, &cdef, 0)) 4421 color_val = Qt;
4422 color_val = make_number (cdef.pixel); 4422 else if (x_defined_color (f, max_color, &cdef, 0))
4423 color_val = make_number (cdef.pixel);
4424 }
4423 if (!NILP (color_val)) 4425 if (!NILP (color_val))
4424 (*put_color_table) (color_table, beg, chars_per_pixel, color_val); 4426 (*put_color_table) (color_table, beg, chars_per_pixel, color_val);
4425 4427
@@ -7848,7 +7850,6 @@ gif_load (f, img)
7848 int width, height; 7850 int width, height;
7849 XImagePtr ximg; 7851 XImagePtr ximg;
7850 TimeValue time; 7852 TimeValue time;
7851 struct gcpro gcpro1;
7852 int ino; 7853 int ino;
7853 CGrafPtr old_port; 7854 CGrafPtr old_port;
7854 GDHandle old_gdh; 7855 GDHandle old_gdh;
diff --git a/src/keyboard.c b/src/keyboard.c
index dff14877103..1ad852c819a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -9684,6 +9684,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
9684 /* Don't downcase the last character if the caller says don't. 9684 /* Don't downcase the last character if the caller says don't.
9685 Don't downcase it if the result is undefined, either. */ 9685 Don't downcase it if the result is undefined, either. */
9686 if ((dont_downcase_last || first_binding >= nmaps) 9686 if ((dont_downcase_last || first_binding >= nmaps)
9687 && t > 0
9687 && t - 1 == original_uppercase_position) 9688 && t - 1 == original_uppercase_position)
9688 keybuf[t - 1] = original_uppercase; 9689 keybuf[t - 1] = original_uppercase;
9689 9690
diff --git a/src/keymap.c b/src/keymap.c
index af881d73ccd..5962dfc2efd 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -3365,7 +3365,7 @@ describe_map (map, prefix, elt_describer, partial, shadow,
3365 if (vect[i].shadowed) 3365 if (vect[i].shadowed)
3366 { 3366 {
3367 SET_PT (PT - 1); 3367 SET_PT (PT - 1);
3368 insert_string (" (shadowed)"); 3368 insert_string ("\n (that binding is currently shadowed by another mode)");
3369 SET_PT (PT + 1); 3369 SET_PT (PT + 1);
3370 } 3370 }
3371 } 3371 }
diff --git a/src/lisp.h b/src/lisp.h
index 468b699fb06..0df41a0d1f4 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3209,10 +3209,14 @@ extern void fatal () NO_RETURN;
3209/* Defined in terminal.c */ 3209/* Defined in terminal.c */
3210extern void syms_of_terminal P_ ((void)); 3210extern void syms_of_terminal P_ ((void));
3211 3211
3212#ifdef HAVE_X_WINDOWS 3212#ifdef HAVE_WINDOW_SYSTEM
3213/* Defined in fontset.c */ 3213/* Defined in fontset.c */
3214extern void syms_of_fontset P_ ((void)); 3214extern void syms_of_fontset P_ ((void));
3215EXFUN (Fset_fontset_font, 4); 3215EXFUN (Fset_fontset_font, 4);
3216
3217/* Defined in xfns.c, w32fns.c, or macfns.c */
3218EXFUN (Fxw_display_color_p, 1);
3219EXFUN (Fx_file_dialog, 5);
3216#endif 3220#endif
3217 3221
3218/* Defined in xfaces.c */ 3222/* Defined in xfaces.c */
@@ -3226,12 +3230,6 @@ extern int getloadavg P_ ((double *, int));
3226#ifdef HAVE_X_WINDOWS 3230#ifdef HAVE_X_WINDOWS
3227/* Defined in xfns.c */ 3231/* Defined in xfns.c */
3228extern void syms_of_xfns P_ ((void)); 3232extern void syms_of_xfns P_ ((void));
3229#endif /* HAVE_X_WINDOWS */
3230#ifdef HAVE_WINDOW_SYSTEM
3231/* Defined in xfns.c, w32fns.c, or macfns.c */
3232EXFUN (Fxw_display_color_p, 1);
3233EXFUN (Fx_file_dialog, 5);
3234#endif /* HAVE_WINDOW_SYSTEM */
3235 3233
3236/* Defined in xsmfns.c */ 3234/* Defined in xsmfns.c */
3237extern void syms_of_xsmfns P_ ((void)); 3235extern void syms_of_xsmfns P_ ((void));
@@ -3241,11 +3239,32 @@ extern void syms_of_xselect P_ ((void));
3241 3239
3242/* Defined in xterm.c */ 3240/* Defined in xterm.c */
3243extern void syms_of_xterm P_ ((void)); 3241extern void syms_of_xterm P_ ((void));
3242#endif /* HAVE_X_WINDOWS */
3244 3243
3245#ifdef MSDOS 3244#ifdef MSDOS
3246/* Defined in msdos.c */ 3245/* Defined in msdos.c */
3247EXFUN (Fmsdos_downcase_filename, 1); 3246EXFUN (Fmsdos_downcase_filename, 1);
3248#endif 3247#endif
3248
3249#ifdef MAC_OS
3250/* Defined in macfns.c */
3251extern void syms_of_macfns P_ ((void));
3252
3253/* Defined in macselect.c */
3254extern void syms_of_macselect P_ ((void));
3255
3256/* Defined in macterm.c */
3257extern void syms_of_macterm P_ ((void));
3258
3259/* Defined in macmenu.c */
3260extern void syms_of_macmenu P_ ((void));
3261
3262/* Defined in mac.c */
3263extern void syms_of_mac P_ ((void));
3264#ifdef MAC_OSX
3265extern void init_mac_osx_environment P_ ((void));
3266#endif /* MAC_OSX */
3267#endif /* MAC_OS */
3249 3268
3250/* Nonzero means Emacs has already been initialized. 3269/* Nonzero means Emacs has already been initialized.
3251 Used during startup to detect startup of dumped Emacs. */ 3270 Used during startup to detect startup of dumped Emacs. */
diff --git a/src/mac.c b/src/mac.c
index 40bbacf15ce..7172301b6b0 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -28,7 +28,9 @@ Boston, MA 02110-1301, USA. */
28 28
29#include "lisp.h" 29#include "lisp.h"
30#include "process.h" 30#include "process.h"
31#undef init_process 31#ifdef MAC_OSX
32#undef select
33#endif
32#include "systime.h" 34#include "systime.h"
33#include "sysselect.h" 35#include "sysselect.h"
34#include "blockinput.h" 36#include "blockinput.h"
@@ -79,8 +81,10 @@ static ComponentInstance as_scripting_component;
79/* The single script context used for all script executions. */ 81/* The single script context used for all script executions. */
80static OSAID as_script_context; 82static OSAID as_script_context;
81 83
84#ifndef MAC_OSX
82static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); 85static OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *));
83static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); 86static OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int));
87#endif
84 88
85/* When converting from Mac to Unix pathnames, /'s in folder names are 89/* When converting from Mac to Unix pathnames, /'s in folder names are
86 converted to :'s. This function, used in copying folder names, 90 converted to :'s. This function, used in copying folder names,
@@ -449,15 +453,10 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
449 char *buf; 453 char *buf;
450 454
451 buf = xmalloc (data_size + 1); 455 buf = xmalloc (data_size + 1);
452 if (buf) 456 memcpy (buf, data_ptr, data_size);
453 { 457 buf[data_size] = '\0';
454 memcpy (buf, data_ptr, data_size); 458 err = posix_pathname_to_fsspec (buf, &fs);
455 buf[data_size] = '\0'; 459 xfree (buf);
456 err = posix_pathname_to_fsspec (buf, &fs);
457 xfree (buf);
458 }
459 else
460 err = memFullErr;
461 if (err == noErr) 460 if (err == noErr)
462 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); 461 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
463#endif 462#endif
@@ -485,14 +484,11 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
485 { 484 {
486 size = AEGetDescDataSize (&desc); 485 size = AEGetDescDataSize (&desc);
487 buf = xmalloc (size); 486 buf = xmalloc (size);
488 if (buf) 487 err = AEGetDescData (&desc, buf, size);
489 { 488 if (err == noErr)
490 err = AEGetDescData (&desc, buf, size); 489 url = CFURLCreateWithBytes (NULL, buf, size,
491 if (err == noErr) 490 kCFStringEncodingUTF8, NULL);
492 url = CFURLCreateWithBytes (NULL, buf, size, 491 xfree (buf);
493 kCFStringEncodingUTF8, NULL);
494 xfree (buf);
495 }
496 AEDisposeDesc (&desc); 492 AEDisposeDesc (&desc);
497 } 493 }
498 } 494 }
@@ -577,21 +573,16 @@ mac_coerce_file_name_desc (from_desc, to_type, handler_refcon, result)
577 data_size = GetHandleSize (from_desc->dataHandle); 573 data_size = GetHandleSize (from_desc->dataHandle);
578#endif 574#endif
579 data_ptr = xmalloc (data_size); 575 data_ptr = xmalloc (data_size);
580 if (data_ptr)
581 {
582#if TARGET_API_MAC_CARBON 576#if TARGET_API_MAC_CARBON
583 err = AEGetDescData (from_desc, data_ptr, data_size); 577 err = AEGetDescData (from_desc, data_ptr, data_size);
584#else 578#else
585 memcpy (data_ptr, *(from_desc->dataHandle), data_size); 579 memcpy (data_ptr, *(from_desc->dataHandle), data_size);
586#endif 580#endif
587 if (err == noErr) 581 if (err == noErr)
588 err = mac_coerce_file_name_ptr (from_type, data_ptr, 582 err = mac_coerce_file_name_ptr (from_type, data_ptr,
589 data_size, to_type, 583 data_size, to_type,
590 handler_refcon, result); 584 handler_refcon, result);
591 xfree (data_ptr); 585 xfree (data_ptr);
592 }
593 else
594 err = memFullErr;
595 } 586 }
596 587
597 if (err != noErr) 588 if (err != noErr)
@@ -687,8 +678,6 @@ create_apple_event_from_event_ref (event, num_params, names, types, result)
687 if (err != noErr) 678 if (err != noErr)
688 break; 679 break;
689 buf = xmalloc (size); 680 buf = xmalloc (size);
690 if (buf == NULL)
691 break;
692 err = GetEventParameter (event, names[i], types[i], NULL, 681 err = GetEventParameter (event, names[i], types[i], NULL,
693 size, NULL, buf); 682 size, NULL, buf);
694 if (err == noErr) 683 if (err == noErr)
@@ -1222,7 +1211,7 @@ parse_value (p)
1222 && '0' <= P[1] && P[1] <= '7' 1211 && '0' <= P[1] && P[1] <= '7'
1223 && '0' <= P[2] && P[2] <= '7') 1212 && '0' <= P[2] && P[2] <= '7')
1224 { 1213 {
1225 *q++ = (P[0] - '0' << 6) + (P[1] - '0' << 3) + (P[2] - '0'); 1214 *q++ = ((P[0] - '0') << 6) + ((P[1] - '0') << 3) + (P[2] - '0');
1226 P += 3; 1215 P += 3;
1227 } 1216 }
1228 else 1217 else
@@ -1592,8 +1581,6 @@ xrm_get_preference_database (application)
1592 1581
1593 count = CFSetGetCount (key_set); 1582 count = CFSetGetCount (key_set);
1594 keys = xmalloc (sizeof (CFStringRef) * count); 1583 keys = xmalloc (sizeof (CFStringRef) * count);
1595 if (keys == NULL)
1596 goto out;
1597 CFSetGetValues (key_set, (const void **)keys); 1584 CFSetGetValues (key_set, (const void **)keys);
1598 for (index = 0; index < count; index++) 1585 for (index = 0; index < count; index++)
1599 { 1586 {
@@ -2789,7 +2776,7 @@ link (const char *name1, const char *name2)
2789/* Determine the path name of the file specified by VREFNUM, DIRID, 2776/* Determine the path name of the file specified by VREFNUM, DIRID,
2790 and NAME and place that in the buffer PATH of length 2777 and NAME and place that in the buffer PATH of length
2791 MAXPATHLEN. */ 2778 MAXPATHLEN. */
2792int 2779static int
2793path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num, 2780path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num,
2794 long dir_id, ConstStr255Param name) 2781 long dir_id, ConstStr255Param name)
2795{ 2782{
@@ -2834,6 +2821,8 @@ path_from_vol_dir_name (char *path, int man_path_len, short vol_ref_num,
2834} 2821}
2835 2822
2836 2823
2824#ifndef MAC_OSX
2825
2837static OSErr 2826static OSErr
2838posix_pathname_to_fsspec (ufn, fs) 2827posix_pathname_to_fsspec (ufn, fs)
2839 const char *ufn; 2828 const char *ufn;
@@ -2866,8 +2855,6 @@ fsspec_to_posix_pathname (fs, ufn, ufnbuflen)
2866 return fnfErr; 2855 return fnfErr;
2867} 2856}
2868 2857
2869#ifndef MAC_OSX
2870
2871int 2858int
2872readlink (const char *path, char *buf, int bufsiz) 2859readlink (const char *path, char *buf, int bufsiz)
2873{ 2860{
@@ -3124,8 +3111,7 @@ get_temp_dir_name ()
3124 short vol_ref_num; 3111 short vol_ref_num;
3125 long dir_id; 3112 long dir_id;
3126 OSErr err; 3113 OSErr err;
3127 Str255 dir_name, full_path; 3114 Str255 full_path;
3128 CInfoPBRec cpb;
3129 char unix_dir_name[MAXPATHLEN+1]; 3115 char unix_dir_name[MAXPATHLEN+1];
3130 DIR *dir; 3116 DIR *dir;
3131 3117
@@ -3217,8 +3203,7 @@ get_path_to_system_folder ()
3217 short vol_ref_num; 3203 short vol_ref_num;
3218 long dir_id; 3204 long dir_id;
3219 OSErr err; 3205 OSErr err;
3220 Str255 dir_name, full_path; 3206 Str255 full_path;
3221 CInfoPBRec cpb;
3222 static char system_folder_unix_name[MAXPATHLEN+1]; 3207 static char system_folder_unix_name[MAXPATHLEN+1];
3223 DIR *dir; 3208 DIR *dir;
3224 3209
@@ -3947,7 +3932,6 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1,
3947#else 3932#else
3948 FSSpec fss; 3933 FSSpec fss;
3949#endif 3934#endif
3950 OSType cCode;
3951 Lisp_Object result = Qnil; 3935 Lisp_Object result = Qnil;
3952 CHECK_STRING (filename); 3936 CHECK_STRING (filename);
3953 3937
@@ -4002,7 +3986,6 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
4002#else 3986#else
4003 FSSpec fss; 3987 FSSpec fss;
4004#endif 3988#endif
4005 OSType cCode;
4006 Lisp_Object result = Qnil; 3989 Lisp_Object result = Qnil;
4007 CHECK_STRING (filename); 3990 CHECK_STRING (filename);
4008 3991
@@ -4296,11 +4279,6 @@ Each type should be a string of length 4 or the symbol
4296 Lisp_Object result = Qnil; 4279 Lisp_Object result = Qnil;
4297 DescType src_desc_type, dst_desc_type; 4280 DescType src_desc_type, dst_desc_type;
4298 AEDesc dst_desc; 4281 AEDesc dst_desc;
4299#ifdef MAC_OSX
4300 FSRef fref;
4301#else
4302 FSSpec fs;
4303#endif
4304 4282
4305 CHECK_STRING (src_data); 4283 CHECK_STRING (src_data);
4306 if (EQ (src_type, Qundecoded_file_name)) 4284 if (EQ (src_type, Qundecoded_file_name))
@@ -4422,18 +4400,20 @@ otherwise. */)
4422 } 4400 }
4423 4401
4424 if (NILP (key)) 4402 if (NILP (key))
4425 if (EQ (format, Qxml)) 4403 {
4426 { 4404 if (EQ (format, Qxml))
4427 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist); 4405 {
4428 if (data == NULL) 4406 CFDataRef data = CFPropertyListCreateXMLData (NULL, plist);
4429 goto out; 4407 if (data == NULL)
4430 result = cfdata_to_lisp (data); 4408 goto out;
4431 CFRelease (data); 4409 result = cfdata_to_lisp (data);
4432 } 4410 CFRelease (data);
4433 else 4411 }
4434 result = 4412 else
4435 cfproperty_list_to_lisp (plist, EQ (format, Qt), 4413 result =
4436 NILP (hash_bound) ? -1 : XINT (hash_bound)); 4414 cfproperty_list_to_lisp (plist, EQ (format, Qt),
4415 NILP (hash_bound) ? -1 : XINT (hash_bound));
4416 }
4437 4417
4438 out: 4418 out:
4439 if (app_plist) 4419 if (app_plist)
@@ -4550,11 +4530,8 @@ cfstring_create_normalized (str, symbol)
4550 if (in_text == NULL) 4530 if (in_text == NULL)
4551 { 4531 {
4552 buffer = xmalloc (sizeof (UniChar) * length); 4532 buffer = xmalloc (sizeof (UniChar) * length);
4553 if (buffer) 4533 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4554 { 4534 in_text = buffer;
4555 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4556 in_text = buffer;
4557 }
4558 } 4535 }
4559 4536
4560 if (in_text) 4537 if (in_text)
@@ -4562,15 +4539,12 @@ cfstring_create_normalized (str, symbol)
4562 while (err == noErr) 4539 while (err == noErr)
4563 { 4540 {
4564 out_buf = xmalloc (out_size); 4541 out_buf = xmalloc (out_size);
4565 if (out_buf == NULL) 4542 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar),
4566 err = mFulErr; 4543 in_text,
4567 else 4544 kUnicodeDefaultDirectionMask,
4568 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), 4545 0, NULL, NULL, NULL,
4569 in_text, 4546 out_size, &out_read, &out_len,
4570 kUnicodeDefaultDirectionMask, 4547 out_buf);
4571 0, NULL, NULL, NULL,
4572 out_size, &out_read, &out_len,
4573 out_buf);
4574 if (err == noErr && out_read < length * sizeof (UniChar)) 4548 if (err == noErr && out_read < length * sizeof (UniChar))
4575 { 4549 {
4576 xfree (out_buf); 4550 xfree (out_buf);
@@ -4701,7 +4675,6 @@ mac_get_system_locale ()
4701 4675
4702 4676
4703#ifdef MAC_OSX 4677#ifdef MAC_OSX
4704#undef select
4705 4678
4706extern int inhibit_window_system; 4679extern int inhibit_window_system;
4707extern int noninteractive; 4680extern int noninteractive;
diff --git a/src/macfns.c b/src/macfns.c
index a6a5e99727a..3f5151daee9 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1024,7 +1024,7 @@ Lisp_Object
1024x_to_mac_color (colorname) 1024x_to_mac_color (colorname)
1025 char * colorname; 1025 char * colorname;
1026{ 1026{
1027 register Lisp_Object tail, ret = Qnil; 1027 register Lisp_Object ret = Qnil;
1028 1028
1029 BLOCK_INPUT; 1029 BLOCK_INPUT;
1030 1030
@@ -1359,7 +1359,6 @@ x_set_mouse_color (f, arg, oldval)
1359 Lisp_Object arg, oldval; 1359 Lisp_Object arg, oldval;
1360{ 1360{
1361 struct x_output *x = f->output_data.x; 1361 struct x_output *x = f->output_data.x;
1362 Display *dpy = FRAME_MAC_DISPLAY (f);
1363 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor; 1362 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
1364 Cursor hourglass_cursor, horizontal_drag_cursor; 1363 Cursor hourglass_cursor, horizontal_drag_cursor;
1365 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); 1364 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
@@ -2387,7 +2386,6 @@ This function is an internal primitive--use `make-frame' instead. */)
2387 struct mac_display_info *dpyinfo = NULL; 2386 struct mac_display_info *dpyinfo = NULL;
2388 Lisp_Object parent; 2387 Lisp_Object parent;
2389 struct kboard *kb; 2388 struct kboard *kb;
2390 static int x_frame_count = 2; /* begins at 2 because terminal frame is F1 */
2391 2389
2392 check_mac (); 2390 check_mac ();
2393 2391
@@ -2910,23 +2908,25 @@ If omitted or nil, that stands for the selected frame's display. */)
2910 BLOCK_INPUT; 2908 BLOCK_INPUT;
2911 err = Gestalt (gestaltSystemVersion, &response); 2909 err = Gestalt (gestaltSystemVersion, &response);
2912 if (err == noErr) 2910 if (err == noErr)
2913 if (response >= 0x00001040) 2911 {
2914 { 2912 if (response >= 0x00001040)
2915 err = Gestalt ('sys1', &major); /* gestaltSystemVersionMajor */ 2913 {
2916 if (err == noErr) 2914 err = Gestalt ('sys1', &major); /* gestaltSystemVersionMajor */
2917 err = Gestalt ('sys2', &minor); /* gestaltSystemVersionMinor */ 2915 if (err == noErr)
2918 if (err == noErr) 2916 err = Gestalt ('sys2', &minor); /* gestaltSystemVersionMinor */
2919 err = Gestalt ('sys3', &bugfix); /* gestaltSystemVersionBugFix */ 2917 if (err == noErr)
2920 } 2918 err = Gestalt ('sys3', &bugfix); /* gestaltSystemVersionBugFix */
2921 else 2919 }
2922 { 2920 else
2923 bugfix = response & 0xf; 2921 {
2924 response >>= 4; 2922 bugfix = response & 0xf;
2925 minor = response & 0xf; 2923 response >>= 4;
2926 response >>= 4; 2924 minor = response & 0xf;
2927 /* convert BCD to int */ 2925 response >>= 4;
2928 major = response - (response >> 4) * 6; 2926 /* convert BCD to int */
2929 } 2927 major = response - (response >> 4) * 6;
2928 }
2929 }
2930 UNBLOCK_INPUT; 2930 UNBLOCK_INPUT;
2931 2931
2932 if (err != noErr) 2932 if (err != noErr)
@@ -3210,6 +3210,14 @@ DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
3210 return Qnil; 3210 return Qnil;
3211} 3211}
3212 3212
3213/* x_sync is a no-op on Mac. */
3214
3215void
3216x_sync (f)
3217 FRAME_PTR f;
3218{
3219}
3220
3213 3221
3214/*********************************************************************** 3222/***********************************************************************
3215 Window properties 3223 Window properties
@@ -4187,7 +4195,6 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4187 int count = SPECPDL_INDEX (); 4195 int count = SPECPDL_INDEX ();
4188 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; 4196 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
4189 char filename[MAXPATHLEN]; 4197 char filename[MAXPATHLEN];
4190 int default_filter_index = 1; /* 1: All Files, 2: Directories only */
4191 static NavEventUPP mac_nav_event_callbackUPP = NULL; 4198 static NavEventUPP mac_nav_event_callbackUPP = NULL;
4192 4199
4193 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p); 4200 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
diff --git a/src/macmenu.c b/src/macmenu.c
index 8610ecafd94..29233ec0d64 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -72,7 +72,7 @@ enum mac_menu_kind { /* Menu ID range */
72 MAC_MENU_END /* 32768 */ 72 MAC_MENU_END /* 32768 */
73}; 73};
74 74
75static const min_menu_id[] = {0, 1, 235, 236, 256, 16384, 32768}; 75static const int min_menu_id[] = {0, 1, 235, 236, 256, 16384, 32768};
76 76
77#define DIALOG_WINDOW_RESOURCE 130 77#define DIALOG_WINDOW_RESOURCE 130
78 78
diff --git a/src/macselect.c b/src/macselect.c
index 066892adce0..fe4a7c8eccc 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -153,7 +153,6 @@ static ScrapFlavorType
153get_flavor_type_from_symbol (sym) 153get_flavor_type_from_symbol (sym)
154 Lisp_Object sym; 154 Lisp_Object sym;
155{ 155{
156 ScrapFlavorType val;
157 Lisp_Object str = Fget (sym, Qmac_ostype); 156 Lisp_Object str = Fget (sym, Qmac_ostype);
158 157
159 if (STRINGP (str) && SBYTES (str) == 4) 158 if (STRINGP (str) && SBYTES (str) == 4)
@@ -322,17 +321,19 @@ get_scrap_private_timestamp (scrap, timestamp)
322 321
323 err = GetScrapFlavorFlags (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &flags); 322 err = GetScrapFlavorFlags (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &flags);
324 if (err == noErr) 323 if (err == noErr)
325 if (!(flags & kScrapFlavorMaskSenderOnly)) 324 {
326 err = noTypeErr; 325 if (!(flags & kScrapFlavorMaskSenderOnly))
327 else 326 err = noTypeErr;
328 { 327 else
329 Size size = sizeof (*timestamp); 328 {
329 Size size = sizeof (*timestamp);
330 330
331 err = GetScrapFlavorData (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, 331 err = GetScrapFlavorData (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
332 &size, timestamp); 332 &size, timestamp);
333 if (err == noErr && size != sizeof (*timestamp)) 333 if (err == noErr && size != sizeof (*timestamp))
334 err = noTypeErr; 334 err = noTypeErr;
335 } 335 }
336 }
336#else /* !TARGET_API_MAC_CARBON */ 337#else /* !TARGET_API_MAC_CARBON */
337 Handle handle; 338 Handle handle;
338 SInt32 size, offset; 339 SInt32 size, offset;
@@ -372,14 +373,11 @@ get_scrap_target_type_list (scrap)
372 err = GetScrapFlavorCount (scrap, &count); 373 err = GetScrapFlavorCount (scrap, &count);
373 if (err == noErr) 374 if (err == noErr)
374 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); 375 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
375 if (flavor_info) 376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info);
377 if (err != noErr)
376 { 378 {
377 err = GetScrapFlavorInfoList (scrap, &count, flavor_info); 379 xfree (flavor_info);
378 if (err != noErr) 380 flavor_info = NULL;
379 {
380 xfree (flavor_info);
381 flavor_info = NULL;
382 }
383 } 381 }
384 if (flavor_info == NULL) 382 if (flavor_info == NULL)
385 count = 0; 383 count = 0;
@@ -683,18 +681,20 @@ x_get_foreign_selection (selection_symbol, target_type, time_stamp)
683 681
684 err = get_scrap_from_symbol (selection_symbol, 0, &scrap); 682 err = get_scrap_from_symbol (selection_symbol, 0, &scrap);
685 if (err == noErr && scrap) 683 if (err == noErr && scrap)
686 if (EQ (target_type, QTARGETS)) 684 {
687 { 685 if (EQ (target_type, QTARGETS))
688 result = get_scrap_target_type_list (scrap); 686 {
689 result = Fvconcat (1, &result); 687 result = get_scrap_target_type_list (scrap);
690 } 688 result = Fvconcat (1, &result);
691 else 689 }
692 { 690 else
693 result = get_scrap_string (scrap, target_type); 691 {
694 if (STRINGP (result)) 692 result = get_scrap_string (scrap, target_type);
695 Fput_text_property (make_number (0), make_number (SBYTES (result)), 693 if (STRINGP (result))
696 Qforeign_selection, target_type, result); 694 Fput_text_property (make_number (0), make_number (SBYTES (result)),
697 } 695 Qforeign_selection, target_type, result);
696 }
697 }
698 698
699 UNBLOCK_INPUT; 699 UNBLOCK_INPUT;
700 700
@@ -1009,7 +1009,7 @@ defer_apple_events (apple_event, reply)
1009 /* Mac OS 10.3 Xcode manual says AESuspendTheCurrentEvent makes 1009 /* Mac OS 10.3 Xcode manual says AESuspendTheCurrentEvent makes
1010 copies of the Apple event and the reply, but Mac OS 10.4 Xcode 1010 copies of the Apple event and the reply, but Mac OS 10.4 Xcode
1011 manual says it doesn't. Anyway we create copies of them and save 1011 manual says it doesn't. Anyway we create copies of them and save
1012 it in `deferred_apple_events'. */ 1012 them in `deferred_apple_events'. */
1013 if (err == noErr) 1013 if (err == noErr)
1014 { 1014 {
1015 if (deferred_apple_events.buf == NULL) 1015 if (deferred_apple_events.buf == NULL)
@@ -1018,20 +1018,13 @@ defer_apple_events (apple_event, reply)
1018 deferred_apple_events.count = 0; 1018 deferred_apple_events.count = 0;
1019 deferred_apple_events.buf = 1019 deferred_apple_events.buf =
1020 xmalloc (sizeof (AppleEvent) * deferred_apple_events.size); 1020 xmalloc (sizeof (AppleEvent) * deferred_apple_events.size);
1021 if (deferred_apple_events.buf == NULL)
1022 err = memFullErr;
1023 } 1021 }
1024 else if (deferred_apple_events.count == deferred_apple_events.size) 1022 else if (deferred_apple_events.count == deferred_apple_events.size)
1025 { 1023 {
1026 AppleEvent *newbuf;
1027
1028 deferred_apple_events.size *= 2; 1024 deferred_apple_events.size *= 2;
1029 newbuf = xrealloc (deferred_apple_events.buf, 1025 deferred_apple_events.buf
1030 sizeof (AppleEvent) * deferred_apple_events.size); 1026 = xrealloc (deferred_apple_events.buf,
1031 if (newbuf) 1027 sizeof (AppleEvent) * deferred_apple_events.size);
1032 deferred_apple_events.buf = newbuf;
1033 else
1034 err = memFullErr;
1035 } 1028 }
1036 } 1029 }
1037 1030
@@ -1123,11 +1116,8 @@ DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events,
1123 doc: /* Process Apple events that are deferred at the startup time. */) 1116 doc: /* Process Apple events that are deferred at the startup time. */)
1124 () 1117 ()
1125{ 1118{
1126 OSErr err;
1127 Lisp_Object result = Qnil; 1119 Lisp_Object result = Qnil;
1128 long i, count; 1120 long i;
1129 AppleEvent apple_event, reply;
1130 AEKeyword keyword;
1131 1121
1132 if (mac_ready_for_apple_events) 1122 if (mac_ready_for_apple_events)
1133 return Qnil; 1123 return Qnil;
@@ -1192,29 +1182,21 @@ copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
1192 buf = NULL; 1182 buf = NULL;
1193 } 1183 }
1194 else if (size_allocated < size) 1184 else if (size_allocated < size)
1195 { 1185 buf = xrealloc (buf, size);
1196 char *newbuf = xrealloc (buf, size);
1197
1198 if (newbuf)
1199 buf = newbuf;
1200 else
1201 {
1202 xfree (buf);
1203 buf = NULL;
1204 }
1205 }
1206 else 1186 else
1207 break; 1187 break;
1208 } 1188 }
1209 if (err == noErr) 1189 if (err == noErr)
1210 if (buf == NULL) 1190 {
1211 err = memFullErr; 1191 if (buf == NULL)
1212 else 1192 err = memFullErr;
1213 { 1193 else
1214 err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone, 1194 {
1215 size, buf); 1195 err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone,
1216 xfree (buf); 1196 size, buf);
1217 } 1197 xfree (buf);
1198 }
1199 }
1218 1200
1219 return err; 1201 return err;
1220} 1202}
@@ -1300,14 +1282,11 @@ mac_handle_service_event (call_ref, event, data)
1300 err = GetScrapFlavorCount (cur_scrap, &count); 1282 err = GetScrapFlavorCount (cur_scrap, &count);
1301 if (err == noErr) 1283 if (err == noErr)
1302 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); 1284 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
1303 if (flavor_info) 1285 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info);
1286 if (err != noErr)
1304 { 1287 {
1305 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info); 1288 xfree (flavor_info);
1306 if (err != noErr) 1289 flavor_info = NULL;
1307 {
1308 xfree (flavor_info);
1309 flavor_info = NULL;
1310 }
1311 } 1290 }
1312 if (flavor_info == NULL) 1291 if (flavor_info == NULL)
1313 break; 1292 break;
diff --git a/src/macterm.c b/src/macterm.c
index 7c946a9fd3f..5696f13e5a0 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -77,7 +77,6 @@ Boston, MA 02110-1301, USA. */
77#include "termhooks.h" 77#include "termhooks.h"
78#include "termopts.h" 78#include "termopts.h"
79#include "termchar.h" 79#include "termchar.h"
80#include "gnu.h"
81#include "disptab.h" 80#include "disptab.h"
82#include "buffer.h" 81#include "buffer.h"
83#include "window.h" 82#include "window.h"
@@ -215,7 +214,6 @@ QDGlobals qd; /* QuickDraw global information structure. */
215 214
216struct mac_display_info *mac_display_info_for_display (Display *); 215struct mac_display_info *mac_display_info_for_display (Display *);
217static void x_update_window_end P_ ((struct window *, int, int)); 216static void x_update_window_end P_ ((struct window *, int, int));
218static int x_io_error_quitter P_ ((Display *));
219int x_catch_errors P_ ((Display *)); 217int x_catch_errors P_ ((Display *));
220void x_uncatch_errors P_ ((Display *, int)); 218void x_uncatch_errors P_ ((Display *, int));
221void x_lower_frame P_ ((struct frame *)); 219void x_lower_frame P_ ((struct frame *));
@@ -1510,11 +1508,8 @@ XCreateGC (display, window, mask, xgcv)
1510{ 1508{
1511 GC gc = xmalloc (sizeof (*gc)); 1509 GC gc = xmalloc (sizeof (*gc));
1512 1510
1513 if (gc) 1511 bzero (gc, sizeof (*gc));
1514 { 1512 XChangeGC (display, gc, mask, xgcv);
1515 bzero (gc, sizeof (*gc));
1516 XChangeGC (display, gc, mask, xgcv);
1517 }
1518 1513
1519 return gc; 1514 return gc;
1520} 1515}
@@ -1697,14 +1692,6 @@ XSetWindowBackground (display, w, color)
1697#endif 1692#endif
1698} 1693}
1699 1694
1700/* x_sync is a no-op on Mac. */
1701void
1702x_sync (f)
1703 void *f;
1704{
1705}
1706
1707
1708/* Flush display of frame F, or of all frames if F is null. */ 1695/* Flush display of frame F, or of all frames if F is null. */
1709 1696
1710static void 1697static void
@@ -2080,7 +2067,6 @@ mac_define_fringe_bitmap (which, bits, h, wd)
2080 unsigned short *bits; 2067 unsigned short *bits;
2081 int h, wd; 2068 int h, wd;
2082{ 2069{
2083 unsigned short *mask_bits;
2084 int i; 2070 int i;
2085 CGDataProviderRef provider; 2071 CGDataProviderRef provider;
2086 2072
@@ -2171,21 +2157,17 @@ x_per_char_metric (font, char2b)
2171 if (*row == NULL) 2157 if (*row == NULL)
2172 { 2158 {
2173 *row = xmalloc (sizeof (XCharStructRow)); 2159 *row = xmalloc (sizeof (XCharStructRow));
2174 if (*row) 2160 bzero (*row, sizeof (XCharStructRow));
2175 bzero (*row, sizeof (XCharStructRow));
2176 } 2161 }
2177 if (*row) 2162 pcm = (*row)->per_char + char2b->byte2;
2163 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2))
2178 { 2164 {
2179 pcm = (*row)->per_char + char2b->byte2; 2165 BLOCK_INPUT;
2180 if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2)) 2166 mac_query_char_extents (font->mac_style,
2181 { 2167 (char2b->byte1 << 8) + char2b->byte2,
2182 BLOCK_INPUT; 2168 NULL, NULL, pcm, NULL);
2183 mac_query_char_extents (font->mac_style, 2169 UNBLOCK_INPUT;
2184 (char2b->byte1 << 8) + char2b->byte2, 2170 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
2185 NULL, NULL, pcm, NULL);
2186 UNBLOCK_INPUT;
2187 XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2);
2188 }
2189 } 2171 }
2190 } 2172 }
2191 else 2173 else
@@ -2366,7 +2348,6 @@ static void x_setup_relief_colors P_ ((struct glyph_string *));
2366static void x_draw_image_glyph_string P_ ((struct glyph_string *)); 2348static void x_draw_image_glyph_string P_ ((struct glyph_string *));
2367static void x_draw_image_relief P_ ((struct glyph_string *)); 2349static void x_draw_image_relief P_ ((struct glyph_string *));
2368static void x_draw_image_foreground P_ ((struct glyph_string *)); 2350static void x_draw_image_foreground P_ ((struct glyph_string *));
2369static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
2370static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 2351static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
2371 int, int, int)); 2352 int, int, int));
2372static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 2353static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
@@ -2567,34 +2548,36 @@ static void
2567mac_compute_glyph_string_overhangs (s) 2548mac_compute_glyph_string_overhangs (s)
2568 struct glyph_string *s; 2549 struct glyph_string *s;
2569{ 2550{
2570 if (s->cmp == NULL 2551 if (!(s->cmp == NULL
2571 && s->first_glyph->type == CHAR_GLYPH) 2552 && s->first_glyph->type == CHAR_GLYPH))
2572 if (!s->two_byte_p 2553 return;
2554
2555 if (!s->two_byte_p
2573#if USE_ATSUI 2556#if USE_ATSUI
2574 || s->font->mac_style 2557 || s->font->mac_style
2575#endif 2558#endif
2576 ) 2559 )
2577 { 2560 {
2578 XCharStruct cs; 2561 XCharStruct cs;
2579 2562
2580 mac_text_extents_16 (s->font, s->char2b, s->nchars, &cs); 2563 mac_text_extents_16 (s->font, s->char2b, s->nchars, &cs);
2581 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0; 2564 s->right_overhang = cs.rbearing > cs.width ? cs.rbearing - cs.width : 0;
2582 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0; 2565 s->left_overhang = cs.lbearing < 0 ? -cs.lbearing : 0;
2583 } 2566 }
2584 else 2567 else
2585 { 2568 {
2586 Rect r; 2569 Rect r;
2587 MacFontStruct *font = s->font; 2570 MacFontStruct *font = s->font;
2588 2571
2589 TextFont (font->mac_fontnum); 2572 TextFont (font->mac_fontnum);
2590 TextSize (font->mac_fontsize); 2573 TextSize (font->mac_fontsize);
2591 TextFace (font->mac_fontface); 2574 TextFace (font->mac_fontface);
2592 2575
2593 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r); 2576 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
2594 2577
2595 s->right_overhang = r.right > s->width ? r.right - s->width : 0; 2578 s->right_overhang = r.right > s->width ? r.right - s->width : 0;
2596 s->left_overhang = r.left < 0 ? -r.left : 0; 2579 s->left_overhang = r.left < 0 ? -r.left : 0;
2597 } 2580 }
2598} 2581}
2599 2582
2600 2583
@@ -3430,7 +3413,6 @@ x_draw_image_glyph_string (s)
3430 int box_line_hwidth = abs (s->face->box_line_width); 3413 int box_line_hwidth = abs (s->face->box_line_width);
3431 int box_line_vwidth = max (s->face->box_line_width, 0); 3414 int box_line_vwidth = max (s->face->box_line_width, 0);
3432 int height; 3415 int height;
3433 Pixmap pixmap = 0;
3434 3416
3435 height = s->height - 2 * box_line_vwidth; 3417 height = s->height - 2 * box_line_vwidth;
3436 3418
@@ -4176,142 +4158,6 @@ x_frame_rehighlight (dpyinfo)
4176 4158
4177 4159
4178 4160
4179/* Keyboard processing - modifier keys, vendor-specific keysyms, etc. */
4180
4181#if 0 /* MAC_TODO */
4182/* Initialize mode_switch_bit and modifier_meaning. */
4183static void
4184x_find_modifier_meanings (dpyinfo)
4185 struct x_display_info *dpyinfo;
4186{
4187 int min_code, max_code;
4188 KeySym *syms;
4189 int syms_per_code;
4190 XModifierKeymap *mods;
4191
4192 dpyinfo->meta_mod_mask = 0;
4193 dpyinfo->shift_lock_mask = 0;
4194 dpyinfo->alt_mod_mask = 0;
4195 dpyinfo->super_mod_mask = 0;
4196 dpyinfo->hyper_mod_mask = 0;
4197
4198#ifdef HAVE_X11R4
4199 XDisplayKeycodes (dpyinfo->display, &min_code, &max_code);
4200#else
4201 min_code = dpyinfo->display->min_keycode;
4202 max_code = dpyinfo->display->max_keycode;
4203#endif
4204
4205 syms = XGetKeyboardMapping (dpyinfo->display,
4206 min_code, max_code - min_code + 1,
4207 &syms_per_code);
4208 mods = XGetModifierMapping (dpyinfo->display);
4209
4210 /* Scan the modifier table to see which modifier bits the Meta and
4211 Alt keysyms are on. */
4212 {
4213 int row, col; /* The row and column in the modifier table. */
4214
4215 for (row = 3; row < 8; row++)
4216 for (col = 0; col < mods->max_keypermod; col++)
4217 {
4218 KeyCode code
4219 = mods->modifiermap[(row * mods->max_keypermod) + col];
4220
4221 /* Zeroes are used for filler. Skip them. */
4222 if (code == 0)
4223 continue;
4224
4225 /* Are any of this keycode's keysyms a meta key? */
4226 {
4227 int code_col;
4228
4229 for (code_col = 0; code_col < syms_per_code; code_col++)
4230 {
4231 int sym = syms[((code - min_code) * syms_per_code) + code_col];
4232
4233 switch (sym)
4234 {
4235 case XK_Meta_L:
4236 case XK_Meta_R:
4237 dpyinfo->meta_mod_mask |= (1 << row);
4238 break;
4239
4240 case XK_Alt_L:
4241 case XK_Alt_R:
4242 dpyinfo->alt_mod_mask |= (1 << row);
4243 break;
4244
4245 case XK_Hyper_L:
4246 case XK_Hyper_R:
4247 dpyinfo->hyper_mod_mask |= (1 << row);
4248 break;
4249
4250 case XK_Super_L:
4251 case XK_Super_R:
4252 dpyinfo->super_mod_mask |= (1 << row);
4253 break;
4254
4255 case XK_Shift_Lock:
4256 /* Ignore this if it's not on the lock modifier. */
4257 if ((1 << row) == LockMask)
4258 dpyinfo->shift_lock_mask = LockMask;
4259 break;
4260 }
4261 }
4262 }
4263 }
4264 }
4265
4266 /* If we couldn't find any meta keys, accept any alt keys as meta keys. */
4267 if (! dpyinfo->meta_mod_mask)
4268 {
4269 dpyinfo->meta_mod_mask = dpyinfo->alt_mod_mask;
4270 dpyinfo->alt_mod_mask = 0;
4271 }
4272
4273 /* If some keys are both alt and meta,
4274 make them just meta, not alt. */
4275 if (dpyinfo->alt_mod_mask & dpyinfo->meta_mod_mask)
4276 {
4277 dpyinfo->alt_mod_mask &= ~dpyinfo->meta_mod_mask;
4278 }
4279
4280 XFree ((char *) syms);
4281 XFreeModifiermap (mods);
4282}
4283
4284#endif /* MAC_TODO */
4285
4286/* Convert between the modifier bits X uses and the modifier bits
4287 Emacs uses. */
4288
4289static unsigned int
4290x_mac_to_emacs_modifiers (dpyinfo, state)
4291 struct x_display_info *dpyinfo;
4292 unsigned short state;
4293{
4294 return (((state & shiftKey) ? shift_modifier : 0)
4295 | ((state & controlKey) ? ctrl_modifier : 0)
4296 | ((state & cmdKey) ? meta_modifier : 0)
4297 | ((state & optionKey) ? alt_modifier : 0));
4298}
4299
4300#if 0 /* MAC_TODO */
4301static unsigned short
4302x_emacs_to_x_modifiers (dpyinfo, state)
4303 struct x_display_info *dpyinfo;
4304 unsigned int state;
4305{
4306 return ( ((state & alt_modifier) ? dpyinfo->alt_mod_mask : 0)
4307 | ((state & super_modifier) ? dpyinfo->super_mod_mask : 0)
4308 | ((state & hyper_modifier) ? dpyinfo->hyper_mod_mask : 0)
4309 | ((state & shift_modifier) ? ShiftMask : 0)
4310 | ((state & ctrl_modifier) ? ControlMask : 0)
4311 | ((state & meta_modifier) ? dpyinfo->meta_mod_mask : 0));
4312}
4313#endif /* MAC_TODO */
4314
4315/* Convert a keysym to its name. */ 4161/* Convert a keysym to its name. */
4316 4162
4317char * 4163char *
@@ -5102,41 +4948,43 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
5102 4948
5103#ifdef USE_TOOLKIT_SCROLL_BARS 4949#ifdef USE_TOOLKIT_SCROLL_BARS
5104 if (NILP (bar->track_top)) 4950 if (NILP (bar->track_top))
5105 if (sb_width >= disp_height) 4951 {
5106 { 4952 if (sb_width >= disp_height)
5107 XSETINT (bar->track_top, 0); 4953 {
5108 XSETINT (bar->track_height, 0); 4954 XSETINT (bar->track_top, 0);
5109 } 4955 XSETINT (bar->track_height, 0);
5110 else 4956 }
5111 { 4957 else
5112 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); 4958 {
5113 Rect r0, r1; 4959 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4960 Rect r0, r1;
5114 4961
5115 BLOCK_INPUT; 4962 BLOCK_INPUT;
5116 4963
5117 SetControl32BitMinimum (ch, 0); 4964 SetControl32BitMinimum (ch, 0);
5118 SetControl32BitMaximum (ch, 1); 4965 SetControl32BitMaximum (ch, 1);
5119 SetControlViewSize (ch, 1); 4966 SetControlViewSize (ch, 1);
5120 4967
5121 /* Move the scroll bar thumb to the top. */ 4968 /* Move the scroll bar thumb to the top. */
5122 SetControl32BitValue (ch, 0); 4969 SetControl32BitValue (ch, 0);
5123 get_control_part_bounds (ch, kControlIndicatorPart, &r0); 4970 get_control_part_bounds (ch, kControlIndicatorPart, &r0);
5124 4971
5125 /* Move the scroll bar thumb to the bottom. */ 4972 /* Move the scroll bar thumb to the bottom. */
5126 SetControl32BitValue (ch, 1); 4973 SetControl32BitValue (ch, 1);
5127 get_control_part_bounds (ch, kControlIndicatorPart, &r1); 4974 get_control_part_bounds (ch, kControlIndicatorPart, &r1);
5128 4975
5129 UnionRect (&r0, &r1, &r0); 4976 UnionRect (&r0, &r1, &r0);
5130 XSETINT (bar->track_top, r0.top); 4977 XSETINT (bar->track_top, r0.top);
5131 XSETINT (bar->track_height, r0.bottom - r0.top); 4978 XSETINT (bar->track_height, r0.bottom - r0.top);
5132 4979
5133 /* Don't show the scroll bar if its height is not enough to 4980 /* Don't show the scroll bar if its height is not enough to
5134 display the scroll bar thumb. */ 4981 display the scroll bar thumb. */
5135 if (r0.bottom - r0.top > 0) 4982 if (r0.bottom - r0.top > 0)
5136 ShowControl (ch); 4983 ShowControl (ch);
5137 4984
5138 UNBLOCK_INPUT; 4985 UNBLOCK_INPUT;
5139 } 4986 }
4987 }
5140 4988
5141 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); 4989 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole);
5142#else /* not USE_TOOLKIT_SCROLL_BARS */ 4990#else /* not USE_TOOLKIT_SCROLL_BARS */
@@ -6205,10 +6053,12 @@ mac_handle_visibility_change (f)
6205 struct input_event buf; 6053 struct input_event buf;
6206 6054
6207 if (IsWindowVisible (wp)) 6055 if (IsWindowVisible (wp))
6208 if (IsWindowCollapsed (wp)) 6056 {
6209 iconified = 1; 6057 if (IsWindowCollapsed (wp))
6210 else 6058 iconified = 1;
6211 visible = 1; 6059 else
6060 visible = 1;
6061 }
6212 6062
6213 if (!f->async_visible && visible) 6063 if (!f->async_visible && visible)
6214 { 6064 {
@@ -6254,9 +6104,6 @@ void
6254x_make_frame_visible (f) 6104x_make_frame_visible (f)
6255 struct frame *f; 6105 struct frame *f;
6256{ 6106{
6257 Lisp_Object type;
6258 int original_top, original_left;
6259
6260 BLOCK_INPUT; 6107 BLOCK_INPUT;
6261 6108
6262 if (! FRAME_VISIBLE_P (f)) 6109 if (! FRAME_VISIBLE_P (f))
@@ -6267,27 +6114,29 @@ x_make_frame_visible (f)
6267 before the window gets really visible. */ 6114 before the window gets really visible. */
6268 if (! FRAME_ICONIFIED_P (f) 6115 if (! FRAME_ICONIFIED_P (f)
6269 && ! f->output_data.mac->asked_for_visible) 6116 && ! f->output_data.mac->asked_for_visible)
6117 {
6270#if TARGET_API_MAC_CARBON 6118#if TARGET_API_MAC_CARBON
6271 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition))) 6119 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
6272 { 6120 {
6273 struct frame *sf = SELECTED_FRAME (); 6121 struct frame *sf = SELECTED_FRAME ();
6274 if (!FRAME_MAC_P (sf)) 6122 if (!FRAME_MAC_P (sf))
6275 RepositionWindow (FRAME_MAC_WINDOW (f), NULL, 6123 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
6276 kWindowCenterOnMainScreen); 6124 kWindowCenterOnMainScreen);
6277 else 6125 else
6278 RepositionWindow (FRAME_MAC_WINDOW (f), 6126 RepositionWindow (FRAME_MAC_WINDOW (f),
6279 FRAME_MAC_WINDOW (sf), 6127 FRAME_MAC_WINDOW (sf),
6280#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 6128#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
6281 kWindowCascadeStartAtParentWindowScreen 6129 kWindowCascadeStartAtParentWindowScreen
6282#else 6130#else
6283 kWindowCascadeOnParentWindowScreen 6131 kWindowCascadeOnParentWindowScreen
6284#endif 6132#endif
6285 ); 6133 );
6286 x_real_positions (f, &f->left_pos, &f->top_pos); 6134 x_real_positions (f, &f->left_pos, &f->top_pos);
6287 } 6135 }
6288 else 6136 else
6289#endif 6137#endif
6290 x_set_offset (f, f->left_pos, f->top_pos, 0); 6138 x_set_offset (f, f->left_pos, f->top_pos, 0);
6139 }
6291 6140
6292 f->output_data.mac->asked_for_visible = 1; 6141 f->output_data.mac->asked_for_visible = 1;
6293 6142
@@ -6707,12 +6556,7 @@ xlfdpat_create (pattern)
6707 struct xlfdpat_block *blk; 6556 struct xlfdpat_block *blk;
6708 6557
6709 pat = xmalloc (sizeof (struct xlfdpat)); 6558 pat = xmalloc (sizeof (struct xlfdpat));
6710 if (pat == NULL)
6711 goto error;
6712
6713 pat->buf = xmalloc (strlen (pattern) + 1); 6559 pat->buf = xmalloc (strlen (pattern) + 1);
6714 if (pat->buf == NULL)
6715 goto error;
6716 6560
6717 /* Normalize the pattern string and store it to `pat->buf'. */ 6561 /* Normalize the pattern string and store it to `pat->buf'. */
6718 nblocks = 0; 6562 nblocks = 0;
@@ -6730,15 +6574,17 @@ xlfdpat_create (pattern)
6730 else 6574 else
6731 { 6575 {
6732 if (last_char == '?') 6576 if (last_char == '?')
6733 if (anychar_head > pat->buf && *(anychar_head - 1) == '*') 6577 {
6734 /* ...*??* -> ...*?? */ 6578 if (anychar_head > pat->buf && *(anychar_head - 1) == '*')
6735 continue; 6579 /* ...*??* -> ...*?? */
6736 else 6580 continue;
6737 /* ...a??* -> ...a*?? */ 6581 else
6738 { 6582 /* ...a??* -> ...a*?? */
6739 *anychar_head++ = '*'; 6583 {
6740 c = '?'; 6584 *anychar_head++ = '*';
6741 } 6585 c = '?';
6586 }
6587 }
6742 nblocks++; 6588 nblocks++;
6743 } 6589 }
6744 else if (c == '?') 6590 else if (c == '?')
@@ -6774,8 +6620,6 @@ xlfdpat_create (pattern)
6774 } 6620 }
6775 6621
6776 pat->blocks = xmalloc (sizeof (struct xlfdpat_block) * nblocks); 6622 pat->blocks = xmalloc (sizeof (struct xlfdpat_block) * nblocks);
6777 if (pat->blocks == NULL)
6778 goto error;
6779 6623
6780 /* Divide the normalized pattern into blocks. */ 6624 /* Divide the normalized pattern into blocks. */
6781 p = pat->buf; 6625 p = pat->buf;
@@ -7235,9 +7079,10 @@ init_font_name_table ()
7235 Qnil, Qnil, Qnil);; 7079 Qnil, Qnil, Qnil);;
7236 err = ATSUFontCount (&nfonts); 7080 err = ATSUFontCount (&nfonts);
7237 if (err == noErr) 7081 if (err == noErr)
7238 font_ids = xmalloc (sizeof (ATSUFontID) * nfonts); 7082 {
7239 if (font_ids) 7083 font_ids = xmalloc (sizeof (ATSUFontID) * nfonts);
7240 err = ATSUGetFontIDs (font_ids, nfonts, NULL); 7084 err = ATSUGetFontIDs (font_ids, nfonts, NULL);
7085 }
7241 if (err == noErr) 7086 if (err == noErr)
7242 for (i = 0; i < nfonts; i++) 7087 for (i = 0; i < nfonts; i++)
7243 { 7088 {
@@ -7247,8 +7092,6 @@ init_font_name_table ()
7247 if (err != noErr) 7092 if (err != noErr)
7248 continue; 7093 continue;
7249 name = xmalloc (name_len + 1); 7094 name = xmalloc (name_len + 1);
7250 if (name == NULL)
7251 continue;
7252 name[name_len] = '\0'; 7095 name[name_len] = '\0';
7253 err = ATSUFindFontName (font_ids[i], kFontFamilyName, 7096 err = ATSUFindFontName (font_ids[i], kFontFamilyName,
7254 kFontMacintoshPlatform, kFontNoScript, 7097 kFontMacintoshPlatform, kFontNoScript,
@@ -7569,7 +7412,7 @@ mac_do_list_fonts (pattern, maxnames)
7569 if (xlfdpat_match (pat, font_name_table[i])) 7412 if (xlfdpat_match (pat, font_name_table[i]))
7570 { 7413 {
7571 font_list = Fcons (build_string (font_name_table[i]), font_list); 7414 font_list = Fcons (build_string (font_name_table[i]), font_list);
7572 if (exact || maxnames > 0 && ++n_fonts >= maxnames) 7415 if (exact || (maxnames > 0 && ++n_fonts >= maxnames))
7573 break; 7416 break;
7574 } 7417 }
7575 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0 7418 else if (scl_val[XLFD_SCL_PIXEL_SIZE] > 0
@@ -7578,8 +7421,6 @@ mac_do_list_fonts (pattern, maxnames)
7578 int former_len = ptr - font_name_table[i]; 7421 int former_len = ptr - font_name_table[i];
7579 7422
7580 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1); 7423 scaled = xmalloc (strlen (font_name_table[i]) + 20 + 1);
7581 if (scaled == NULL)
7582 continue;
7583 memcpy (scaled, font_name_table[i], former_len); 7424 memcpy (scaled, font_name_table[i], former_len);
7584 sprintf (scaled + former_len, 7425 sprintf (scaled + former_len,
7585 "-%d-%d-72-72-m-%d-%s", 7426 "-%d-%d-72-72-m-%d-%s",
@@ -7592,7 +7433,7 @@ mac_do_list_fonts (pattern, maxnames)
7592 { 7433 {
7593 font_list = Fcons (build_string (scaled), font_list); 7434 font_list = Fcons (build_string (scaled), font_list);
7594 xfree (scaled); 7435 xfree (scaled);
7595 if (exact || maxnames > 0 && ++n_fonts >= maxnames) 7436 if (exact || (maxnames > 0 && ++n_fonts >= maxnames))
7596 break; 7437 break;
7597 } 7438 }
7598 else 7439 else
@@ -7912,18 +7753,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
7912 font->max_char_or_byte2 = 0xff; 7753 font->max_char_or_byte2 = 0xff;
7913 7754
7914 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100); 7755 font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100);
7915 if (font->bounds.rows == NULL)
7916 {
7917 mac_unload_font (&one_mac_display_info, font);
7918 return NULL;
7919 }
7920 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100); 7756 bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100);
7921 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow)); 7757 font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow));
7922 if (font->bounds.rows[0] == NULL)
7923 {
7924 mac_unload_font (&one_mac_display_info, font);
7925 return NULL;
7926 }
7927 bzero (font->bounds.rows[0], sizeof (XCharStructRow)); 7758 bzero (font->bounds.rows[0], sizeof (XCharStructRow));
7928 7759
7929#if USE_CG_TEXT_DRAWING 7760#if USE_CG_TEXT_DRAWING
@@ -7945,9 +7776,10 @@ XLoadQueryFont (Display *dpy, char *fontname)
7945 } 7776 }
7946 7777
7947 if (font->cg_font) 7778 if (font->cg_font)
7948 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100); 7779 {
7949 if (font->cg_glyphs) 7780 font->cg_glyphs = xmalloc (sizeof (CGGlyph) * 0x100);
7950 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100); 7781 bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100);
7782 }
7951#endif 7783#endif
7952 space_bounds = font->bounds.rows[0]->per_char + 0x20; 7784 space_bounds = font->bounds.rows[0]->per_char + 0x20;
7953 err = mac_query_char_extents (font->mac_style, 0x20, 7785 err = mac_query_char_extents (font->mac_style, 0x20,
@@ -8093,11 +7925,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
8093 7925
8094 font->bounds.per_char = 7926 font->bounds.per_char =
8095 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7927 xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
8096 if (font->bounds.per_char == NULL)
8097 {
8098 mac_unload_font (&one_mac_display_info, font);
8099 return NULL;
8100 }
8101 bzero (font->bounds.per_char, 7928 bzero (font->bounds.per_char,
8102 sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7929 sizeof (XCharStruct) * (0xff - 0x20 + 1));
8103 7930
@@ -8241,10 +8068,8 @@ x_load_font (f, fontname, size)
8241 8068
8242 /* Load the font and add it to the table. */ 8069 /* Load the font and add it to the table. */
8243 { 8070 {
8244 char *full_name;
8245 struct MacFontStruct *font; 8071 struct MacFontStruct *font;
8246 struct font_info *fontp; 8072 struct font_info *fontp;
8247 unsigned long value;
8248 int i; 8073 int i;
8249 8074
8250 fontname = (char *) SDATA (XCAR (font_names)); 8075 fontname = (char *) SDATA (XCAR (font_names));
@@ -8756,6 +8581,7 @@ static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
8756 8581
8757#endif 8582#endif
8758 8583
8584#ifdef MAC_OS8
8759static void 8585static void
8760do_get_menus (void) 8586do_get_menus (void)
8761{ 8587{
@@ -8817,6 +8643,7 @@ do_check_ram_size (void)
8817 exit (1); 8643 exit (1);
8818 } 8644 }
8819} 8645}
8646#endif /* MAC_OS8 */
8820 8647
8821static void 8648static void
8822do_window_update (WindowPtr win) 8649do_window_update (WindowPtr win)
@@ -8998,42 +8825,41 @@ do_grow_window (WindowPtr w, EventRecord *e)
8998static void 8825static void
8999do_zoom_window (WindowPtr w, int zoom_in_or_out) 8826do_zoom_window (WindowPtr w, int zoom_in_or_out)
9000{ 8827{
9001 GrafPtr save_port;
9002 Rect zoom_rect, port_rect; 8828 Rect zoom_rect, port_rect;
9003 Point top_left; 8829 int columns, rows, width, height;
9004 int w_title_height, columns, rows, width, height;
9005 struct frame *f = mac_window_to_frame (w); 8830 struct frame *f = mac_window_to_frame (w);
9006 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 8831 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
9007
9008#if TARGET_API_MAC_CARBON 8832#if TARGET_API_MAC_CARBON
9009 { 8833 Point standard_size;
9010 Point standard_size;
9011 8834
9012 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); 8835 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
9013 standard_size.v = dpyinfo->height; 8836 standard_size.v = dpyinfo->height;
9014 8837
9015 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) 8838 if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
9016 zoom_in_or_out = inZoomIn; 8839 zoom_in_or_out = inZoomIn;
9017 else 8840 else
9018 { 8841 {
9019 /* Adjust the standard size according to character boundaries. */ 8842 /* Adjust the standard size according to character boundaries. */
9020
9021 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left);
9022 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
9023 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
9024 standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
9025 GetWindowBounds (w, kWindowContentRgn, &port_rect);
9026 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)
9027 && port_rect.left == zoom_rect.left
9028 && port_rect.top == zoom_rect.top)
9029 zoom_in_or_out = inZoomIn;
9030 else
9031 zoom_in_or_out = inZoomOut;
9032 }
9033 8843
9034 ZoomWindowIdeal (w, zoom_in_or_out, &standard_size); 8844 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, zoom_rect.right - zoom_rect.left);
9035 } 8845 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
8846 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
8847 standard_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
8848 GetWindowBounds (w, kWindowContentRgn, &port_rect);
8849 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)
8850 && port_rect.left == zoom_rect.left
8851 && port_rect.top == zoom_rect.top)
8852 zoom_in_or_out = inZoomIn;
8853 else
8854 zoom_in_or_out = inZoomOut;
8855 }
8856
8857 ZoomWindowIdeal (w, zoom_in_or_out, &standard_size);
9036#else /* not TARGET_API_MAC_CARBON */ 8858#else /* not TARGET_API_MAC_CARBON */
8859 GrafPtr save_port;
8860 Point top_left;
8861 int w_title_height;
8862
9037 GetPort (&save_port); 8863 GetPort (&save_port);
9038 8864
9039 SetPortWindowPort (w); 8865 SetPortWindowPort (w);
@@ -9101,15 +8927,12 @@ mac_store_apple_event (class, id, desc)
9101 Lisp_Object class, id; 8927 Lisp_Object class, id;
9102 const AEDesc *desc; 8928 const AEDesc *desc;
9103{ 8929{
9104 OSErr err = noErr; 8930 OSErr err;
9105 struct input_event buf; 8931 struct input_event buf;
9106 AEDesc *desc_copy; 8932 AEDesc *desc_copy;
9107 8933
9108 desc_copy = xmalloc (sizeof (AEDesc)); 8934 desc_copy = xmalloc (sizeof (AEDesc));
9109 if (desc_copy == NULL) 8935 err = AEDuplicateDesc (desc, desc_copy);
9110 err = memFullErr;
9111 else
9112 err = AEDuplicateDesc (desc, desc_copy);
9113 if (err == noErr) 8936 if (err == noErr)
9114 { 8937 {
9115 EVENT_INIT (buf); 8938 EVENT_INIT (buf);
@@ -9168,26 +8991,27 @@ mac_handle_command_event (next_handler, event, data)
9168 mac_find_apple_event_spec (0, command.commandID, 8991 mac_find_apple_event_spec (0, command.commandID,
9169 &class_key, &id_key, &binding); 8992 &class_key, &id_key, &binding);
9170 if (!NILP (binding) && !EQ (binding, Qundefined)) 8993 if (!NILP (binding) && !EQ (binding, Qundefined))
9171 if (INTEGERP (binding)) 8994 {
9172 return XINT (binding); 8995 if (INTEGERP (binding))
9173 else 8996 return XINT (binding);
9174 { 8997 else
9175 AppleEvent apple_event; 8998 {
9176 UInt32 modifiers; 8999 AppleEvent apple_event;
9177 static EventParamName names[] = {kEventParamDirectObject, 9000 static EventParamName names[] = {kEventParamDirectObject,
9178 kEventParamKeyModifiers}; 9001 kEventParamKeyModifiers};
9179 static EventParamType types[] = {typeHICommand, 9002 static EventParamType types[] = {typeHICommand,
9180 typeUInt32}; 9003 typeUInt32};
9181 err = create_apple_event_from_event_ref (event, 2, names, types, 9004 err = create_apple_event_from_event_ref (event, 2, names, types,
9182 &apple_event); 9005 &apple_event);
9183 if (err == noErr) 9006 if (err == noErr)
9184 { 9007 {
9185 err = mac_store_apple_event (class_key, id_key, &apple_event); 9008 err = mac_store_apple_event (class_key, id_key, &apple_event);
9186 AEDisposeDesc (&apple_event); 9009 AEDisposeDesc (&apple_event);
9187 } 9010 }
9188 if (err == noErr) 9011 if (err == noErr)
9189 return noErr; 9012 return noErr;
9190 } 9013 }
9014 }
9191 9015
9192 return eventNotHandledErr; 9016 return eventNotHandledErr;
9193} 9017}
@@ -9195,7 +9019,6 @@ mac_handle_command_event (next_handler, event, data)
9195static OSErr 9019static OSErr
9196init_command_handler () 9020init_command_handler ()
9197{ 9021{
9198 OSErr err = noErr;
9199 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; 9022 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
9200 static EventHandlerUPP handle_command_eventUPP = NULL; 9023 static EventHandlerUPP handle_command_eventUPP = NULL;
9201 9024
@@ -10071,18 +9894,18 @@ XTread_socket (sd, expected, hold_quit)
10071 XSETINT (inev.x, mouse_loc.h); 9894 XSETINT (inev.x, mouse_loc.h);
10072 XSETINT (inev.y, mouse_loc.v); 9895 XSETINT (inev.y, mouse_loc.v);
10073 9896
10074 if (dpyinfo->grabbed && tracked_scroll_bar 9897 if ((dpyinfo->grabbed && tracked_scroll_bar)
10075 || ch != 0 9898 || (ch != 0
10076#ifndef USE_TOOLKIT_SCROLL_BARS 9899#ifndef USE_TOOLKIT_SCROLL_BARS
10077 /* control_part_code becomes kControlNoPart if 9900 /* control_part_code becomes kControlNoPart if
10078 a progress indicator is clicked. */ 9901 a progress indicator is clicked. */
10079 && control_part_code != kControlNoPart 9902 && control_part_code != kControlNoPart
10080#else /* USE_TOOLKIT_SCROLL_BARS */ 9903#else /* USE_TOOLKIT_SCROLL_BARS */
10081#ifdef MAC_OSX 9904#ifdef MAC_OSX
10082 && control_kind.kind == kControlKindScrollBar 9905 && control_kind.kind == kControlKindScrollBar
10083#endif /* MAC_OSX */ 9906#endif /* MAC_OSX */
10084#endif /* USE_TOOLKIT_SCROLL_BARS */ 9907#endif /* USE_TOOLKIT_SCROLL_BARS */
10085 ) 9908 ))
10086 { 9909 {
10087 struct scroll_bar *bar; 9910 struct scroll_bar *bar;
10088 9911
@@ -10882,7 +10705,6 @@ mac_check_bundle()
10882 extern int inhibit_window_system; 10705 extern int inhibit_window_system;
10883 extern int noninteractive; 10706 extern int noninteractive;
10884 CFBundleRef appsBundle; 10707 CFBundleRef appsBundle;
10885 pid_t child;
10886 10708
10887 /* No need to test if already -nw*/ 10709 /* No need to test if already -nw*/
10888 if (inhibit_window_system || noninteractive) 10710 if (inhibit_window_system || noninteractive)
diff --git a/src/macterm.h b/src/macterm.h
index f6807d93487..db284fe7788 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -547,7 +547,15 @@ extern int XParseGeometry P_ ((char *, int *, int *, unsigned int *,
547/* Defined in macterm.c. */ 547/* Defined in macterm.c. */
548 548
549extern void x_set_window_size P_ ((struct frame *, int, int, int)); 549extern void x_set_window_size P_ ((struct frame *, int, int, int));
550extern void x_set_mouse_position P_ ((struct frame *, int, int));
551extern void x_set_mouse_pixel_position P_ ((struct frame *, int, int));
550extern void x_make_frame_visible P_ ((struct frame *)); 552extern void x_make_frame_visible P_ ((struct frame *));
553extern void x_make_frame_invisible P_ ((struct frame *));
554extern void x_iconify_frame P_ ((struct frame *));
555extern void x_free_frame_resources P_ ((struct frame *));
556extern void x_destroy_window P_ ((struct frame *));
557extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
558extern void x_delete_display P_ ((struct x_display_info *));
551extern void mac_initialize P_ ((void)); 559extern void mac_initialize P_ ((void));
552extern Pixmap XCreatePixmap P_ ((Display *, WindowPtr, unsigned int, 560extern Pixmap XCreatePixmap P_ ((Display *, WindowPtr, unsigned int,
553 unsigned int, unsigned int)); 561 unsigned int, unsigned int));
@@ -557,6 +565,7 @@ extern Pixmap XCreatePixmapFromBitmapData P_ ((Display *, WindowPtr, char *,
557 unsigned int)); 565 unsigned int));
558extern void XFreePixmap P_ ((Display *, Pixmap)); 566extern void XFreePixmap P_ ((Display *, Pixmap));
559extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *)); 567extern GC XCreateGC P_ ((Display *, Window, unsigned long, XGCValues *));
568extern void XFreeGC P_ ((Display *, GC));
560extern void XSetForeground P_ ((Display *, GC, unsigned long)); 569extern void XSetForeground P_ ((Display *, GC, unsigned long));
561extern void XSetBackground P_ ((Display *, GC, unsigned long)); 570extern void XSetBackground P_ ((Display *, GC, unsigned long));
562extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); 571extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
@@ -568,6 +577,7 @@ extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
568extern OSErr install_window_handler P_ ((WindowPtr)); 577extern OSErr install_window_handler P_ ((WindowPtr));
569extern void remove_window_handler P_ ((WindowPtr)); 578extern void remove_window_handler P_ ((WindowPtr));
570extern Lisp_Object mac_make_lispy_event_code P_ ((int)); 579extern Lisp_Object mac_make_lispy_event_code P_ ((int));
580extern void do_menu_choice P_ ((SInt32));
571#if USE_CG_DRAWING 581#if USE_CG_DRAWING
572extern void mac_prepare_for_quickdraw P_ ((struct frame *)); 582extern void mac_prepare_for_quickdraw P_ ((struct frame *));
573#endif 583#endif
@@ -581,6 +591,24 @@ extern void mac_prepare_for_quickdraw P_ ((struct frame *));
581 591
582extern void x_clear_frame_selections P_ ((struct frame *)); 592extern void x_clear_frame_selections P_ ((struct frame *));
583 593
594/* Defined in macfns.c */
595
596extern int have_menus_p P_ ((void));
597
598extern void x_real_positions P_ ((struct frame *, int *, int *));
599extern void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
600extern int x_pixel_width P_ ((struct frame *));
601extern int x_pixel_height P_ ((struct frame *));
602extern int x_char_width P_ ((struct frame *));
603extern int x_char_height P_ ((struct frame *));
604extern void x_sync P_ ((struct frame *));
605extern void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
606
607/* Defined in macmenu.c */
608
609extern void x_activate_menubar P_ ((struct frame *));
610extern void free_frame_menubar P_ ((struct frame *));
611
584/* Defined in mac.c. */ 612/* Defined in mac.c. */
585 613
586extern void mac_clear_font_name_table P_ ((void)); 614extern void mac_clear_font_name_table P_ ((void));
diff --git a/src/print.c b/src/print.c
index 7e9ed30c32b..12960ef214d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -759,7 +759,8 @@ DEFUN ("prin1-to-string", Fprin1_to_string, Sprin1_to_string, 1, 2, 0,
759 doc: /* Return a string containing the printed representation of OBJECT. 759 doc: /* Return a string containing the printed representation of OBJECT.
760OBJECT can be any Lisp object. This function outputs quoting characters 760OBJECT can be any Lisp object. This function outputs quoting characters
761when necessary to make output that `read' can handle, whenever possible, 761when necessary to make output that `read' can handle, whenever possible,
762unless the optional second argument NOESCAPE is non-nil. 762unless the optional second argument NOESCAPE is non-nil. For complex objects,
763the behavior is controlled by `print-level' and `print-length', which see.
763 764
764OBJECT is any of the Lisp data types: a number, a string, a symbol, 765OBJECT is any of the Lisp data types: a number, a string, a symbol,
765a list, a buffer, a window, a frame, etc. 766a list, a buffer, a window, a frame, etc.
diff --git a/src/process.c b/src/process.c
index 003f27b77b8..6e633a5825c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2322,7 +2322,11 @@ get_lisp_to_sockaddr_size (address, familyp)
2322} 2322}
2323 2323
2324/* Convert an address object (vector or string) to an internal sockaddr. 2324/* Convert an address object (vector or string) to an internal sockaddr.
2325 Format of address has already been validated by size_lisp_to_sockaddr. */ 2325
2326 The address format has been basically validated by
2327 get_lisp_to_sockaddr_size, but this does not mean FAMILY is valid;
2328 it could have come from user data. So if FAMILY is not valid,
2329 we return after zeroing *SA. */
2326 2330
2327static void 2331static void
2328conv_lisp_to_sockaddr (family, address, sa, len) 2332conv_lisp_to_sockaddr (family, address, sa, len)
@@ -2336,7 +2340,6 @@ conv_lisp_to_sockaddr (family, address, sa, len)
2336 register int i; 2340 register int i;
2337 2341
2338 bzero (sa, len); 2342 bzero (sa, len);
2339 sa->sa_family = family;
2340 2343
2341 if (VECTORP (address)) 2344 if (VECTORP (address))
2342 { 2345 {
@@ -2348,6 +2351,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
2348 i = XINT (p->contents[--len]); 2351 i = XINT (p->contents[--len]);
2349 sin->sin_port = htons (i); 2352 sin->sin_port = htons (i);
2350 cp = (unsigned char *)&sin->sin_addr; 2353 cp = (unsigned char *)&sin->sin_addr;
2354 sa->sa_family = family;
2351 } 2355 }
2352#ifdef AF_INET6 2356#ifdef AF_INET6
2353 else if (family == AF_INET6) 2357 else if (family == AF_INET6)
@@ -2363,9 +2367,10 @@ conv_lisp_to_sockaddr (family, address, sa, len)
2363 int j = XFASTINT (p->contents[i]) & 0xffff; 2367 int j = XFASTINT (p->contents[i]) & 0xffff;
2364 ip6[i] = ntohs (j); 2368 ip6[i] = ntohs (j);
2365 } 2369 }
2366 return; 2370 sa->sa_family = family;
2367 } 2371 }
2368#endif 2372#endif
2373 return;
2369 } 2374 }
2370 else if (STRINGP (address)) 2375 else if (STRINGP (address))
2371 { 2376 {
@@ -2376,6 +2381,7 @@ conv_lisp_to_sockaddr (family, address, sa, len)
2376 cp = SDATA (address); 2381 cp = SDATA (address);
2377 for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++) 2382 for (i = 0; i < sizeof (sockun->sun_path) && *cp; i++)
2378 sockun->sun_path[i] = *cp++; 2383 sockun->sun_path[i] = *cp++;
2384 sa->sa_family = family;
2379 } 2385 }
2380#endif 2386#endif
2381 return; 2387 return;
@@ -6236,6 +6242,8 @@ text to PROCESS after you call this function. */)
6236 emacs_close (XINT (XPROCESS (proc)->outfd)); 6242 emacs_close (XINT (XPROCESS (proc)->outfd));
6237#endif /* not HAVE_SHUTDOWN */ 6243#endif /* not HAVE_SHUTDOWN */
6238 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); 6244 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0);
6245 if (new_outfd < 0)
6246 abort ();
6239 old_outfd = XINT (XPROCESS (proc)->outfd); 6247 old_outfd = XINT (XPROCESS (proc)->outfd);
6240 6248
6241 if (!proc_encode_coding_system[new_outfd]) 6249 if (!proc_encode_coding_system[new_outfd])
diff --git a/src/puresize.h b/src/puresize.h
index 168e1e7980a..ccbc7a82554 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -49,7 +49,7 @@ Boston, MA 02110-1301, USA. */
49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */ 49/* Increase BASE_PURESIZE by a ratio depending on the machine's word size. */
50#ifndef PURESIZE_RATIO 50#ifndef PURESIZE_RATIO
51#if BITS_PER_EMACS_INT > 32 51#if BITS_PER_EMACS_INT > 32
52#define PURESIZE_RATIO 9/5 /* Don't surround with `()'. */ 52#define PURESIZE_RATIO 10/6 /* Don't surround with `()'. */
53#else 53#else
54#define PURESIZE_RATIO 1 54#define PURESIZE_RATIO 1
55#endif 55#endif
diff --git a/src/s/ms-w32.h b/src/s/ms-w32.h
index 3e5d9c865bb..55f62644d04 100644
--- a/src/s/ms-w32.h
+++ b/src/s/ms-w32.h
@@ -465,8 +465,10 @@ extern char *get_emacs_configuration_options (void);
465#endif 465#endif
466#include <string.h> 466#include <string.h>
467 467
468/* We need a little extra space, see ../../lisp/loadup.el */ 468/* We need a little extra space, see ../../lisp/loadup.el.
469#define SYSTEM_PURESIZE_EXTRA 137500 469 The number below comes from 22038 bytes worth (as of 2006-04)
470 of w32-specific files loaded by loadup.el, plus 2K spare. */
471#define SYSTEM_PURESIZE_EXTRA 24000
470 472
471/* For unexec to work on Alpha systems, we need to put Emacs' 473/* For unexec to work on Alpha systems, we need to put Emacs'
472 initialized data into a separate section from the CRT initialized 474 initialized data into a separate section from the CRT initialized
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index db77a83cee2..4ca0be829a2 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -100,7 +100,11 @@ Boston, MA 02110-1301, USA. */
100#if defined (__ppc__) 100#if defined (__ppc__)
101#include <mach-o/ppc/reloc.h> 101#include <mach-o/ppc/reloc.h>
102#endif 102#endif
103#if defined (HAVE_MALLOC_MALLOC_H) 103#include <config.h>
104#undef malloc
105#undef realloc
106#undef free
107#ifdef HAVE_MALLOC_MALLOC_H
104#include <malloc/malloc.h> 108#include <malloc/malloc.h>
105#else 109#else
106#include <objc/malloc.h> 110#include <objc/malloc.h>
@@ -558,7 +562,7 @@ print_load_command (struct load_command *lc)
558static void 562static void
559read_load_commands () 563read_load_commands ()
560{ 564{
561 int n, i, j; 565 int i;
562 566
563 if (!unexec_read (&mh, sizeof (struct mach_header))) 567 if (!unexec_read (&mh, sizeof (struct mach_header)))
564 unexec_error ("cannot read mach-o header"); 568 unexec_error ("cannot read mach-o header");
@@ -680,7 +684,6 @@ copy_data_segment (struct load_command *lc)
680 struct section *sectp; 684 struct section *sectp;
681 int j; 685 int j;
682 unsigned long header_offset, file_offset, old_file_offset; 686 unsigned long header_offset, file_offset, old_file_offset;
683 struct region_t *r;
684 687
685 printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n", 688 printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",
686 scp->segname, scp->fileoff, scp->fileoff + scp->filesize, 689 scp->segname, scp->fileoff, scp->fileoff + scp->filesize,
diff --git a/src/window.c b/src/window.c
index cbfc7e02401..61b85e5ad22 100644
--- a/src/window.c
+++ b/src/window.c
@@ -663,12 +663,24 @@ coordinates_in_window (w, x, y)
663 || WINDOW_RIGHTMOST_P (w)) 663 || WINDOW_RIGHTMOST_P (w))
664 { 664 {
665 if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width) 665 if (!WINDOW_LEFTMOST_P (w) && abs (*x - x0) < grabbable_width)
666 return ON_VERTICAL_BORDER; 666 {
667 /* Convert X and Y to window relative coordinates.
668 Vertical border is at the left edge of window. */
669 *x = max (0, *x - x0);
670 *y -= top_y;
671 return ON_VERTICAL_BORDER;
672 }
667 } 673 }
668 else 674 else
669 { 675 {
670 if (abs (*x - x1) < grabbable_width) 676 if (abs (*x - x1) < grabbable_width)
671 return ON_VERTICAL_BORDER; 677 {
678 /* Convert X and Y to window relative coordinates.
679 Vertical border is at the right edge of window. */
680 *x = min (x1, *x) - x0;
681 *y -= top_y;
682 return ON_VERTICAL_BORDER;
683 }
672 } 684 }
673 685
674 if (*x < x0 || *x >= x1) 686 if (*x < x0 || *x >= x1)
@@ -710,7 +722,13 @@ coordinates_in_window (w, x, y)
710 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w) 722 && !WINDOW_HAS_VERTICAL_SCROLL_BAR (w)
711 && !WINDOW_RIGHTMOST_P (w) 723 && !WINDOW_RIGHTMOST_P (w)
712 && (abs (*x - right_x) < grabbable_width)) 724 && (abs (*x - right_x) < grabbable_width))
713 return ON_VERTICAL_BORDER; 725 {
726 /* Convert X and Y to window relative coordinates.
727 Vertical border is at the right edge of window. */
728 *x = min (right_x, *x) - left_x;
729 *y -= top_y;
730 return ON_VERTICAL_BORDER;
731 }
714 } 732 }
715 else 733 else
716 { 734 {
@@ -722,6 +740,8 @@ coordinates_in_window (w, x, y)
722 { 740 {
723 /* On the border on the right side of the window? Assume that 741 /* On the border on the right side of the window? Assume that
724 this area begins at RIGHT_X minus a canonical char width. */ 742 this area begins at RIGHT_X minus a canonical char width. */
743 *x = min (right_x, *x) - left_x;
744 *y -= top_y;
725 return ON_VERTICAL_BORDER; 745 return ON_VERTICAL_BORDER;
726 } 746 }
727 } 747 }
@@ -2015,7 +2035,7 @@ window_loop (type, obj, mini, frames)
2015 `obj & 1' means consider only full-width windows. 2035 `obj & 1' means consider only full-width windows.
2016 `obj & 2' means consider also dedicated windows. */ 2036 `obj & 2' means consider also dedicated windows. */
2017 if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w)) 2037 if (((XINT (obj) & 1) && !WINDOW_FULL_WIDTH_P (w))
2018 || (!(XINT (obj) & 2) && EQ (w->dedicated, Qt)) 2038 || (!(XINT (obj) & 2) && !NILP (w->dedicated))
2019 /* Minibuffer windows are always ignored. */ 2039 /* Minibuffer windows are always ignored. */
2020 || MINI_WINDOW_P (w)) 2040 || MINI_WINDOW_P (w))
2021 break; 2041 break;
@@ -2070,7 +2090,7 @@ window_loop (type, obj, mini, frames)
2070 case GET_LARGEST_WINDOW: 2090 case GET_LARGEST_WINDOW:
2071 { /* nil `obj' means to ignore dedicated windows. */ 2091 { /* nil `obj' means to ignore dedicated windows. */
2072 /* Ignore dedicated windows and minibuffers. */ 2092 /* Ignore dedicated windows and minibuffers. */
2073 if (MINI_WINDOW_P (w) || (NILP (obj) && EQ (w->dedicated, Qt))) 2093 if (MINI_WINDOW_P (w) || (NILP (obj) && !NILP (w->dedicated)))
2074 break; 2094 break;
2075 2095
2076 if (NILP (best_window)) 2096 if (NILP (best_window))
@@ -4257,18 +4277,30 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4257 4277
4258 while (1) 4278 while (1)
4259 { 4279 {
4280 Lisp_Object first_parallel = Qnil;
4281
4260 p = XWINDOW (window); 4282 p = XWINDOW (window);
4261 parent = p->parent; 4283 parent = p->parent;
4262 4284
4263 /* Make sure there is a following window. */ 4285 if (NILP (XWINDOW (window)->next))
4264 if (NILP (parent)
4265 && (horiz_flag ? 1
4266 : NILP (XWINDOW (window)->next)))
4267 { 4286 {
4268 Fset_window_configuration (old_config); 4287 Fset_window_configuration (old_config);
4269 error ("No other window following this one"); 4288 error ("No other window following this one");
4270 } 4289 }
4271 4290
4291 /* See if this level has windows in parallel in the specified
4292 direction. If so, set FIRST_PARALLEL to the first one. */
4293 if (horiz_flag)
4294 {
4295 if (! NILP (parent) && !NILP (XWINDOW (parent)->vchild))
4296 first_parallel = XWINDOW (parent)->vchild;
4297 }
4298 else
4299 {
4300 if (! NILP (parent) && !NILP (XWINDOW (parent)->hchild))
4301 first_parallel = XWINDOW (parent)->hchild;
4302 }
4303
4272 /* Don't make this window too small. */ 4304 /* Don't make this window too small. */
4273 if (XINT (CURSIZE (window)) + delta 4305 if (XINT (CURSIZE (window)) + delta
4274 < (horiz_flag ? window_min_width : window_min_height)) 4306 < (horiz_flag ? window_min_width : window_min_height))
@@ -4286,12 +4318,11 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4286 XINT (CURSIZE (window)) + delta); 4318 XINT (CURSIZE (window)) + delta);
4287 4319
4288 /* If this window has following siblings in the desired dimension, 4320 /* If this window has following siblings in the desired dimension,
4289 make them smaller. 4321 make them smaller, and exit the loop.
4322
4290 (If we reach the top of the tree and can never do this, 4323 (If we reach the top of the tree and can never do this,
4291 we will fail and report an error, above.) */ 4324 we will fail and report an error, above.) */
4292 if (horiz_flag 4325 if (NILP (first_parallel))
4293 ? !NILP (XWINDOW (parent)->hchild)
4294 : !NILP (XWINDOW (parent)->vchild))
4295 { 4326 {
4296 if (!NILP (XWINDOW (window)->next)) 4327 if (!NILP (XWINDOW (window)->next))
4297 { 4328 {
@@ -4313,9 +4344,7 @@ adjust_window_trailing_edge (window, delta, horiz_flag)
4313 else 4344 else
4314 /* Here we have a chain of parallel siblings, in the other dimension. 4345 /* Here we have a chain of parallel siblings, in the other dimension.
4315 Change the size of the other siblings. */ 4346 Change the size of the other siblings. */
4316 for (child = (horiz_flag 4347 for (child = first_parallel;
4317 ? XWINDOW (parent)->vchild
4318 : XWINDOW (parent)->hchild);
4319 ! NILP (child); 4348 ! NILP (child);
4320 child = XWINDOW (child)->next) 4349 child = XWINDOW (child)->next)
4321 if (! EQ (child, window)) 4350 if (! EQ (child, window))
@@ -4856,7 +4885,7 @@ window_scroll_pixel_based (window, n, whole, noerror)
4856 { 4885 {
4857 if (it.current_y < it.last_visible_y 4886 if (it.current_y < it.last_visible_y
4858 && (it.current_y + it.max_ascent + it.max_descent 4887 && (it.current_y + it.max_ascent + it.max_descent
4859 >= it.last_visible_y)) 4888 > it.last_visible_y))
4860 { 4889 {
4861 /* The last line was only partially visible, make it fully 4890 /* The last line was only partially visible, make it fully
4862 visible. */ 4891 visible. */
diff --git a/src/xdisp.c b/src/xdisp.c
index fb80f349967..80b9ff6c8f6 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -14879,7 +14879,7 @@ dump_glyph_row (row, vpos, glyphs)
14879{ 14879{
14880 if (glyphs != 1) 14880 if (glyphs != 1)
14881 { 14881 {
14882 fprintf (stderr, "Row Start End Used oEI><\\CTZFesm X Y W H V A P\n"); 14882 fprintf (stderr, "Row Start End Used oE><\\CTZFesm X Y W H V A P\n");
14883 fprintf (stderr, "======================================================================\n"); 14883 fprintf (stderr, "======================================================================\n");
14884 14884
14885 fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d\ 14885 fprintf (stderr, "%3d %5d %5d %4d %1.1d%1.1d%1.1d%1.1d\
@@ -22371,7 +22371,10 @@ note_mouse_highlight (f, x, y)
22371 } 22371 }
22372 22372
22373 if (part == ON_VERTICAL_BORDER) 22373 if (part == ON_VERTICAL_BORDER)
22374 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 22374 {
22375 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
22376 help_echo_string = make_string ("drag-mouse-1: resize", 20);
22377 }
22375 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE 22378 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
22376 || part == ON_SCROLL_BAR) 22379 || part == ON_SCROLL_BAR)
22377 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 22380 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
diff --git a/src/xfaces.c b/src/xfaces.c
index 27edd1a45dc..3222a7bdd91 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4991,10 +4991,12 @@ Default face attributes override any local face attributes. */)
4991 gvec = XVECTOR (global_lface)->contents; 4991 gvec = XVECTOR (global_lface)->contents;
4992 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 4992 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
4993 if (! UNSPECIFIEDP (gvec[i])) 4993 if (! UNSPECIFIEDP (gvec[i]))
4994 if (IGNORE_DEFFACE_P (gvec[i])) 4994 {
4995 lvec[i] = Qunspecified; 4995 if (IGNORE_DEFFACE_P (gvec[i]))
4996 else 4996 lvec[i] = Qunspecified;
4997 lvec[i] = gvec[i]; 4997 else
4998 lvec[i] = gvec[i];
4999 }
4998 5000
4999 return Qnil; 5001 return Qnil;
5000} 5002}
@@ -6814,20 +6816,22 @@ try_font_list (f, attrs, family, registry, fonts, prefer_face_family)
6814 6816
6815#ifdef MAC_OS 6817#ifdef MAC_OS
6816 if (nfonts == 0 && STRINGP (try_family) && STRINGP (registry)) 6818 if (nfonts == 0 && STRINGP (try_family) && STRINGP (registry))
6817 if (xstricmp (SDATA (registry), "mac-roman") == 0) 6819 {
6818 /* When realizing the default face and a font spec does not 6820 if (xstricmp (SDATA (registry), "mac-roman") == 0)
6819 matched exactly, Emacs looks for ones with the same registry 6821 /* When realizing the default face and a font spec does not
6820 as the default font. On the Mac, this is mac-roman, which 6822 matched exactly, Emacs looks for ones with the same registry
6821 does not work if the family is -etl-fixed, e.g. The 6823 as the default font. On the Mac, this is mac-roman, which
6822 following widens the choices and fixes that problem. */ 6824 does not work if the family is -etl-fixed, e.g. The
6823 nfonts = try_alternative_families (f, try_family, Qnil, fonts); 6825 following widens the choices and fixes that problem. */
6824 else if (SBYTES (try_family) > 0 6826 nfonts = try_alternative_families (f, try_family, Qnil, fonts);
6825 && SREF (try_family, SBYTES (try_family) - 1) != '*') 6827 else if (SBYTES (try_family) > 0
6826 /* Some Central European/Cyrillic font family names have the 6828 && SREF (try_family, SBYTES (try_family) - 1) != '*')
6827 Roman counterpart name as their prefix. */ 6829 /* Some Central European/Cyrillic font family names have the
6828 nfonts = try_alternative_families (f, concat2 (try_family, 6830 Roman counterpart name as their prefix. */
6829 build_string ("*")), 6831 nfonts = try_alternative_families (f, concat2 (try_family,
6830 registry, fonts); 6832 build_string ("*")),
6833 registry, fonts);
6834 }
6831#endif 6835#endif
6832 6836
6833 if (EQ (try_family, family)) 6837 if (EQ (try_family, family))
diff --git a/src/xmenu.c b/src/xmenu.c
index 3c8c6d81a37..6e5ec6c5058 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -266,14 +266,15 @@ menubar_id_to_frame (id)
266static void 266static void
267init_menu_items () 267init_menu_items ()
268{ 268{
269 if (!NILP (menu_items_inuse))
270 error ("Trying to use a menu from within a menu-entry");
271
269 if (NILP (menu_items)) 272 if (NILP (menu_items))
270 { 273 {
271 menu_items_allocated = 60; 274 menu_items_allocated = 60;
272 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); 275 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
273 } 276 }
274 277
275 if (!NILP (menu_items_inuse))
276 error ("Trying to use a menu from within a menu-entry");
277 menu_items_inuse = Qt; 278 menu_items_inuse = Qt;
278 menu_items_used = 0; 279 menu_items_used = 0;
279 menu_items_n_panes = 0; 280 menu_items_n_panes = 0;
@@ -310,6 +311,39 @@ discard_menu_items ()
310 xassert (NILP (menu_items_inuse)); 311 xassert (NILP (menu_items_inuse));
311} 312}
312 313
314/* This undoes save_menu_items, and it is called by the specpdl unwind
315 mechanism. */
316
317static Lisp_Object
318restore_menu_items (saved)
319 Lisp_Object saved;
320{
321 menu_items = XCAR (saved);
322 menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil);
323 menu_items_allocated = (VECTORP (menu_items) ? ASIZE (menu_items) : 0);
324 saved = XCDR (saved);
325 menu_items_used = XINT (XCAR (saved));
326 saved = XCDR (saved);
327 menu_items_n_panes = XINT (XCAR (saved));
328 saved = XCDR (saved);
329 menu_items_submenu_depth = XINT (XCAR (saved));
330}
331
332/* Push the whole state of menu_items processing onto the specpdl.
333 It will be restored when the specpdl is unwound. */
334
335static void
336save_menu_items ()
337{
338 Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil,
339 make_number (menu_items_used),
340 make_number (menu_items_n_panes),
341 make_number (menu_items_submenu_depth));
342 record_unwind_protect (restore_menu_items, saved);
343 menu_items_inuse = Qnil;
344 menu_items = Qnil;
345}
346
313/* Make the menu_items vector twice as large. */ 347/* Make the menu_items vector twice as large. */
314 348
315static void 349static void
@@ -320,6 +354,7 @@ grow_menu_items ()
320 old = menu_items; 354 old = menu_items;
321 355
322 menu_items_allocated *= 2; 356 menu_items_allocated *= 2;
357
323 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); 358 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
324 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, 359 bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
325 old_size * sizeof (Lisp_Object)); 360 old_size * sizeof (Lisp_Object));
@@ -1740,6 +1775,7 @@ digest_single_submenu (start, end, top_level_items)
1740 int i; 1775 int i;
1741 int submenu_depth = 0; 1776 int submenu_depth = 0;
1742 widget_value **submenu_stack; 1777 widget_value **submenu_stack;
1778 int panes_seen = 0;
1743 1779
1744 submenu_stack 1780 submenu_stack
1745 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *)); 1781 = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
@@ -1786,6 +1822,8 @@ digest_single_submenu (start, end, top_level_items)
1786 Lisp_Object pane_name, prefix; 1822 Lisp_Object pane_name, prefix;
1787 char *pane_string; 1823 char *pane_string;
1788 1824
1825 panes_seen++;
1826
1789 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME]; 1827 pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
1790 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; 1828 prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
1791 1829
@@ -1833,6 +1871,10 @@ digest_single_submenu (start, end, top_level_items)
1833 Lisp_Object item_name, enable, descrip, def, type, selected; 1871 Lisp_Object item_name, enable, descrip, def, type, selected;
1834 Lisp_Object help; 1872 Lisp_Object help;
1835 1873
1874 /* All items should be contained in panes. */
1875 if (panes_seen == 0)
1876 abort ();
1877
1836 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME); 1878 item_name = AREF (menu_items, i + MENU_ITEMS_ITEM_NAME);
1837 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE); 1879 enable = AREF (menu_items, i + MENU_ITEMS_ITEM_ENABLE);
1838 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY); 1880 descrip = AREF (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY);
@@ -2067,7 +2109,6 @@ set_frame_menubar (f, first_time, deep_p)
2067 specbind (Qdebug_on_next_call, Qnil); 2109 specbind (Qdebug_on_next_call, Qnil);
2068 2110
2069 record_unwind_save_match_data (); 2111 record_unwind_save_match_data ();
2070 record_unwind_protect (unuse_menu_items, Qnil);
2071 if (NILP (Voverriding_local_map_menu_flag)) 2112 if (NILP (Voverriding_local_map_menu_flag))
2072 { 2113 {
2073 specbind (Qoverriding_terminal_local_map, Qnil); 2114 specbind (Qoverriding_terminal_local_map, Qnil);
@@ -2095,6 +2136,8 @@ set_frame_menubar (f, first_time, deep_p)
2095 2136
2096 /* Fill in menu_items with the current menu bar contents. 2137 /* Fill in menu_items with the current menu bar contents.
2097 This can evaluate Lisp code. */ 2138 This can evaluate Lisp code. */
2139 save_menu_items ();
2140
2098 menu_items = f->menu_bar_vector; 2141 menu_items = f->menu_bar_vector;
2099 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; 2142 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
2100 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); 2143 submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
@@ -2154,23 +2197,33 @@ set_frame_menubar (f, first_time, deep_p)
2154 } 2197 }
2155 2198
2156 set_buffer_internal_1 (prev); 2199 set_buffer_internal_1 (prev);
2157 unbind_to (specpdl_count, Qnil);
2158 2200
2159 /* If there has been no change in the Lisp-level contents 2201 /* If there has been no change in the Lisp-level contents
2160 of the menu bar, skip redisplaying it. Just exit. */ 2202 of the menu bar, skip redisplaying it. Just exit. */
2161 2203
2204 /* Compare the new menu items with the ones computed last time. */
2162 for (i = 0; i < previous_menu_items_used; i++) 2205 for (i = 0; i < previous_menu_items_used; i++)
2163 if (menu_items_used == i 2206 if (menu_items_used == i
2164 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i]))) 2207 || (!EQ (previous_items[i], XVECTOR (menu_items)->contents[i])))
2165 break; 2208 break;
2166 if (i == menu_items_used && i == previous_menu_items_used && i != 0) 2209 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
2167 { 2210 {
2211 /* The menu items have not changed. Don't bother updating
2212 the menus in any form, since it would be a no-op. */
2168 free_menubar_widget_value_tree (first_wv); 2213 free_menubar_widget_value_tree (first_wv);
2169 discard_menu_items (); 2214 discard_menu_items ();
2170 2215 unbind_to (specpdl_count, Qnil);
2171 return; 2216 return;
2172 } 2217 }
2173 2218
2219 /* The menu items are different, so store them in the frame. */
2220 f->menu_bar_vector = menu_items;
2221 f->menu_bar_items_used = menu_items_used;
2222
2223 /* This calls restore_menu_items to restore menu_items, etc.,
2224 as they were outside. */
2225 unbind_to (specpdl_count, Qnil);
2226
2174 /* Now GC cannot happen during the lifetime of the widget_value, 2227 /* Now GC cannot happen during the lifetime of the widget_value,
2175 so it's safe to store data from a Lisp_String. */ 2228 so it's safe to store data from a Lisp_String. */
2176 wv = first_wv->contents; 2229 wv = first_wv->contents;
@@ -2185,9 +2238,6 @@ set_frame_menubar (f, first_time, deep_p)
2185 wv = wv->next; 2238 wv = wv->next;
2186 } 2239 }
2187 2240
2188 f->menu_bar_vector = menu_items;
2189 f->menu_bar_items_used = menu_items_used;
2190 discard_menu_items ();
2191 } 2241 }
2192 else 2242 else
2193 { 2243 {