aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2006-01-16 06:59:21 +0000
committerMiles Bader2006-01-16 06:59:21 +0000
commit6a2bd1a5019d2130c87ac5cf17f1322bf614b624 (patch)
tree8e72a4a1b7c177b494ae7721f00ea27b14f9f439 /src
parent5bb51be51248803e7400837b83c711854fa86648 (diff)
parent292f71fe67394186e943783bef808c611699b63c (diff)
downloademacs-6a2bd1a5019d2130c87ac5cf17f1322bf614b624.tar.gz
emacs-6a2bd1a5019d2130c87ac5cf17f1322bf614b624.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-95
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 598-615) - Update from CVS - Remove lisp/toolbar directory - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 142-146) - Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog125
-rw-r--r--src/buffer.c3
-rw-r--r--src/ccl.c1
-rw-r--r--src/emacs.c2
-rw-r--r--src/fileio.c1
-rw-r--r--src/image.c109
-rw-r--r--src/lread.c38
-rw-r--r--src/mac.c40
-rw-r--r--src/macfns.c21
-rw-r--r--src/macterm.c671
-rw-r--r--src/macterm.h2
-rw-r--r--src/minibuf.c42
-rw-r--r--src/search.c4
-rw-r--r--src/syssignal.h5
-rw-r--r--src/term.c4
-rw-r--r--src/unexelf.c14
-rw-r--r--src/window.c1
-rw-r--r--src/xterm.c1
18 files changed, 535 insertions, 549 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3feb061a654..00b66dbd06f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,119 @@
12005-10-21 Richard M. Stallman <rms@gnu.org>
2
3 * lread.c (Fload): Simplify gcpro structure.
4 Gcpro FOUND as well as FILE, but not EFOUND.
5 Unless preloading, record FOUND instead of FILE in Vload_history.
6 Rename repeat local FILE to MSG_FILE.
7 (syms_of_lread) <load-history>: Doc fix.
8
92005-10-21 Kenichi Handa <handa@m17n.org>
10
11 * search.c (boyer_moore): Surround the '||' part of expression in
12 `if' condition by parentheses explicitly.
13
142005-10-20 Kim F. Storm <storm@cua.dk>
15
16 * buffer.c (clone_per_buffer_values): Remove unused var tem.
17 (init_buffer): Remove unused vars dotstat, pwdstat.
18
19 * ccl.c (check_ccl_update): Remove unused var vp.
20
21 * fileio.c (auto_save_error): Call SAFE_FREE.
22
23 * fns.c (Fchar_table_range): Remove unused var i.
24
25 * minibuf.c (display_completion_list_1): New wrapper function
26 for Fdisplay_completion_list.
27 (Fminibuffer_completion_help): Use it.
28
29 * term.c (encode_terminal_code): Remove unused var src_start.
30
31 * window.c (Fwindow_tree): Remove unused var alist.
32
33 * xterm.c (x_calc_absolute_position): Remove unused vars win_x, win_y.
34
352005-10-20 Aubrey Jaffer <agj@alum.mit.edu> (tiny change)
36
37 * unexelf.c (unexec): Fix calls to `fatal' with less than 3
38 arguments.
39
402005-10-20 Olli Savia <ops@iki.fi> (tiny change)
41
42 * syssignal.h [__Lynx__]: Undef SIGPOLL along with SIGIO.
43
442005-10-20 Andreas Schwab <schwab@suse.de>
45
46 * minibuf.c (Fdisplay_completion_list): Doc fix.
47
482005-10-19 Kim F. Storm <storm@cua.dk>
49
50 * image.c (check_image_size): Handle integer Vmax_image_size value
51 directly as max pixel value. Use default frame size for null frame.
52 (syms_of_image) <max-image-size>: Describe integer value.
53
542005-10-19 Romain Francoise <romain@orebokech.com>
55
56 * emacs.c (main): Update copyright year.
57
582005-10-18 Chong Yidong <cyd@stupidchicken.com>
59
60 * image.c (Vmax_image_size): New variable.
61 (check_image_size): New function.
62 (xbm_read_bitmap_data, pbm_load, png_load, jpeg_load, tiff_load)
63 (gif_load, gs_load): Use it.
64 (lookup_image): Try loading again if previous load failed.
65 (xbm_read_bitmap_data): Add a new argument, a pointer to the frame
66 to display in, NULL if none.
67 (xbm_load_image, xbm_file_p): Pass xbm_read_bitmap_data the new
68 argument.
69
702005-10-18 Richard M. Stallman <rms@gnu.org>
71
72 * search.c (Fstring_match): Doc fix.
73
742005-10-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
75
76 * macterm.c (note_mouse_movement): Use PtInRect.
77 (XTread_socket): Also ignore mouse motion just before a button
78 release event. Don't process button release event when mouse is
79 not grabbed.
80
812005-10-16 Masatake YAMATO <jet@gyve.org>
82
83 * minibuf.c (Fdisplay_completion_list): Add new optional
84 argument COMMON_SUBSTRING. Bind `completion-common-substring'
85 to the optional argument during running `completion-setup-hook'.
86
872005-10-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
88
89 * mac.c [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp):
90 Allow nil as argument.
91 [TARGET_API_MAC_CARBON] (Fmac_code_convert_string): Regard nil
92 for encoding arguments as UTF-16 in native byte order, no BOM.
93
94 * macfns.c (Fx_create_frame): Add debugging code.
95 (Fx_show_tip): Set frame pixel width and height.
96
97 * macterm.c (MAC_WINDOW_NORMAL_GC): Remove macro.
98 (FRAME_NORMAL_GC): New macro.
99 (mac_draw_line, mac_clear_area, mac_clear_window)
100 (mac_fill_rectangle, mac_draw_string, mac_draw_string_16)
101 (mac_draw_image_string, mac_draw_image_string_16): Rename from
102 XDrawLine, XClearArea, XClearWindow, XFillRectangle, XDrawString,
103 XDrawString16, XDrawImageString, and XDrawImageString16, respectively.
104 All uses changed.
105 (mac_draw_line, mac_erase_rectangle, mac_clear_area)
106 (mac_clear_window, mac_draw_bitmap, mac_draw_rectangle)
107 (mac_invert_rectangle, mac_draw_string_common, mac_draw_string)
108 (mac_draw_string_16, mac_draw_image_string)
109 (mac_draw_image_string_16, mac_copy_area, mac_copy_area_with_mask)
110 (mac_scroll_area): Drawing functions now take frame as destination.
111 All uses changed.
112 (mac_draw_string_common): Get port height with FRAME_PIXEL_HEIGHT.
113 (x_draw_fringe_bitmap): Set clipping area in face->gc.
114
115 * macterm.h (mac_clear_area): Add extern.
116
12005-10-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> 1172005-10-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2 118
3 * macterm.c (note_mouse_movement, XTread_socket): Apply 2005-10-14 119 * macterm.c (note_mouse_movement, XTread_socket): Apply 2005-10-14
@@ -193,7 +309,7 @@
193 (FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc. 309 (FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc.
194 310
195 * xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT. 311 * xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT.
196 Add debug code. 312 Add debugging code.
197 313
1982005-10-08 Kim F. Storm <storm@cua.dk> 3142005-10-08 Kim F. Storm <storm@cua.dk>
199 315
@@ -237,6 +353,11 @@
237 * xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in 353 * xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in
238 struct glyph_string to for_overlaps. 354 struct glyph_string to for_overlaps.
239 355
3562005-10-04 Richard M. Stallman <rms@gnu.org>
357
358 * alloc.c (refill_memory_reserve): Conditionalize the body,
359 not the function's existence.
360
2402005-10-04 Kim F. Storm <storm@cua.dk> 3612005-10-04 Kim F. Storm <storm@cua.dk>
241 362
242 * window.c (window_split_tree): New function. 363 * window.c (window_split_tree): New function.
@@ -278,7 +399,7 @@
278 * keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler. 399 * keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler.
279 400
280 * macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c. 401 * macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c.
281 (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debug code. 402 (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debugging code.
282 (Fx_create_frame, x_create_tip_frame) [USE_ATSUI]: 403 (Fx_create_frame, x_create_tip_frame) [USE_ATSUI]:
283 Try ATSUI-compatible 12pt Monaco font first. 404 Try ATSUI-compatible 12pt Monaco font first.
284 405
diff --git a/src/buffer.c b/src/buffer.c
index e8a45f42342..2c02ffacc1d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -486,7 +486,7 @@ static void
486clone_per_buffer_values (from, to) 486clone_per_buffer_values (from, to)
487 struct buffer *from, *to; 487 struct buffer *from, *to;
488{ 488{
489 Lisp_Object to_buffer, tem; 489 Lisp_Object to_buffer;
490 int offset; 490 int offset;
491 491
492 XSETBUFFER (to_buffer, to); 492 XSETBUFFER (to_buffer, to);
@@ -5128,7 +5128,6 @@ void
5128init_buffer () 5128init_buffer ()
5129{ 5129{
5130 char *pwd; 5130 char *pwd;
5131 struct stat dotstat, pwdstat;
5132 Lisp_Object temp; 5131 Lisp_Object temp;
5133 int len; 5132 int len;
5134 5133
diff --git a/src/ccl.c b/src/ccl.c
index a785707295c..7f6ec1a7aa3 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1940,7 +1940,6 @@ int
1940check_ccl_update (ccl) 1940check_ccl_update (ccl)
1941 struct ccl_program *ccl; 1941 struct ccl_program *ccl;
1942{ 1942{
1943 struct Lisp_Vector *vp;
1944 Lisp_Object slot, ccl_prog; 1943 Lisp_Object slot, ccl_prog;
1945 1944
1946 if (ccl->idx < 0) 1945 if (ccl->idx < 0)
diff --git a/src/emacs.c b/src/emacs.c
index 0149bec6d5e..0193043ed2d 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -896,7 +896,7 @@ main (argc, argv
896 else 896 else
897 { 897 {
898 printf ("GNU Emacs %s\n", SDATA (tem)); 898 printf ("GNU Emacs %s\n", SDATA (tem));
899 printf ("Copyright (C) 2004 Free Software Foundation, Inc.\n"); 899 printf ("Copyright (C) 2005 Free Software Foundation, Inc.\n");
900 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n"); 900 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
901 printf ("You may redistribute copies of Emacs\n"); 901 printf ("You may redistribute copies of Emacs\n");
902 printf ("under the terms of the GNU General Public License.\n"); 902 printf ("under the terms of the GNU General Public License.\n");
diff --git a/src/fileio.c b/src/fileio.c
index 16eb0475a2b..2e63a60fdb9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5711,6 +5711,7 @@ auto_save_error (error)
5711 Fsleep_for (make_number (1), Qnil); 5711 Fsleep_for (make_number (1), Qnil);
5712 } 5712 }
5713 5713
5714 SAFE_FREE ();
5714 UNGCPRO; 5715 UNGCPRO;
5715 return Qnil; 5716 return Qnil;
5716} 5717}
diff --git a/src/image.c b/src/image.c
index 2463c24a33a..1996d8477e9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1099,7 +1099,10 @@ or omitted means use the selected frame. */)
1099 1099
1100static struct image *make_image P_ ((Lisp_Object spec, unsigned hash)); 1100static struct image *make_image P_ ((Lisp_Object spec, unsigned hash));
1101static void free_image P_ ((struct frame *f, struct image *img)); 1101static void free_image P_ ((struct frame *f, struct image *img));
1102static int check_image_size P_ ((struct frame *f, int width, int height));
1102 1103
1104#define MAX_IMAGE_SIZE 6.0
1105Lisp_Object Vmax_image_size;
1103 1106
1104/* Allocate and return a new image structure for image specification 1107/* Allocate and return a new image structure for image specification
1105 SPEC. SPEC has a hash value of HASH. */ 1108 SPEC. SPEC has a hash value of HASH. */
@@ -1151,6 +1154,39 @@ free_image (f, img)
1151 } 1154 }
1152} 1155}
1153 1156
1157/* Return 1 if the given widths and heights are valid for display;
1158 otherwise, return 0. */
1159
1160int
1161check_image_size (f, width, height)
1162 struct frame *f;
1163 int width;
1164 int height;
1165{
1166 int w, h;
1167
1168 if (width <= 0 || height <= 0)
1169 return 0;
1170
1171 if (INTEGERP (Vmax_image_size))
1172 w = h = XINT (Vmax_image_size);
1173 else if (FLOATP (Vmax_image_size))
1174 {
1175 if (f != NULL)
1176 {
1177 w = FRAME_PIXEL_WIDTH (f);
1178 h = FRAME_PIXEL_HEIGHT (f);
1179 }
1180 else
1181 w = h = 1024; /* Arbitrary size for unknown frame. */
1182 w = (int) (XFLOAT_DATA (Vmax_image_size) * w);
1183 h = (int) (XFLOAT_DATA (Vmax_image_size) * h);
1184 }
1185 else
1186 return 1;
1187
1188 return (width <= w && height <= h);
1189}
1154 1190
1155/* Prepare image IMG for display on frame F. Must be called before 1191/* Prepare image IMG for display on frame F. Must be called before
1156 drawing an image. */ 1192 drawing an image. */
@@ -1708,6 +1744,12 @@ lookup_image (f, spec)
1708 if (img->hash == hash && !NILP (Fequal (img->spec, spec))) 1744 if (img->hash == hash && !NILP (Fequal (img->spec, spec)))
1709 break; 1745 break;
1710 1746
1747 if (img && img->load_failed_p)
1748 {
1749 free_image (f, img);
1750 img = NULL;
1751 }
1752
1711 /* If not found, create a new image and cache it. */ 1753 /* If not found, create a new image and cache it. */
1712 if (img == NULL) 1754 if (img == NULL)
1713 { 1755 {
@@ -2551,7 +2593,8 @@ static int xbm_load P_ ((struct frame *f, struct image *img));
2551static int xbm_load_image P_ ((struct frame *f, struct image *img, 2593static int xbm_load_image P_ ((struct frame *f, struct image *img,
2552 unsigned char *, unsigned char *)); 2594 unsigned char *, unsigned char *));
2553static int xbm_image_p P_ ((Lisp_Object object)); 2595static int xbm_image_p P_ ((Lisp_Object object));
2554static int xbm_read_bitmap_data P_ ((unsigned char *, unsigned char *, 2596static int xbm_read_bitmap_data P_ ((struct frame *f,
2597 unsigned char *, unsigned char *,
2555 int *, int *, unsigned char **)); 2598 int *, int *, unsigned char **));
2556static int xbm_file_p P_ ((Lisp_Object)); 2599static int xbm_file_p P_ ((Lisp_Object));
2557 2600
@@ -2939,7 +2982,8 @@ Create_Pixmap_From_Bitmap_Data(f, img, data, fg, bg, non_default_colors)
2939 CONTENTS looks like an in-memory XBM file. */ 2982 CONTENTS looks like an in-memory XBM file. */
2940 2983
2941static int 2984static int
2942xbm_read_bitmap_data (contents, end, width, height, data) 2985xbm_read_bitmap_data (f, contents, end, width, height, data)
2986 struct frame *f;
2943 unsigned char *contents, *end; 2987 unsigned char *contents, *end;
2944 int *width, *height; 2988 int *width, *height;
2945 unsigned char **data; 2989 unsigned char **data;
@@ -2992,7 +3036,7 @@ xbm_read_bitmap_data (contents, end, width, height, data)
2992 expect (XBM_TK_NUMBER); 3036 expect (XBM_TK_NUMBER);
2993 } 3037 }
2994 3038
2995 if (*width < 0 || *height < 0) 3039 if (!check_image_size (f, *width, *height))
2996 goto failure; 3040 goto failure;
2997 else if (data == NULL) 3041 else if (data == NULL)
2998 goto success; 3042 goto success;
@@ -3096,7 +3140,7 @@ xbm_load_image (f, img, contents, end)
3096 unsigned char *data; 3140 unsigned char *data;
3097 int success_p = 0; 3141 int success_p = 0;
3098 3142
3099 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data); 3143 rc = xbm_read_bitmap_data (f, contents, end, &img->width, &img->height, &data);
3100 if (rc) 3144 if (rc)
3101 { 3145 {
3102 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); 3146 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
@@ -3150,7 +3194,7 @@ xbm_file_p (data)
3150{ 3194{
3151 int w, h; 3195 int w, h;
3152 return (STRINGP (data) 3196 return (STRINGP (data)
3153 && xbm_read_bitmap_data (SDATA (data), 3197 && xbm_read_bitmap_data (NULL, SDATA (data),
3154 (SDATA (data) 3198 (SDATA (data)
3155 + SBYTES (data)), 3199 + SBYTES (data)),
3156 &w, &h, NULL)); 3200 &w, &h, NULL));
@@ -5465,8 +5509,7 @@ pbm_load (f, img)
5465 max_color_idx = 255; 5509 max_color_idx = 255;
5466 } 5510 }
5467 5511
5468 if (width < 0 5512 if (!check_image_size (f, width, height)
5469 || height < 0
5470 || (type != PBM_MONO && max_color_idx < 0)) 5513 || (type != PBM_MONO && max_color_idx < 0))
5471 goto error; 5514 goto error;
5472 5515
@@ -5966,6 +6009,9 @@ png_load (f, img)
5966 fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 6009 fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
5967 &interlace_type, NULL, NULL); 6010 &interlace_type, NULL, NULL);
5968 6011
6012 if (!check_image_size (f, width, height))
6013 goto error;
6014
5969 /* If image contains simply transparency data, we prefer to 6015 /* If image contains simply transparency data, we prefer to
5970 construct a clipping mask. */ 6016 construct a clipping mask. */
5971 if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) 6017 if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
@@ -6726,6 +6772,12 @@ jpeg_load (f, img)
6726 width = img->width = cinfo.output_width; 6772 width = img->width = cinfo.output_width;
6727 height = img->height = cinfo.output_height; 6773 height = img->height = cinfo.output_height;
6728 6774
6775 if (!check_image_size (f, width, height))
6776 {
6777 image_error ("Invalid image size", Qnil, Qnil);
6778 longjmp (mgr.setjmp_buffer, 2);
6779 }
6780
6729 /* Create X image and pixmap. */ 6781 /* Create X image and pixmap. */
6730 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6782 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6731 longjmp (mgr.setjmp_buffer, 2); 6783 longjmp (mgr.setjmp_buffer, 2);
@@ -7155,6 +7207,14 @@ tiff_load (f, img)
7155 of width x height 32-bit values. */ 7207 of width x height 32-bit values. */
7156 fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); 7208 fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
7157 fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); 7209 fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
7210
7211 if (!check_image_size (f, width, height))
7212 {
7213 image_error ("Invalid image size", Qnil, Qnil);
7214 UNGCPRO;
7215 return 0;
7216 }
7217
7158 buf = (uint32 *) xmalloc (width * height * sizeof *buf); 7218 buf = (uint32 *) xmalloc (width * height * sizeof *buf);
7159 7219
7160 rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); 7220 rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
@@ -7459,6 +7519,15 @@ gif_load (f, img)
7459 } 7519 }
7460 } 7520 }
7461 7521
7522 /* Before reading entire contents, check the declared image size. */
7523 if (!check_image_size (f, gif->SWidth, gif->SHeight))
7524 {
7525 image_error ("Invalid image size", Qnil, Qnil);
7526 fn_DGifCloseFile (gif);
7527 UNGCPRO;
7528 return 0;
7529 }
7530
7462 /* Read entire contents. */ 7531 /* Read entire contents. */
7463 rc = fn_DGifSlurp (gif); 7532 rc = fn_DGifSlurp (gif);
7464 if (rc == GIF_ERROR) 7533 if (rc == GIF_ERROR)
@@ -7492,6 +7561,14 @@ gif_load (f, img)
7492 max (gif->Image.Top + gif->Image.Height, 7561 max (gif->Image.Top + gif->Image.Height,
7493 image_top + image_height)); 7562 image_top + image_height));
7494 7563
7564 if (!check_image_size (f, width, height))
7565 {
7566 image_error ("Invalid image size", Qnil, Qnil);
7567 fn_DGifCloseFile (gif);
7568 UNGCPRO;
7569 return 0;
7570 }
7571
7495 /* Create the X image and pixmap. */ 7572 /* Create the X image and pixmap. */
7496 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 7573 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
7497 { 7574 {
@@ -7944,6 +8021,12 @@ gs_load (f, img)
7944 in_height = XFASTINT (pt_height) / 72.0; 8021 in_height = XFASTINT (pt_height) / 72.0;
7945 img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy; 8022 img->height = in_height * FRAME_X_DISPLAY_INFO (f)->resy;
7946 8023
8024 if (!check_image_size (f, img->width, img->height))
8025 {
8026 image_error ("Invalid image size", Qnil, Qnil);
8027 return 0;
8028 }
8029
7947 /* Create the pixmap. */ 8030 /* Create the pixmap. */
7948 xassert (img->pixmap == NO_PIXMAP); 8031 xassert (img->pixmap == NO_PIXMAP);
7949 8032
@@ -8217,6 +8300,18 @@ listed; they're always supported. */);
8217 Vimage_library_alist = Qnil; 8300 Vimage_library_alist = Qnil;
8218 Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt); 8301 Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
8219 8302
8303 DEFVAR_LISP ("max-image-size", &Vmax_image_size,
8304 doc: /* Maximum size of images.
8305Emacs will not load an image into memory if its pixel width or
8306pixel height exceeds this limit.
8307
8308If the value is an integer, it directly specifies the maximum
8309image height and width, measured in pixels. If it is a floating
8310point number, it specifies the maximum image height and width
8311as a ratio to the frame height and width. If the value is
8312non-numeric, there is no explicit limit on the size of images. */);
8313 Vmax_image_size = make_float (MAX_IMAGE_SIZE);
8314
8220 Vimage_type_cache = Qnil; 8315 Vimage_type_cache = Qnil;
8221 staticpro (&Vimage_type_cache); 8316 staticpro (&Vimage_type_cache);
8222 8317
diff --git a/src/lread.c b/src/lread.c
index 7b91260cda9..5778a9d3a0c 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -848,6 +848,11 @@ If optional fourth arg NOSUFFIX is non-nil, don't try adding
848If optional fifth arg MUST-SUFFIX is non-nil, insist on 848If optional fifth arg MUST-SUFFIX is non-nil, insist on
849 the suffix `.elc' or `.el'; don't accept just FILE unless 849 the suffix `.elc' or `.el'; don't accept just FILE unless
850 it ends in one of those suffixes or includes a directory name. 850 it ends in one of those suffixes or includes a directory name.
851
852Loading a file records its definitions, and its `provide' and
853`require' calls, in an element of `load-history' whose
854car is the file name loaded. See `load-history'.
855
851Return t if file exists. */) 856Return t if file exists. */)
852 (file, noerror, nomessage, nosuffix, must_suffix) 857 (file, noerror, nomessage, nosuffix, must_suffix)
853 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; 858 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
@@ -856,7 +861,7 @@ Return t if file exists. */)
856 register int fd = -1; 861 register int fd = -1;
857 int count = SPECPDL_INDEX (); 862 int count = SPECPDL_INDEX ();
858 Lisp_Object temp; 863 Lisp_Object temp;
859 struct gcpro gcpro1; 864 struct gcpro gcpro1, gcpro2;
860 Lisp_Object found, efound; 865 Lisp_Object found, efound;
861 /* 1 means we printed the ".el is newer" message. */ 866 /* 1 means we printed the ".el is newer" message. */
862 int newer = 0; 867 int newer = 0;
@@ -905,7 +910,8 @@ Return t if file exists. */)
905 int size = SBYTES (file); 910 int size = SBYTES (file);
906 Lisp_Object tmp[2]; 911 Lisp_Object tmp[2];
907 912
908 GCPRO1 (file); 913 found = Qnil;
914 GCPRO2 (file, found);
909 915
910 if (! NILP (must_suffix)) 916 if (! NILP (must_suffix))
911 { 917 {
@@ -994,6 +1000,8 @@ Return t if file exists. */)
994 struct stat s1, s2; 1000 struct stat s1, s2;
995 int result; 1001 int result;
996 1002
1003 GCPRO2 (file, found);
1004
997 if (version < 0 1005 if (version < 0
998 && ! (version = safe_to_load_p (fd))) 1006 && ! (version = safe_to_load_p (fd)))
999 { 1007 {
@@ -1011,7 +1019,6 @@ Return t if file exists. */)
1011 1019
1012 compiled = 1; 1020 compiled = 1;
1013 1021
1014 GCPRO1 (efound);
1015 efound = ENCODE_FILE (found); 1022 efound = ENCODE_FILE (found);
1016 1023
1017#ifdef DOS_NT 1024#ifdef DOS_NT
@@ -1021,7 +1028,6 @@ Return t if file exists. */)
1021 SSET (efound, SBYTES (efound) - 1, 0); 1028 SSET (efound, SBYTES (efound) - 1, 0);
1022 result = stat ((char *)SDATA (efound), &s2); 1029 result = stat ((char *)SDATA (efound), &s2);
1023 SSET (efound, SBYTES (efound) - 1, 'c'); 1030 SSET (efound, SBYTES (efound) - 1, 'c');
1024 UNGCPRO;
1025 1031
1026 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) 1032 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
1027 { 1033 {
@@ -1031,12 +1037,13 @@ Return t if file exists. */)
1031 /* If we won't print another message, mention this anyway. */ 1037 /* If we won't print another message, mention this anyway. */
1032 if (!NILP (nomessage)) 1038 if (!NILP (nomessage))
1033 { 1039 {
1034 Lisp_Object file; 1040 Lisp_Object msg_file;
1035 file = Fsubstring (found, make_number (0), make_number (-1)); 1041 msg_file = Fsubstring (found, make_number (0), make_number (-1));
1036 message_with_string ("Source file `%s' newer than byte-compiled file", 1042 message_with_string ("Source file `%s' newer than byte-compiled file",
1037 file, 1); 1043 msg_file, 1);
1038 } 1044 }
1039 } 1045 }
1046 UNGCPRO;
1040 } 1047 }
1041 } 1048 }
1042 else 1049 else
@@ -1055,12 +1062,12 @@ Return t if file exists. */)
1055 } 1062 }
1056 } 1063 }
1057 1064
1065 GCPRO2 (file, found);
1066
1058#ifdef WINDOWSNT 1067#ifdef WINDOWSNT
1059 emacs_close (fd); 1068 emacs_close (fd);
1060 GCPRO1 (efound);
1061 efound = ENCODE_FILE (found); 1069 efound = ENCODE_FILE (found);
1062 stream = fopen ((char *) SDATA (efound), fmode); 1070 stream = fopen ((char *) SDATA (efound), fmode);
1063 UNGCPRO;
1064#else /* not WINDOWSNT */ 1071#else /* not WINDOWSNT */
1065 stream = fdopen (fd, fmode); 1072 stream = fdopen (fd, fmode);
1066#endif /* not WINDOWSNT */ 1073#endif /* not WINDOWSNT */
@@ -1087,7 +1094,6 @@ Return t if file exists. */)
1087 message_with_string ("Loading %s...", file, 1); 1094 message_with_string ("Loading %s...", file, 1);
1088 } 1095 }
1089 1096
1090 GCPRO1 (file);
1091 record_unwind_protect (load_unwind, make_save_value (stream, 0)); 1097 record_unwind_protect (load_unwind, make_save_value (stream, 0));
1092 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 1098 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
1093 specbind (Qload_file_name, found); 1099 specbind (Qload_file_name, found);
@@ -1096,8 +1102,9 @@ Return t if file exists. */)
1096 = Fcons (make_number (fileno (stream)), load_descriptor_list); 1102 = Fcons (make_number (fileno (stream)), load_descriptor_list);
1097 load_in_progress++; 1103 load_in_progress++;
1098 if (! version || version >= 22) 1104 if (! version || version >= 22)
1099 readevalloop (Qget_file_char, stream, file, Feval, 1105 readevalloop (Qget_file_char, stream,
1100 0, Qnil, Qnil, Qnil, Qnil); 1106 (! NILP (Vpurify_flag) ? file : found),
1107 Feval, 0, Qnil, Qnil, Qnil, Qnil);
1101 else 1108 else
1102 { 1109 {
1103 /* We can't handle a file which was compiled with 1110 /* We can't handle a file which was compiled with
@@ -4017,7 +4024,7 @@ when the corresponding call to `provide' is made. */);
4017 Vafter_load_alist = Qnil; 4024 Vafter_load_alist = Qnil;
4018 4025
4019 DEFVAR_LISP ("load-history", &Vload_history, 4026 DEFVAR_LISP ("load-history", &Vload_history,
4020 doc: /* Alist mapping source file names to symbols and features. 4027 doc: /* Alist mapping file names to symbols and features.
4021Each alist element is a list that starts with a file name, 4028Each alist element is a list that starts with a file name,
4022except for one element (optional) that starts with nil and describes 4029except for one element (optional) that starts with nil and describes
4023definitions evaluated from buffers not visiting files. 4030definitions evaluated from buffers not visiting files.
@@ -4026,7 +4033,10 @@ and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
4026`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. 4033`(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
4027An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)', 4034An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)',
4028and means that SYMBOL was an autoload before this file redefined it 4035and means that SYMBOL was an autoload before this file redefined it
4029as a function. */); 4036as a function.
4037
4038For a preloaded file, the file name recorded is relative to the main Lisp
4039directory. These names are converted to absolute by `file-loadhist-lookup'. */);
4030 Vload_history = Qnil; 4040 Vload_history = Qnil;
4031 4041
4032 DEFVAR_LISP ("load-file-name", &Vload_file_name, 4042 DEFVAR_LISP ("load-file-name", &Vload_file_name,
diff --git a/src/mac.c b/src/mac.c
index 0d8c99ffb1e..4c8e78ade25 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -3411,7 +3411,7 @@ terminate_applescript()
3411} 3411}
3412 3412
3413/* Convert a lisp string to the 4 byte character code. */ 3413/* Convert a lisp string to the 4 byte character code. */
3414 3414
3415OSType 3415OSType
3416mac_get_code_from_arg(Lisp_Object arg, OSType defCode) 3416mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
3417{ 3417{
@@ -3419,7 +3419,7 @@ mac_get_code_from_arg(Lisp_Object arg, OSType defCode)
3419 if (NILP(arg)) 3419 if (NILP(arg))
3420 { 3420 {
3421 result = defCode; 3421 result = defCode;
3422 } 3422 }
3423 else 3423 else
3424 { 3424 {
3425 /* check type string */ 3425 /* check type string */
@@ -3483,7 +3483,7 @@ DEFUN ("mac-get-file-creator", Fmac_get_file_creator, Smac_get_file_creator, 1,
3483 3483
3484 status = FSpGetFInfo (&fss, &finder_info); 3484 status = FSpGetFInfo (&fss, &finder_info);
3485#endif 3485#endif
3486 if (status == noErr) 3486 if (status == noErr)
3487 { 3487 {
3488#ifdef MAC_OSX 3488#ifdef MAC_OSX
3489 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator); 3489 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileCreator);
@@ -3538,7 +3538,7 @@ DEFUN ("mac-get-file-type", Fmac_get_file_type, Smac_get_file_type, 1, 1, 0,
3538 3538
3539 status = FSpGetFInfo (&fss, &finder_info); 3539 status = FSpGetFInfo (&fss, &finder_info);
3540#endif 3540#endif
3541 if (status == noErr) 3541 if (status == noErr)
3542 { 3542 {
3543#ifdef MAC_OSX 3543#ifdef MAC_OSX
3544 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType); 3544 result = mac_get_object_from_code(((FileInfo*)&catalogInfo.finderInfo)->fileType);
@@ -3596,7 +3596,7 @@ assumed. Return non-nil if successful. */)
3596 3596
3597 status = FSpGetFInfo (&fss, &finder_info); 3597 status = FSpGetFInfo (&fss, &finder_info);
3598#endif 3598#endif
3599 if (status == noErr) 3599 if (status == noErr)
3600 { 3600 {
3601#ifdef MAC_OSX 3601#ifdef MAC_OSX
3602 ((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode; 3602 ((FileInfo*)&catalogInfo.finderInfo)->fileCreator = cCode;
@@ -3656,7 +3656,7 @@ CODE must be a 4-character string. Return non-nil if successful. */)
3656 3656
3657 status = FSpGetFInfo (&fss, &finder_info); 3657 status = FSpGetFInfo (&fss, &finder_info);
3658#endif 3658#endif
3659 if (status == noErr) 3659 if (status == noErr)
3660 { 3660 {
3661#ifdef MAC_OSX 3661#ifdef MAC_OSX
3662 ((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode; 3662 ((FileInfo*)&catalogInfo.finderInfo)->fileType = cCode;
@@ -3968,10 +3968,13 @@ get_cfstring_encoding_from_lisp (obj)
3968 CFStringRef iana_name; 3968 CFStringRef iana_name;
3969 CFStringEncoding encoding = kCFStringEncodingInvalidId; 3969 CFStringEncoding encoding = kCFStringEncodingInvalidId;
3970 3970
3971 if (NILP (obj))
3972 return kCFStringEncodingUnicode;
3973
3971 if (INTEGERP (obj)) 3974 if (INTEGERP (obj))
3972 return XINT (obj); 3975 return XINT (obj);
3973 3976
3974 if (SYMBOLP (obj) && !NILP (obj) && !NILP (Fcoding_system_p (obj))) 3977 if (SYMBOLP (obj) && !NILP (Fcoding_system_p (obj)))
3975 { 3978 {
3976 Lisp_Object coding_spec, plist; 3979 Lisp_Object coding_spec, plist;
3977 3980
@@ -4115,7 +4118,8 @@ DEFUN ("mac-code-convert-string", Fmac_code_convert_string, Smac_code_convert_st
4115 doc: /* Convert STRING from SOURCE encoding to TARGET encoding. 4118 doc: /* Convert STRING from SOURCE encoding to TARGET encoding.
4116The conversion is performed using the converter provided by the system. 4119The conversion is performed using the converter provided by the system.
4117Each encoding is specified by either a coding system symbol, a mime 4120Each encoding is specified by either a coding system symbol, a mime
4118charset string, or an integer as a CFStringEncoding value. 4121charset string, or an integer as a CFStringEncoding value. Nil for
4122encoding means UTF-16 in native byte order, no byte order marker.
4119On Mac OS X 10.2 and later, you can do Unicode Normalization by 4123On Mac OS X 10.2 and later, you can do Unicode Normalization by
4120specifying the optional argument NORMALIZATION-FORM with a symbol NFD, 4124specifying the optional argument NORMALIZATION-FORM with a symbol NFD,
4121NFKD, NFC, NFKC, HFS+D, or HFS+C. 4125NFKD, NFC, NFKC, HFS+D, or HFS+C.
@@ -4126,7 +4130,6 @@ On successful conversion, return the result string, else return nil. */)
4126 Lisp_Object result = Qnil; 4130 Lisp_Object result = Qnil;
4127 CFStringEncoding src_encoding, tgt_encoding; 4131 CFStringEncoding src_encoding, tgt_encoding;
4128 CFStringRef str = NULL; 4132 CFStringRef str = NULL;
4129 CFDataRef data = NULL;
4130 4133
4131 CHECK_STRING (string); 4134 CHECK_STRING (string);
4132 if (!INTEGERP (source) && !STRINGP (source)) 4135 if (!INTEGERP (source) && !STRINGP (source))
@@ -4148,7 +4151,7 @@ On successful conversion, return the result string, else return nil. */)
4148 if (src_encoding != kCFStringEncodingInvalidId 4151 if (src_encoding != kCFStringEncodingInvalidId
4149 && tgt_encoding != kCFStringEncodingInvalidId) 4152 && tgt_encoding != kCFStringEncodingInvalidId)
4150 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string), 4153 str = CFStringCreateWithBytes (NULL, SDATA (string), SBYTES (string),
4151 src_encoding, true); 4154 src_encoding, !NILP (source));
4152#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 4155#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
4153 if (str) 4156 if (str)
4154 { 4157 {
@@ -4160,15 +4163,18 @@ On successful conversion, return the result string, else return nil. */)
4160#endif 4163#endif
4161 if (str) 4164 if (str)
4162 { 4165 {
4163 data = CFStringCreateExternalRepresentation (NULL, str, 4166 CFIndex str_len, buf_len;
4164 tgt_encoding, '\0'); 4167
4168 str_len = CFStringGetLength (str);
4169 if (CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
4170 !NILP (target), NULL, 0, &buf_len) == str_len)
4171 {
4172 result = make_uninit_string (buf_len);
4173 CFStringGetBytes (str, CFRangeMake (0, str_len), tgt_encoding, 0,
4174 !NILP (target), SDATA (result), buf_len, NULL);
4175 }
4165 CFRelease (str); 4176 CFRelease (str);
4166 } 4177 }
4167 if (data)
4168 {
4169 result = cfdata_to_lisp (data);
4170 CFRelease (data);
4171 }
4172 4178
4173 UNBLOCK_INPUT; 4179 UNBLOCK_INPUT;
4174 4180
diff --git a/src/macfns.c b/src/macfns.c
index ecee09189f5..8071974c6d4 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1745,8 +1745,7 @@ x_set_tool_bar_lines (f, value, oldval)
1745 int y = nlines * FRAME_LINE_HEIGHT (f); 1745 int y = nlines * FRAME_LINE_HEIGHT (f);
1746 1746
1747 BLOCK_INPUT; 1747 BLOCK_INPUT;
1748 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1748 mac_clear_area (f, 0, y, width, height);
1749 0, y, width, height, 0);
1750 UNBLOCK_INPUT; 1749 UNBLOCK_INPUT;
1751 1750
1752 if (WINDOWP (f->tool_bar_window)) 1751 if (WINDOWP (f->tool_bar_window))
@@ -2439,7 +2438,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2439 frame = Qnil; 2438 frame = Qnil;
2440 GCPRO4 (parms, parent, name, frame); 2439 GCPRO4 (parms, parent, name, frame);
2441 tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer", 2440 tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer",
2442 RES_TYPE_SYMBOL); 2441 RES_TYPE_SYMBOL);
2443 if (EQ (tem, Qnone) || NILP (tem)) 2442 if (EQ (tem, Qnone) || NILP (tem))
2444 f = make_frame_without_minibuffer (Qnil, kb, display); 2443 f = make_frame_without_minibuffer (Qnil, kb, display);
2445 else if (EQ (tem, Qonly)) 2444 else if (EQ (tem, Qonly))
@@ -2480,7 +2479,11 @@ This function is an internal primitive--use `make-frame' instead. */)
2480 if (! STRINGP (f->icon_name)) 2479 if (! STRINGP (f->icon_name))
2481 f->icon_name = Qnil; 2480 f->icon_name = Qnil;
2482 2481
2483/* FRAME_W32_DISPLAY_INFO (f) = dpyinfo; */ 2482/* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */
2483#if GLYPH_DEBUG
2484 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
2485 dpyinfo_refcount = dpyinfo->reference_count;
2486#endif /* GLYPH_DEBUG */
2484#ifdef MULTI_KBOARD 2487#ifdef MULTI_KBOARD
2485 FRAME_KBOARD (f) = kb; 2488 FRAME_KBOARD (f) = kb;
2486#endif 2489#endif
@@ -2606,9 +2609,10 @@ This function is an internal primitive--use `make-frame' instead. */)
2606 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 2609 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
2607 "menuBar", "MenuBar", RES_TYPE_NUMBER); 2610 "menuBar", "MenuBar", RES_TYPE_NUMBER);
2608 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), 2611 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
2609 "toolBar", "ToolBar", RES_TYPE_NUMBER); 2612 "toolBar", "ToolBar", RES_TYPE_NUMBER);
2610 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 2613 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
2611 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); 2614 "bufferPredicate", "BufferPredicate",
2615 RES_TYPE_SYMBOL);
2612 x_default_parameter (f, parms, Qtitle, Qnil, 2616 x_default_parameter (f, parms, Qtitle, Qnil,
2613 "title", "Title", RES_TYPE_STRING); 2617 "title", "Title", RES_TYPE_STRING);
2614 x_default_parameter (f, parms, Qfullscreen, Qnil, 2618 x_default_parameter (f, parms, Qfullscreen, Qnil,
@@ -3593,7 +3597,7 @@ x_create_tip_frame (dpyinfo, parms, text)
3593 3597
3594 FRAME_FONTSET (f) = -1; 3598 FRAME_FONTSET (f) = -1;
3595 f->icon_name = Qnil; 3599 f->icon_name = Qnil;
3596 3600/* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */
3597#if GLYPH_DEBUG 3601#if GLYPH_DEBUG
3598 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; 3602 image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
3599 dpyinfo_refcount = dpyinfo->reference_count; 3603 dpyinfo_refcount = dpyinfo->reference_count;
@@ -4047,6 +4051,9 @@ Text larger than the specified size is clipped. */)
4047 BringToFront (FRAME_MAC_WINDOW (f)); 4051 BringToFront (FRAME_MAC_WINDOW (f));
4048 UNBLOCK_INPUT; 4052 UNBLOCK_INPUT;
4049 4053
4054 FRAME_PIXEL_WIDTH (f) = width;
4055 FRAME_PIXEL_HEIGHT (f) = height;
4056
4050 /* Draw into the window. */ 4057 /* Draw into the window. */
4051 w->must_be_updated_p = 1; 4058 w->must_be_updated_p = 1;
4052 update_single_window (w, 1); 4059 update_single_window (w, 1);
diff --git a/src/macterm.c b/src/macterm.c
index 02dcbf5e04f..f0574c9078f 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -273,7 +273,7 @@ extern void menubar_selection_callback (FRAME_PTR, int);
273#define GC_BACK_COLOR(gc) (&(gc)->back_color) 273#define GC_BACK_COLOR(gc) (&(gc)->back_color)
274#define GC_FONT(gc) ((gc)->xgcv.font) 274#define GC_FONT(gc) ((gc)->xgcv.font)
275#define GC_CLIP_REGION(gc) ((gc)->clip_region) 275#define GC_CLIP_REGION(gc) ((gc)->clip_region)
276#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc) 276#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
277 277
278static RgnHandle saved_port_clip_region = NULL; 278static RgnHandle saved_port_clip_region = NULL;
279 279
@@ -319,13 +319,12 @@ XFreePixmap (display, pixmap)
319/* Mac version of XDrawLine. */ 319/* Mac version of XDrawLine. */
320 320
321static void 321static void
322XDrawLine (display, w, gc, x1, y1, x2, y2) 322mac_draw_line (f, gc, x1, y1, x2, y2)
323 Display *display; 323 struct frame *f;
324 WindowPtr w;
325 GC gc; 324 GC gc;
326 int x1, y1, x2, y2; 325 int x1, y1, x2, y2;
327{ 326{
328 SetPortWindowPort (w); 327 SetPortWindowPort (FRAME_MAC_WINDOW (f));
329 328
330 RGBForeColor (GC_FORE_COLOR (gc)); 329 RGBForeColor (GC_FORE_COLOR (gc));
331 330
@@ -360,15 +359,15 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
360 359
361 360
362static void 361static void
363mac_erase_rectangle (w, gc, x, y, width, height) 362mac_erase_rectangle (f, gc, x, y, width, height)
364 WindowPtr w; 363 struct frame *f;
365 GC gc; 364 GC gc;
366 int x, y; 365 int x, y;
367 unsigned int width, height; 366 unsigned int width, height;
368{ 367{
369 Rect r; 368 Rect r;
370 369
371 SetPortWindowPort (w); 370 SetPortWindowPort (FRAME_MAC_WINDOW (f));
372 371
373 RGBBackColor (GC_BACK_COLOR (gc)); 372 RGBBackColor (GC_BACK_COLOR (gc));
374 SetRect (&r, x, y, x + width, y + height); 373 SetRect (&r, x, y, x + width, y + height);
@@ -377,43 +376,40 @@ mac_erase_rectangle (w, gc, x, y, width, height)
377 EraseRect (&r); 376 EraseRect (&r);
378 mac_end_clip (GC_CLIP_REGION (gc)); 377 mac_end_clip (GC_CLIP_REGION (gc));
379 378
380 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 379 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
381} 380}
382 381
383 382
384/* Mac version of XClearArea. */ 383/* Mac version of XClearArea. */
385 384
386void 385void
387XClearArea (display, w, x, y, width, height, exposures) 386mac_clear_area (f, x, y, width, height)
388 Display *display; 387 struct frame *f;
389 WindowPtr w;
390 int x, y; 388 int x, y;
391 unsigned int width, height; 389 unsigned int width, height;
392 int exposures;
393{ 390{
394 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height); 391 mac_erase_rectangle (f, FRAME_NORMAL_GC (f), x, y, width, height);
395} 392}
396 393
397/* Mac version of XClearWindow. */ 394/* Mac version of XClearWindow. */
398 395
399static void 396static void
400XClearWindow (display, w) 397mac_clear_window (f)
401 Display *display; 398 struct frame *f;
402 WindowPtr w;
403{ 399{
404 SetPortWindowPort (w); 400 SetPortWindowPort (FRAME_MAC_WINDOW (f));
405 401
406 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 402 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
407 403
408#if TARGET_API_MAC_CARBON 404#if TARGET_API_MAC_CARBON
409 { 405 {
410 Rect r; 406 Rect r;
411 407
412 GetWindowPortBounds (w, &r); 408 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
413 EraseRect (&r); 409 EraseRect (&r);
414 } 410 }
415#else /* not TARGET_API_MAC_CARBON */ 411#else /* not TARGET_API_MAC_CARBON */
416 EraseRect (&(w->portRect)); 412 EraseRect (&(FRAME_MAC_WINDOW (f)->portRect));
417#endif /* not TARGET_API_MAC_CARBON */ 413#endif /* not TARGET_API_MAC_CARBON */
418} 414}
419 415
@@ -421,9 +417,8 @@ XClearWindow (display, w)
421/* Mac replacement for XCopyArea. */ 417/* Mac replacement for XCopyArea. */
422 418
423static void 419static void
424mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) 420mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p)
425 Display *display; 421 struct frame *f;
426 WindowPtr w;
427 GC gc; 422 GC gc;
428 int x, y, width, height; 423 int x, y, width, height;
429 unsigned short *bits; 424 unsigned short *bits;
@@ -436,7 +431,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
436 bitmap.baseAddr = (char *)bits; 431 bitmap.baseAddr = (char *)bits;
437 SetRect (&(bitmap.bounds), 0, 0, width, height); 432 SetRect (&(bitmap.bounds), 0, 0, width, height);
438 433
439 SetPortWindowPort (w); 434 SetPortWindowPort (FRAME_MAC_WINDOW (f));
440 435
441 RGBForeColor (GC_FORE_COLOR (gc)); 436 RGBForeColor (GC_FORE_COLOR (gc));
442 RGBBackColor (GC_BACK_COLOR (gc)); 437 RGBBackColor (GC_BACK_COLOR (gc));
@@ -444,17 +439,22 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
444 439
445 mac_begin_clip (GC_CLIP_REGION (gc)); 440 mac_begin_clip (GC_CLIP_REGION (gc));
446#if TARGET_API_MAC_CARBON 441#if TARGET_API_MAC_CARBON
447 LockPortBits (GetWindowPort (w)); 442 {
448 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)), 443 CGrafPtr port;
449 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0); 444
450 UnlockPortBits (GetWindowPort (w)); 445 GetPort (&port);
446 LockPortBits (port);
447 CopyBits (&bitmap, GetPortBitMapForCopyBits (port),
448 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0);
449 UnlockPortBits (port);
450 }
451#else /* not TARGET_API_MAC_CARBON */ 451#else /* not TARGET_API_MAC_CARBON */
452 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, 452 CopyBits (&bitmap, &(FRAME_MAC_WINDOW (f)->portBits), &(bitmap.bounds), &r,
453 overlay_p ? srcOr : srcCopy, 0); 453 overlay_p ? srcOr : srcCopy, 0);
454#endif /* not TARGET_API_MAC_CARBON */ 454#endif /* not TARGET_API_MAC_CARBON */
455 mac_end_clip (GC_CLIP_REGION (gc)); 455 mac_end_clip (GC_CLIP_REGION (gc));
456 456
457 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 457 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
458} 458}
459 459
460 460
@@ -571,16 +571,15 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
571/* Mac replacement for XFillRectangle. */ 571/* Mac replacement for XFillRectangle. */
572 572
573static void 573static void
574XFillRectangle (display, w, gc, x, y, width, height) 574mac_fill_rectangle (f, gc, x, y, width, height)
575 Display *display; 575 struct frame *f;
576 WindowPtr w;
577 GC gc; 576 GC gc;
578 int x, y; 577 int x, y;
579 unsigned int width, height; 578 unsigned int width, height;
580{ 579{
581 Rect r; 580 Rect r;
582 581
583 SetPortWindowPort (w); 582 SetPortWindowPort (FRAME_MAC_WINDOW (f));
584 583
585 RGBForeColor (GC_FORE_COLOR (gc)); 584 RGBForeColor (GC_FORE_COLOR (gc));
586 SetRect (&r, x, y, x + width, y + height); 585 SetRect (&r, x, y, x + width, y + height);
@@ -591,46 +590,18 @@ XFillRectangle (display, w, gc, x, y, width, height)
591} 590}
592 591
593 592
594#if 0 /* TODO: figure out if we need to do this on Mac. */
595static void
596mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
597 Display *display;
598 Pixmap p;
599 GC gc;
600 int x, y;
601 unsigned int width, height;
602{
603 CGrafPtr old_port;
604 GDHandle old_gdh;
605 Rect r;
606
607 GetGWorld (&old_port, &old_gdh);
608 SetGWorld (p, NULL);
609 RGBForeColor (GC_FORE_COLOR (gc));
610 SetRect (&r, x, y, x + width, y + height);
611
612 LockPixels (GetGWorldPixMap (p));
613 PaintRect (&r); /* using foreground color of gc */
614 UnlockPixels (GetGWorldPixMap (p));
615
616 SetGWorld (old_port, old_gdh);
617}
618#endif
619
620
621/* Mac replacement for XDrawRectangle: dest is a window. */ 593/* Mac replacement for XDrawRectangle: dest is a window. */
622 594
623static void 595static void
624mac_draw_rectangle (display, w, gc, x, y, width, height) 596mac_draw_rectangle (f, gc, x, y, width, height)
625 Display *display; 597 struct frame *f;
626 WindowPtr w;
627 GC gc; 598 GC gc;
628 int x, y; 599 int x, y;
629 unsigned int width, height; 600 unsigned int width, height;
630{ 601{
631 Rect r; 602 Rect r;
632 603
633 SetPortWindowPort (w); 604 SetPortWindowPort (FRAME_MAC_WINDOW (f));
634 605
635 RGBForeColor (GC_FORE_COLOR (gc)); 606 RGBForeColor (GC_FORE_COLOR (gc));
636 SetRect (&r, x, y, x + width + 1, y + height + 1); 607 SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -641,35 +612,6 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
641} 612}
642 613
643 614
644#if 0 /* TODO: figure out if we need to do this on Mac. */
645/* Mac replacement for XDrawRectangle: dest is a Pixmap. */
646
647static void
648mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
649 Display *display;
650 Pixmap p;
651 GC gc;
652 int x, y;
653 unsigned int width, height;
654{
655 CGrafPtr old_port;
656 GDHandle old_gdh;
657 Rect r;
658
659 GetGWorld (&old_port, &old_gdh);
660 SetGWorld (p, NULL);
661 RGBForeColor (GC_FORE_COLOR (gc));
662 SetRect (&r, x, y, x + width + 1, y + height + 1);
663
664 LockPixels (GetGWorldPixMap (p));
665 FrameRect (&r); /* using foreground color of gc */
666 UnlockPixels (GetGWorldPixMap (p));
667
668 SetGWorld (old_port, old_gdh);
669}
670#endif
671
672
673#if USE_ATSUI 615#if USE_ATSUI
674static OSStatus 616static OSStatus
675atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout) 617atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
@@ -726,16 +668,16 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
726} 668}
727#endif 669#endif
728 670
671
729static void 672static void
730mac_invert_rectangle (display, w, x, y, width, height) 673mac_invert_rectangle (f, x, y, width, height)
731 Display *display; 674 struct frame *f;
732 WindowPtr w;
733 int x, y; 675 int x, y;
734 unsigned int width, height; 676 unsigned int width, height;
735{ 677{
736 Rect r; 678 Rect r;
737 679
738 SetPortWindowPort (w); 680 SetPortWindowPort (FRAME_MAC_WINDOW (f));
739 681
740 SetRect (&r, x, y, x + width, y + height); 682 SetRect (&r, x, y, x + width, y + height);
741 683
@@ -744,10 +686,8 @@ mac_invert_rectangle (display, w, x, y, width, height)
744 686
745 687
746static void 688static void
747mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 689mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
748 bytes_per_char) 690 struct frame *f;
749 Display *display;
750 WindowPtr w;
751 GC gc; 691 GC gc;
752 int x, y; 692 int x, y;
753 char *buf; 693 char *buf;
@@ -761,7 +701,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
761 } 701 }
762#endif 702#endif
763 703
764 SetPortWindowPort (w); 704 SetPortWindowPort (FRAME_MAC_WINDOW (f));
765 705
766 RGBForeColor (GC_FORE_COLOR (gc)); 706 RGBForeColor (GC_FORE_COLOR (gc));
767 if (mode != srcOr) 707 if (mode != srcOr)
@@ -806,16 +746,13 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
806 { 746 {
807 CGrafPtr port; 747 CGrafPtr port;
808 CGContextRef context; 748 CGContextRef context;
809 Rect rect; 749 float port_height = FRAME_PIXEL_HEIGHT (f);
810 float port_height;
811 ATSUAttributeTag tags[] = {kATSUCGContextTag}; 750 ATSUAttributeTag tags[] = {kATSUCGContextTag};
812 ByteCount sizes[] = {sizeof (CGContextRef)}; 751 ByteCount sizes[] = {sizeof (CGContextRef)};
813 ATSUAttributeValuePtr values[] = {&context}; 752 ATSUAttributeValuePtr values[] = {&context};
814 753
815 GetPort (&port); 754 GetPort (&port);
816 QDBeginCGContext (port, &context); 755 QDBeginCGContext (port, &context);
817 GetPortBounds (port, &rect);
818 port_height = rect.bottom - rect.top;
819 if (gc->n_clip_rects) 756 if (gc->n_clip_rects)
820 { 757 {
821 CGContextTranslateCTM (context, 0, port_height); 758 CGContextTranslateCTM (context, 0, port_height);
@@ -864,7 +801,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
864#endif 801#endif
865 802
866 if (mode != srcOr) 803 if (mode != srcOr)
867 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 804 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
868#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 805#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
869 if (!NILP(Vmac_use_core_graphics)) 806 if (!NILP(Vmac_use_core_graphics))
870 SwapQDTextFlags(savedFlags); 807 SwapQDTextFlags(savedFlags);
@@ -875,73 +812,65 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
875/* Mac replacement for XDrawString. */ 812/* Mac replacement for XDrawString. */
876 813
877static void 814static void
878XDrawString (display, w, gc, x, y, buf, nchars) 815mac_draw_string (f, gc, x, y, buf, nchars)
879 Display *display; 816 struct frame *f;
880 WindowPtr w;
881 GC gc; 817 GC gc;
882 int x, y; 818 int x, y;
883 char *buf; 819 char *buf;
884 int nchars; 820 int nchars;
885{ 821{
886 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcOr, 1); 822 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1);
887} 823}
888 824
889 825
890/* Mac replacement for XDrawString16. */ 826/* Mac replacement for XDrawString16. */
891 827
892static void 828static void
893XDrawString16 (display, w, gc, x, y, buf, nchars) 829mac_draw_string_16 (f, gc, x, y, buf, nchars)
894 Display *display; 830 struct frame *f;
895 WindowPtr w;
896 GC gc; 831 GC gc;
897 int x, y; 832 int x, y;
898 XChar2b *buf; 833 XChar2b *buf;
899 int nchars; 834 int nchars;
900{ 835{
901 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcOr, 836 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2);
902 2);
903} 837}
904 838
905 839
906/* Mac replacement for XDrawImageString. */ 840/* Mac replacement for XDrawImageString. */
907 841
908static void 842static void
909XDrawImageString (display, w, gc, x, y, buf, nchars) 843mac_draw_image_string (f, gc, x, y, buf, nchars)
910 Display *display; 844 struct frame *f;
911 WindowPtr w;
912 GC gc; 845 GC gc;
913 int x, y; 846 int x, y;
914 char *buf; 847 char *buf;
915 int nchars; 848 int nchars;
916{ 849{
917 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcCopy, 1); 850 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1);
918} 851}
919 852
920 853
921/* Mac replacement for XDrawString16. */ 854/* Mac replacement for XDrawString16. */
922 855
923static void 856static void
924XDrawImageString16 (display, w, gc, x, y, buf, nchars) 857mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
925 Display *display; 858 struct frame *f;
926 WindowPtr w;
927 GC gc; 859 GC gc;
928 int x, y; 860 int x, y;
929 XChar2b *buf; 861 XChar2b *buf;
930 int nchars; 862 int nchars;
931{ 863{
932 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcCopy, 864 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
933 2);
934} 865}
935 866
936 867
937/* Mac replacement for XCopyArea: dest must be window. */ 868/* Mac replacement for XCopyArea: dest must be window. */
938 869
939static void 870static void
940mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x, 871mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y)
941 dest_y)
942 Display *display;
943 Pixmap src; 872 Pixmap src;
944 WindowPtr dest; 873 struct frame *f;
945 GC gc; 874 GC gc;
946 int src_x, src_y; 875 int src_x, src_y;
947 unsigned int width, height; 876 unsigned int width, height;
@@ -949,7 +878,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
949{ 878{
950 Rect src_r, dest_r; 879 Rect src_r, dest_r;
951 880
952 SetPortWindowPort (dest); 881 SetPortWindowPort (FRAME_MAC_WINDOW (f));
953 882
954 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 883 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
955 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 884 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -960,28 +889,32 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
960 mac_begin_clip (GC_CLIP_REGION (gc)); 889 mac_begin_clip (GC_CLIP_REGION (gc));
961 LockPixels (GetGWorldPixMap (src)); 890 LockPixels (GetGWorldPixMap (src));
962#if TARGET_API_MAC_CARBON 891#if TARGET_API_MAC_CARBON
963 LockPortBits (GetWindowPort (dest)); 892 {
964 CopyBits (GetPortBitMapForCopyBits (src), 893 CGrafPtr port;
965 GetPortBitMapForCopyBits (GetWindowPort (dest)), 894
966 &src_r, &dest_r, srcCopy, 0); 895 GetPort (&port);
967 UnlockPortBits (GetWindowPort (dest)); 896 LockPortBits (port);
897 CopyBits (GetPortBitMapForCopyBits (src),
898 GetPortBitMapForCopyBits (port),
899 &src_r, &dest_r, srcCopy, 0);
900 UnlockPortBits (port);
901 }
968#else /* not TARGET_API_MAC_CARBON */ 902#else /* not TARGET_API_MAC_CARBON */
969 CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits), 903 CopyBits (&(((GrafPtr)src)->portBits), &(FRAME_MAC_WINDOW (f)->portBits),
970 &src_r, &dest_r, srcCopy, 0); 904 &src_r, &dest_r, srcCopy, 0);
971#endif /* not TARGET_API_MAC_CARBON */ 905#endif /* not TARGET_API_MAC_CARBON */
972 UnlockPixels (GetGWorldPixMap (src)); 906 UnlockPixels (GetGWorldPixMap (src));
973 mac_end_clip (GC_CLIP_REGION (gc)); 907 mac_end_clip (GC_CLIP_REGION (gc));
974 908
975 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 909 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
976} 910}
977 911
978 912
979static void 913static void
980mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, 914mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y,
981 width, height, dest_x, dest_y) 915 width, height, dest_x, dest_y)
982 Display *display;
983 Pixmap src, mask; 916 Pixmap src, mask;
984 WindowPtr dest; 917 struct frame *f;
985 GC gc; 918 GC gc;
986 int src_x, src_y; 919 int src_x, src_y;
987 unsigned int width, height; 920 unsigned int width, height;
@@ -989,7 +922,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
989{ 922{
990 Rect src_r, dest_r; 923 Rect src_r, dest_r;
991 924
992 SetPortWindowPort (dest); 925 SetPortWindowPort (FRAME_MAC_WINDOW (f));
993 926
994 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 927 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
995 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 928 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -1001,29 +934,33 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
1001 LockPixels (GetGWorldPixMap (src)); 934 LockPixels (GetGWorldPixMap (src));
1002 LockPixels (GetGWorldPixMap (mask)); 935 LockPixels (GetGWorldPixMap (mask));
1003#if TARGET_API_MAC_CARBON 936#if TARGET_API_MAC_CARBON
1004 LockPortBits (GetWindowPort (dest)); 937 {
1005 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask), 938 CGrafPtr port;
1006 GetPortBitMapForCopyBits (GetWindowPort (dest)), 939
1007 &src_r, &src_r, &dest_r); 940 GetPort (&port);
1008 UnlockPortBits (GetWindowPort (dest)); 941 LockPortBits (port);
942 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
943 GetPortBitMapForCopyBits (port),
944 &src_r, &src_r, &dest_r);
945 UnlockPortBits (port);
946 }
1009#else /* not TARGET_API_MAC_CARBON */ 947#else /* not TARGET_API_MAC_CARBON */
1010 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits), 948 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1011 &(dest->portBits), &src_r, &src_r, &dest_r); 949 &(FRAME_MAC_WINDOW (f)->portBits), &src_r, &src_r, &dest_r);
1012#endif /* not TARGET_API_MAC_CARBON */ 950#endif /* not TARGET_API_MAC_CARBON */
1013 UnlockPixels (GetGWorldPixMap (mask)); 951 UnlockPixels (GetGWorldPixMap (mask));
1014 UnlockPixels (GetGWorldPixMap (src)); 952 UnlockPixels (GetGWorldPixMap (src));
1015 mac_end_clip (GC_CLIP_REGION (gc)); 953 mac_end_clip (GC_CLIP_REGION (gc));
1016 954
1017 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 955 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1018} 956}
1019 957
1020 958
1021/* Mac replacement for XCopyArea: used only for scrolling. */ 959/* Mac replacement for XCopyArea: used only for scrolling. */
1022 960
1023static void 961static void
1024mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 962mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
1025 Display *display; 963 struct frame *f;
1026 WindowPtr w;
1027 GC gc; 964 GC gc;
1028 int src_x, src_y; 965 int src_x, src_y;
1029 unsigned int width, height; 966 unsigned int width, height;
@@ -1034,11 +971,13 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1034 RgnHandle dummy = NewRgn (); /* For avoiding update events. */ 971 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
1035 972
1036 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 973 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1037 ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y, 974 ScrollWindowRect (FRAME_MAC_WINDOW (f),
975 &src_r, dest_x - src_x, dest_y - src_y,
1038 kScrollWindowNoOptions, dummy); 976 kScrollWindowNoOptions, dummy);
1039 DisposeRgn (dummy); 977 DisposeRgn (dummy);
1040#else /* not TARGET_API_MAC_CARBON */ 978#else /* not TARGET_API_MAC_CARBON */
1041 Rect src_r, dest_r; 979 Rect src_r, dest_r;
980 WindowPtr w = FRAME_MAC_WINDOW (f);
1042 981
1043 SetPort (w); 982 SetPort (w);
1044 983
@@ -1053,93 +992,11 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1053 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 992 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
1054 mac_end_clip (GC_CLIP_REGION (gc)); 993 mac_end_clip (GC_CLIP_REGION (gc));
1055 994
1056 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 995 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1057#endif /* not TARGET_API_MAC_CARBON */ 996#endif /* not TARGET_API_MAC_CARBON */
1058} 997}
1059 998
1060 999
1061#if 0 /* TODO: figure out if we need to do this on Mac. */
1062/* Mac replacement for XCopyArea: dest must be Pixmap. */
1063
1064static void
1065mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1066 dest_x, dest_y)
1067 Display *display;
1068 Pixmap src, dest;
1069 GC gc;
1070 int src_x, src_y;
1071 unsigned int width, height;
1072 int dest_x, dest_y;
1073{
1074 CGrafPtr old_port;
1075 GDHandle old_gdh;
1076 Rect src_r, dest_r;
1077
1078 GetGWorld (&old_port, &old_gdh);
1079 SetGWorld (dest, NULL);
1080 ForeColor (blackColor);
1081 BackColor (whiteColor);
1082
1083 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1084 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1085
1086 LockPixels (GetGWorldPixMap (src));
1087 LockPixels (GetGWorldPixMap (dest));
1088#if TARGET_API_MAC_CARBON
1089 CopyBits (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (dest),
1090 &src_r, &dest_r, srcCopy, 0);
1091#else /* not TARGET_API_MAC_CARBON */
1092 CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits),
1093 &src_r, &dest_r, srcCopy, 0);
1094#endif /* not TARGET_API_MAC_CARBON */
1095 UnlockPixels (GetGWorldPixMap (dest));
1096 UnlockPixels (GetGWorldPixMap (src));
1097
1098 SetGWorld (old_port, old_gdh);
1099}
1100
1101
1102static void
1103mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1104 width, height, dest_x, dest_y)
1105 Display *display;
1106 Pixmap src, mask, dest;
1107 GC gc;
1108 int src_x, src_y;
1109 unsigned int width, height;
1110 int dest_x, dest_y;
1111{
1112 CGrafPtr old_port;
1113 GDHandle old_gdh;
1114 Rect src_r, dest_r;
1115
1116 GetGWorld (&old_port, &old_gdh);
1117 SetGWorld (dest, NULL);
1118 ForeColor (blackColor);
1119 BackColor (whiteColor);
1120
1121 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1122 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1123
1124 LockPixels (GetGWorldPixMap (src));
1125 LockPixels (GetGWorldPixMap (mask));
1126 LockPixels (GetGWorldPixMap (dest));
1127#if TARGET_API_MAC_CARBON
1128 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
1129 GetPortBitMapForCopyBits (dest), &src_r, &src_r, &dest_r);
1130#else /* not TARGET_API_MAC_CARBON */
1131 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1132 &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r);
1133#endif /* not TARGET_API_MAC_CARBON */
1134 UnlockPixels (GetGWorldPixMap (dest));
1135 UnlockPixels (GetGWorldPixMap (mask));
1136 UnlockPixels (GetGWorldPixMap (src));
1137
1138 SetGWorld (old_port, old_gdh);
1139}
1140#endif
1141
1142
1143/* Mac replacement for XChangeGC. */ 1000/* Mac replacement for XChangeGC. */
1144 1001
1145static void 1002static void
@@ -1511,8 +1368,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1511 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc, 1368 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
1512 face->foreground); 1369 face->foreground);
1513 1370
1514 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1371 mac_draw_line (f, f->output_data.mac->normal_gc, x, y0, x, y1);
1515 f->output_data.mac->normal_gc, x, y0, x, y1);
1516} 1372}
1517 1373
1518/* End update of window W (which is equal to updated_window). 1374/* End update of window W (which is equal to updated_window).
@@ -1651,11 +1507,8 @@ x_after_update_window_line (desired_row)
1651 y -= width; 1507 y -= width;
1652 1508
1653 BLOCK_INPUT; 1509 BLOCK_INPUT;
1654 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1510 mac_clear_area (f, 0, y, width, height);
1655 0, y, width, height, 0); 1511 mac_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height);
1656 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1657 FRAME_PIXEL_WIDTH (f) - width, y,
1658 width, height, 0);
1659 UNBLOCK_INPUT; 1512 UNBLOCK_INPUT;
1660 } 1513 }
1661} 1514}
@@ -1674,8 +1527,6 @@ x_draw_fringe_bitmap (w, row, p)
1674{ 1527{
1675 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1528 struct frame *f = XFRAME (WINDOW_FRAME (w));
1676 Display *display = FRAME_MAC_DISPLAY (f); 1529 Display *display = FRAME_MAC_DISPLAY (f);
1677 WindowPtr window = FRAME_MAC_WINDOW (f);
1678 GC gc = f->output_data.mac->normal_gc;
1679 struct face *face = p->face; 1530 struct face *face = p->face;
1680 int rowY; 1531 int rowY;
1681 1532
@@ -1689,12 +1540,12 @@ x_draw_fringe_bitmap (w, row, p)
1689 int oldVH = row->visible_height; 1540 int oldVH = row->visible_height;
1690 row->visible_height = p->h; 1541 row->visible_height = p->h;
1691 row->y -= rowY - p->y; 1542 row->y -= rowY - p->y;
1692 x_clip_to_row (w, row, -1, gc); 1543 x_clip_to_row (w, row, -1, face->gc);
1693 row->y = oldY; 1544 row->y = oldY;
1694 row->visible_height = oldVH; 1545 row->visible_height = oldVH;
1695 } 1546 }
1696 else 1547 else
1697 x_clip_to_row (w, row, -1, gc); 1548 x_clip_to_row (w, row, -1, face->gc);
1698 1549
1699 if (p->bx >= 0 && !p->overlay_p) 1550 if (p->bx >= 0 && !p->overlay_p)
1700 { 1551 {
@@ -1709,7 +1560,7 @@ x_draw_fringe_bitmap (w, row, p)
1709 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); 1560 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
1710#endif 1561#endif
1711 1562
1712 mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny); 1563 mac_erase_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
1713 1564
1714#if 0 /* MAC_TODO: stipple */ 1565#if 0 /* MAC_TODO: stipple */
1715 if (!face->stipple) 1566 if (!face->stipple)
@@ -1728,12 +1579,12 @@ x_draw_fringe_bitmap (w, row, p)
1728 ? (p->overlay_p ? face->background 1579 ? (p->overlay_p ? face->background
1729 : f->output_data.mac->cursor_pixel) 1580 : f->output_data.mac->cursor_pixel)
1730 : face->foreground)); 1581 : face->foreground));
1731 mac_draw_bitmap (display, window, face->gc, p->x, p->y, 1582 mac_draw_bitmap (f, face->gc, p->x, p->y,
1732 p->wd, p->h, bits, p->overlay_p); 1583 p->wd, p->h, bits, p->overlay_p);
1733 XSetForeground (display, face->gc, gcv.foreground); 1584 XSetForeground (display, face->gc, gcv.foreground);
1734 } 1585 }
1735 1586
1736 mac_reset_clip_rectangles (display, gc); 1587 mac_reset_clip_rectangles (display, face->gc);
1737} 1588}
1738 1589
1739 1590
@@ -2284,7 +2135,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
2284 struct glyph_string *s; 2135 struct glyph_string *s;
2285 int x, y, w, h; 2136 int x, y, w, h;
2286{ 2137{
2287 mac_erase_rectangle (s->window, s->gc, x, y, w, h); 2138 mac_erase_rectangle (s->f, s->gc, x, y, w, h);
2288} 2139}
2289 2140
2290 2141
@@ -2366,9 +2217,8 @@ x_draw_glyph_string_foreground (s)
2366 for (i = 0; i < s->nchars; ++i) 2217 for (i = 0; i < s->nchars; ++i)
2367 { 2218 {
2368 struct glyph *g = s->first_glyph + i; 2219 struct glyph *g = s->first_glyph + i;
2369 mac_draw_rectangle (s->display, s->window, 2220 mac_draw_rectangle (s->f, s->gc, x, s->y,
2370 s->gc, x, s->y, g->pixel_width - 1, 2221 g->pixel_width - 1, s->height - 1);
2371 s->height - 1);
2372 x += g->pixel_width; 2222 x += g->pixel_width;
2373 } 2223 }
2374 } 2224 }
@@ -2405,21 +2255,21 @@ x_draw_glyph_string_foreground (s)
2405 || GC_FONT (s->gc)->mac_style 2255 || GC_FONT (s->gc)->mac_style
2406#endif 2256#endif
2407 ) 2257 )
2408 XDrawString16 (s->display, s->window, s->gc, x, 2258 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2409 s->ybase - boff, s->char2b, s->nchars); 2259 s->char2b, s->nchars);
2410 else 2260 else
2411 XDrawString (s->display, s->window, s->gc, x, 2261 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2412 s->ybase - boff, char1b, s->nchars); 2262 char1b, s->nchars);
2413 } 2263 }
2414#if defined (MAC_OS8) && !USE_ATSUI 2264#if defined (MAC_OS8) && !USE_ATSUI
2415 else 2265 else
2416 { 2266 {
2417 if (s->two_byte_p) 2267 if (s->two_byte_p)
2418 XDrawImageString16 (s->display, s->window, s->gc, x, 2268 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2419 s->ybase - boff, s->char2b, s->nchars); 2269 s->char2b, s->nchars);
2420 else 2270 else
2421 XDrawImageString (s->display, s->window, s->gc, x, 2271 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2422 s->ybase - boff, char1b, s->nchars); 2272 char1b, s->nchars);
2423 } 2273 }
2424#endif 2274#endif
2425 } 2275 }
@@ -2451,16 +2301,16 @@ x_draw_composite_glyph_string_foreground (s)
2451 if (s->font_not_found_p) 2301 if (s->font_not_found_p)
2452 { 2302 {
2453 if (s->gidx == 0) 2303 if (s->gidx == 0)
2454 mac_draw_rectangle (s->display, s->window, s->gc, x, s->y, 2304 mac_draw_rectangle (s->f, s->gc, x, s->y,
2455 s->width - 1, s->height - 1); 2305 s->width - 1, s->height - 1);
2456 } 2306 }
2457 else 2307 else
2458 { 2308 {
2459 for (i = 0; i < s->nchars; i++, ++s->gidx) 2309 for (i = 0; i < s->nchars; i++, ++s->gidx)
2460 XDrawString16 (s->display, s->window, s->gc, 2310 mac_draw_string_16 (s->f, s->gc,
2461 x + s->cmp->offsets[s->gidx * 2], 2311 x + s->cmp->offsets[s->gidx * 2],
2462 s->ybase - s->cmp->offsets[s->gidx * 2 + 1], 2312 s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
2463 s->char2b + i, 1); 2313 s->char2b + i, 1);
2464 } 2314 }
2465} 2315}
2466 2316
@@ -2816,7 +2666,6 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2816 Rect *clip_rect; 2666 Rect *clip_rect;
2817{ 2667{
2818 Display *dpy = FRAME_MAC_DISPLAY (f); 2668 Display *dpy = FRAME_MAC_DISPLAY (f);
2819 Window window = FRAME_MAC_WINDOW (f);
2820 int i; 2669 int i;
2821 GC gc; 2670 GC gc;
2822 2671
@@ -2829,15 +2678,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2829 /* Top. */ 2678 /* Top. */
2830 if (top_p) 2679 if (top_p)
2831 for (i = 0; i < width; ++i) 2680 for (i = 0; i < width; ++i)
2832 XDrawLine (dpy, window, gc, 2681 mac_draw_line (f, gc,
2833 left_x + i * left_p, top_y + i, 2682 left_x + i * left_p, top_y + i,
2834 right_x - i * right_p, top_y + i); 2683 right_x - i * right_p, top_y + i);
2835 2684
2836 /* Left. */ 2685 /* Left. */
2837 if (left_p) 2686 if (left_p)
2838 for (i = 0; i < width; ++i) 2687 for (i = 0; i < width; ++i)
2839 XDrawLine (dpy, window, gc, 2688 mac_draw_line (f, gc,
2840 left_x + i, top_y + i, left_x + i, bottom_y - i); 2689 left_x + i, top_y + i, left_x + i, bottom_y - i);
2841 2690
2842 mac_reset_clip_rectangles (dpy, gc); 2691 mac_reset_clip_rectangles (dpy, gc);
2843 if (raised_p) 2692 if (raised_p)
@@ -2849,15 +2698,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2849 /* Bottom. */ 2698 /* Bottom. */
2850 if (bot_p) 2699 if (bot_p)
2851 for (i = 0; i < width; ++i) 2700 for (i = 0; i < width; ++i)
2852 XDrawLine (dpy, window, gc, 2701 mac_draw_line (f, gc,
2853 left_x + i * left_p, bottom_y - i, 2702 left_x + i * left_p, bottom_y - i,
2854 right_x - i * right_p, bottom_y - i); 2703 right_x - i * right_p, bottom_y - i);
2855 2704
2856 /* Right. */ 2705 /* Right. */
2857 if (right_p) 2706 if (right_p)
2858 for (i = 0; i < width; ++i) 2707 for (i = 0; i < width; ++i)
2859 XDrawLine (dpy, window, gc, 2708 mac_draw_line (f, gc,
2860 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); 2709 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
2861 2710
2862 mac_reset_clip_rectangles (dpy, gc); 2711 mac_reset_clip_rectangles (dpy, gc);
2863} 2712}
@@ -2884,22 +2733,22 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2884 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1); 2733 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1);
2885 2734
2886 /* Top. */ 2735 /* Top. */
2887 XFillRectangle (s->display, s->window, s->gc, 2736 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2888 left_x, top_y, right_x - left_x + 1, width); 2737 right_x - left_x + 1, width);
2889 2738
2890 /* Left. */ 2739 /* Left. */
2891 if (left_p) 2740 if (left_p)
2892 XFillRectangle (s->display, s->window, s->gc, 2741 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2893 left_x, top_y, width, bottom_y - top_y + 1); 2742 width, bottom_y - top_y + 1);
2894 2743
2895 /* Bottom. */ 2744 /* Bottom. */
2896 XFillRectangle (s->display, s->window, s->gc, 2745 mac_fill_rectangle (s->f, s->gc, left_x, bottom_y - width + 1,
2897 left_x, bottom_y - width + 1, right_x - left_x + 1, width); 2746 right_x - left_x + 1, width);
2898 2747
2899 /* Right. */ 2748 /* Right. */
2900 if (right_p) 2749 if (right_p)
2901 XFillRectangle (s->display, s->window, s->gc, 2750 mac_fill_rectangle (s->f, s->gc, right_x - width + 1,
2902 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2751 top_y, width, bottom_y - top_y + 1);
2903 2752
2904 XSetForeground (s->display, s->gc, xgcv.foreground); 2753 XSetForeground (s->display, s->gc, xgcv.foreground);
2905 mac_reset_clip_rectangles (s->display, s->gc); 2754 mac_reset_clip_rectangles (s->display, s->gc);
@@ -2986,13 +2835,13 @@ x_draw_image_foreground (s)
2986 x_set_glyph_string_clipping (s); 2835 x_set_glyph_string_clipping (s);
2987 2836
2988 if (s->img->mask) 2837 if (s->img->mask)
2989 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, 2838 mac_copy_area_with_mask (s->img->pixmap, s->img->mask,
2990 s->window, s->gc, s->slice.x, s->slice.y, 2839 s->f, s->gc, s->slice.x, s->slice.y,
2991 s->slice.width, s->slice.height, x, y); 2840 s->slice.width, s->slice.height, x, y);
2992 else 2841 else
2993 { 2842 {
2994 mac_copy_area (s->display, s->img->pixmap, 2843 mac_copy_area (s->img->pixmap,
2995 s->window, s->gc, s->slice.x, s->slice.y, 2844 s->f, s->gc, s->slice.x, s->slice.y,
2996 s->slice.width, s->slice.height, x, y); 2845 s->slice.width, s->slice.height, x, y);
2997 2846
2998 /* When the image has a mask, we can expect that at 2847 /* When the image has a mask, we can expect that at
@@ -3005,8 +2854,7 @@ x_draw_image_foreground (s)
3005 { 2854 {
3006 int r = s->img->relief; 2855 int r = s->img->relief;
3007 if (r < 0) r = -r; 2856 if (r < 0) r = -r;
3008 mac_draw_rectangle (s->display, s->window, s->gc, 2857 mac_draw_rectangle (s->f, s->gc, x - r, y - r,
3009 x - r, y - r,
3010 s->slice.width + r*2 - 1, 2858 s->slice.width + r*2 - 1,
3011 s->slice.height + r*2 - 1); 2859 s->slice.height + r*2 - 1);
3012 } 2860 }
@@ -3014,7 +2862,7 @@ x_draw_image_foreground (s)
3014 } 2862 }
3015 else 2863 else
3016 /* Draw a rectangle if image could not be loaded. */ 2864 /* Draw a rectangle if image could not be loaded. */
3017 mac_draw_rectangle (s->display, s->window, s->gc, x, y, 2865 mac_draw_rectangle (s->f, s->gc, x, y,
3018 s->slice.width - 1, s->slice.height - 1); 2866 s->slice.width - 1, s->slice.height - 1);
3019} 2867}
3020 2868
@@ -3072,70 +2920,6 @@ x_draw_image_relief (s)
3072} 2920}
3073 2921
3074 2922
3075#if 0 /* TODO: figure out if we need to do this on Mac. */
3076/* Draw the foreground of image glyph string S to PIXMAP. */
3077
3078static void
3079x_draw_image_foreground_1 (s, pixmap)
3080 struct glyph_string *s;
3081 Pixmap pixmap;
3082{
3083 int x = 0;
3084 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
3085
3086 /* If first glyph of S has a left box line, start drawing it to the
3087 right of that line. */
3088 if (s->face->box != FACE_NO_BOX
3089 && s->first_glyph->left_box_line_p
3090 && s->slice.x == 0)
3091 x += abs (s->face->box_line_width);
3092
3093 /* If there is a margin around the image, adjust x- and y-position
3094 by that margin. */
3095 if (s->slice.x == 0)
3096 x += s->img->hmargin;
3097 if (s->slice.y == 0)
3098 y += s->img->vmargin;
3099
3100 if (s->img->pixmap)
3101 {
3102 if (s->img->mask)
3103 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
3104 s->img->mask, pixmap, s->gc,
3105 s->slice.x, s->slice.y,
3106 s->slice.width, s->slice.height,
3107 x, y);
3108 else
3109 {
3110 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
3111 s->slice.x, s->slice.y,
3112 s->slice.width, s->slice.height,
3113 x, y);
3114
3115 /* When the image has a mask, we can expect that at
3116 least part of a mouse highlight or a block cursor will
3117 be visible. If the image doesn't have a mask, make
3118 a block cursor visible by drawing a rectangle around
3119 the image. I believe it's looking better if we do
3120 nothing here for mouse-face. */
3121 if (s->hl == DRAW_CURSOR)
3122 {
3123 int r = s->img->relief;
3124 if (r < 0) r = -r;
3125 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
3126 s->slice.width + r*2 - 1,
3127 s->slice.height + r*2 - 1);
3128 }
3129 }
3130 }
3131 else
3132 /* Draw a rectangle if image could not be loaded. */
3133 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
3134 s->slice.width - 1, s->slice.height - 1);
3135}
3136#endif
3137
3138
3139/* Draw part of the background of glyph string S. X, Y, W, and H 2923/* Draw part of the background of glyph string S. X, Y, W, and H
3140 give the rectangle to draw. */ 2924 give the rectangle to draw. */
3141 2925
@@ -3205,62 +2989,13 @@ x_draw_image_glyph_string (s)
3205 if (s->slice.y == 0) 2989 if (s->slice.y == 0)
3206 y += box_line_vwidth; 2990 y += box_line_vwidth;
3207 2991
3208#if 0 /* TODO: figure out if we need to do this on Mac. */ 2992 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3209 if (s->img->mask)
3210 {
3211 /* Create a pixmap as large as the glyph string. Fill it
3212 with the background color. Copy the image to it, using
3213 its mask. Copy the temporary pixmap to the display. */
3214 int depth = one_mac_display_info.n_planes;
3215
3216 /* Create a pixmap as large as the glyph string. */
3217 pixmap = XCreatePixmap (s->display, s->window,
3218 s->background_width,
3219 s->height, depth);
3220
3221 /* Fill the pixmap with the background color/stipple. */
3222#if 0 /* TODO: stipple */
3223 if (s->stippled_p)
3224 {
3225 /* Fill background with a stipple pattern. */
3226 XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
3227 XFillRectangle (s->display, pixmap, s->gc,
3228 0, 0, s->background_width, s->height);
3229 XSetFillStyle (s->display, s->gc, FillSolid);
3230 }
3231 else
3232#endif
3233 {
3234 XGCValues xgcv;
3235 XGetGCValues (s->display, s->gc, GCForeground | GCBackground,
3236 &xgcv);
3237 XSetForeground (s->display, s->gc, xgcv.background);
3238 mac_fill_rectangle_to_pixmap (s->display, pixmap, s->gc,
3239 0, 0, s->background_width,
3240 s->height);
3241 XSetForeground (s->display, s->gc, xgcv.foreground);
3242 }
3243 }
3244 else
3245#endif
3246 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3247 2993
3248 s->background_filled_p = 1; 2994 s->background_filled_p = 1;
3249 } 2995 }
3250 2996
3251 /* Draw the foreground. */ 2997 /* Draw the foreground. */
3252#if 0 /* TODO: figure out if we need to do this on Mac. */ 2998 x_draw_image_foreground (s);
3253 if (pixmap != 0)
3254 {
3255 x_draw_image_foreground_1 (s, pixmap);
3256 x_set_glyph_string_clipping (s);
3257 mac_copy_area (s->display, pixmap, s->window, s->gc,
3258 0, 0, s->background_width, s->height, s->x, s->y);
3259 XFreePixmap (s->display, pixmap);
3260 }
3261 else
3262#endif
3263 x_draw_image_foreground (s);
3264 2999
3265 /* If we must draw a relief around the image, do it. */ 3000 /* If we must draw a relief around the image, do it. */
3266 if (s->img->relief 3001 if (s->img->relief
@@ -3319,7 +3054,7 @@ x_draw_stretch_glyph_string (s)
3319 } 3054 }
3320 else 3055 else
3321#endif /* MAC_TODO */ 3056#endif /* MAC_TODO */
3322 mac_erase_rectangle (s->window, gc, x, y, w, h); 3057 mac_erase_rectangle (s->f, gc, x, y, w, h);
3323 } 3058 }
3324 } 3059 }
3325 else if (!s->background_filled_p) 3060 else if (!s->background_filled_p)
@@ -3410,15 +3145,15 @@ x_draw_glyph_string (s)
3410 unsigned long dy = s->height - h; 3145 unsigned long dy = s->height - h;
3411 3146
3412 if (s->face->underline_defaulted_p) 3147 if (s->face->underline_defaulted_p)
3413 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3148 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3414 s->width, h); 3149 s->width, h);
3415 else 3150 else
3416 { 3151 {
3417 XGCValues xgcv; 3152 XGCValues xgcv;
3418 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3153 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3419 XSetForeground (s->display, s->gc, s->face->underline_color); 3154 XSetForeground (s->display, s->gc, s->face->underline_color);
3420 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3155 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3421 s->width, h); 3156 s->width, h);
3422 XSetForeground (s->display, s->gc, xgcv.foreground); 3157 XSetForeground (s->display, s->gc, xgcv.foreground);
3423 } 3158 }
3424 } 3159 }
@@ -3429,15 +3164,15 @@ x_draw_glyph_string (s)
3429 unsigned long dy = 0, h = 1; 3164 unsigned long dy = 0, h = 1;
3430 3165
3431 if (s->face->overline_color_defaulted_p) 3166 if (s->face->overline_color_defaulted_p)
3432 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3167 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3433 s->width, h); 3168 s->width, h);
3434 else 3169 else
3435 { 3170 {
3436 XGCValues xgcv; 3171 XGCValues xgcv;
3437 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3172 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3438 XSetForeground (s->display, s->gc, s->face->overline_color); 3173 XSetForeground (s->display, s->gc, s->face->overline_color);
3439 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3174 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3440 s->width, h); 3175 s->width, h);
3441 XSetForeground (s->display, s->gc, xgcv.foreground); 3176 XSetForeground (s->display, s->gc, xgcv.foreground);
3442 } 3177 }
3443 } 3178 }
@@ -3449,15 +3184,15 @@ x_draw_glyph_string (s)
3449 unsigned long dy = (s->height - h) / 2; 3184 unsigned long dy = (s->height - h) / 2;
3450 3185
3451 if (s->face->strike_through_color_defaulted_p) 3186 if (s->face->strike_through_color_defaulted_p)
3452 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3187 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3453 s->width, h); 3188 s->width, h);
3454 else 3189 else
3455 { 3190 {
3456 XGCValues xgcv; 3191 XGCValues xgcv;
3457 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3192 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3458 XSetForeground (s->display, s->gc, s->face->strike_through_color); 3193 XSetForeground (s->display, s->gc, s->face->strike_through_color);
3459 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3194 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3460 s->width, h); 3195 s->width, h);
3461 XSetForeground (s->display, s->gc, xgcv.foreground); 3196 XSetForeground (s->display, s->gc, xgcv.foreground);
3462 } 3197 }
3463 } 3198 }
@@ -3478,8 +3213,7 @@ mac_shift_glyphs_for_insert (f, x, y, width, height, shift_by)
3478 struct frame *f; 3213 struct frame *f;
3479 int x, y, width, height, shift_by; 3214 int x, y, width, height, shift_by;
3480{ 3215{
3481 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3216 mac_scroll_area (f, f->output_data.mac->normal_gc,
3482 f->output_data.mac->normal_gc,
3483 x, y, width, height, 3217 x, y, width, height,
3484 x + shift_by, y); 3218 x + shift_by, y);
3485} 3219}
@@ -3517,7 +3251,7 @@ x_clear_frame ()
3517 /* We don't set the output cursor here because there will always 3251 /* We don't set the output cursor here because there will always
3518 follow an explicit cursor_to. */ 3252 follow an explicit cursor_to. */
3519 BLOCK_INPUT; 3253 BLOCK_INPUT;
3520 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); 3254 mac_clear_window (f);
3521 3255
3522 /* We have to clear the scroll bars, too. If we have changed 3256 /* We have to clear the scroll bars, too. If we have changed
3523 colors or something like that, then they should be notified. */ 3257 colors or something like that, then they should be notified. */
@@ -3607,21 +3341,18 @@ XTflash (f)
3607 /* If window is tall, flash top and bottom line. */ 3341 /* If window is tall, flash top and bottom line. */
3608 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3342 if (height > 3 * FRAME_LINE_HEIGHT (f))
3609 { 3343 {
3610 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3344 mac_invert_rectangle (f, flash_left,
3611 flash_left,
3612 (FRAME_INTERNAL_BORDER_WIDTH (f) 3345 (FRAME_INTERNAL_BORDER_WIDTH (f)
3613 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3346 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3614 width, flash_height); 3347 width, flash_height);
3615 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3348 mac_invert_rectangle (f, flash_left,
3616 flash_left,
3617 (height - flash_height 3349 (height - flash_height
3618 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3350 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3619 width, flash_height); 3351 width, flash_height);
3620 } 3352 }
3621 else 3353 else
3622 /* If it is short, flash it all. */ 3354 /* If it is short, flash it all. */
3623 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3355 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3624 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3625 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3356 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3626 3357
3627 x_flush (f); 3358 x_flush (f);
@@ -3661,21 +3392,18 @@ XTflash (f)
3661 /* If window is tall, flash top and bottom line. */ 3392 /* If window is tall, flash top and bottom line. */
3662 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3393 if (height > 3 * FRAME_LINE_HEIGHT (f))
3663 { 3394 {
3664 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3395 mac_invert_rectangle (f, flash_left,
3665 flash_left,
3666 (FRAME_INTERNAL_BORDER_WIDTH (f) 3396 (FRAME_INTERNAL_BORDER_WIDTH (f)
3667 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3397 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3668 width, flash_height); 3398 width, flash_height);
3669 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3399 mac_invert_rectangle (f, flash_left,
3670 flash_left,
3671 (height - flash_height 3400 (height - flash_height
3672 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3401 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3673 width, flash_height); 3402 width, flash_height);
3674 } 3403 }
3675 else 3404 else
3676 /* If it is short, flash it all. */ 3405 /* If it is short, flash it all. */
3677 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3406 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3678 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3679 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3407 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3680 3408
3681 x_flush (f); 3409 x_flush (f);
@@ -3780,11 +3508,10 @@ x_scroll_run (w, run)
3780 updated_window = w; 3508 updated_window = w;
3781 x_clear_cursor (w); 3509 x_clear_cursor (w);
3782 3510
3783 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3511 mac_scroll_area (f, f->output_data.mac->normal_gc,
3784 f->output_data.mac->normal_gc, 3512 x, from_y,
3785 x, from_y, 3513 width, height,
3786 width, height, 3514 x, to_y);
3787 x, to_y);
3788 3515
3789 UNBLOCK_INPUT; 3516 UNBLOCK_INPUT;
3790} 3517}
@@ -4185,10 +3912,7 @@ note_mouse_movement (frame, pos)
4185 return 1; 3912 return 1;
4186 } 3913 }
4187 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3914 /* Has the mouse moved off the glyph it was on at the last sighting? */
4188 if (pos->h < last_mouse_glyph.left 3915 if (!PtInRect (*pos, &last_mouse_glyph))
4189 || pos->h >= last_mouse_glyph.right
4190 || pos->v < last_mouse_glyph.top
4191 || pos->v >= last_mouse_glyph.bottom)
4192 { 3916 {
4193 frame->mouse_moved = 1; 3917 frame->mouse_moved = 1;
4194 last_mouse_scroll_bar = Qnil; 3918 last_mouse_scroll_bar = Qnil;
@@ -4831,8 +4555,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4831 if (NILP (w->vertical_scroll_bar)) 4555 if (NILP (w->vertical_scroll_bar))
4832 { 4556 {
4833 BLOCK_INPUT; 4557 BLOCK_INPUT;
4834 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4558 mac_clear_area (f, left, top, width, height);
4835 left, top, width, height, 0);
4836 UNBLOCK_INPUT; 4559 UNBLOCK_INPUT;
4837 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top, 4560 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top,
4838 disp_height); 4561 disp_height);
@@ -4856,14 +4579,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4856 { 4579 {
4857 /* Since toolkit scroll bars are smaller than the space reserved 4580 /* Since toolkit scroll bars are smaller than the space reserved
4858 for them on the frame, we have to clear "under" them. */ 4581 for them on the frame, we have to clear "under" them. */
4859 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4582 mac_clear_area (f, left, top, width, height);
4860 left, top, width, height, 0);
4861
4862#if 0
4863 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
4864 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4865 sb_left - 1, top, 1, height, 0);
4866#endif
4867 4583
4868 HideControl (ch); 4584 HideControl (ch);
4869 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4585 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
@@ -5296,7 +5012,7 @@ x_draw_hollow_cursor (w, row)
5296 5012
5297 /* Set clipping, draw the rectangle, and reset clipping again. */ 5013 /* Set clipping, draw the rectangle, and reset clipping again. */
5298 x_clip_to_row (w, row, TEXT_AREA, gc); 5014 x_clip_to_row (w, row, TEXT_AREA, gc);
5299 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 5015 mac_draw_rectangle (f, gc, x, y, wd, h);
5300 mac_reset_clip_rectangles (dpy, gc); 5016 mac_reset_clip_rectangles (dpy, gc);
5301} 5017}
5302 5018
@@ -5369,17 +5085,17 @@ x_draw_bar_cursor (w, row, width, kind)
5369 x_clip_to_row (w, row, TEXT_AREA, gc); 5085 x_clip_to_row (w, row, TEXT_AREA, gc);
5370 5086
5371 if (kind == BAR_CURSOR) 5087 if (kind == BAR_CURSOR)
5372 XFillRectangle (dpy, window, gc, 5088 mac_fill_rectangle (f, gc,
5373 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5089 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5374 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 5090 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
5375 width, row->height); 5091 width, row->height);
5376 else 5092 else
5377 XFillRectangle (dpy, window, gc, 5093 mac_fill_rectangle (f, gc,
5378 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5094 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5379 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y + 5095 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
5380 row->height - width), 5096 row->height - width),
5381 cursor_glyph->pixel_width, 5097 cursor_glyph->pixel_width,
5382 width); 5098 width);
5383 5099
5384 mac_reset_clip_rectangles (dpy, gc); 5100 mac_reset_clip_rectangles (dpy, gc);
5385 } 5101 }
@@ -5404,8 +5120,7 @@ mac_clear_frame_area (f, x, y, width, height)
5404 struct frame *f; 5120 struct frame *f;
5405 int x, y, width, height; 5121 int x, y, width, height;
5406{ 5122{
5407 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 5123 mac_clear_area (f, x, y, width, height);
5408 x, y, width, height, 0);
5409} 5124}
5410 5125
5411 5126
@@ -9824,7 +9539,8 @@ XTread_socket (sd, expected, hold_quit)
9824 } 9539 }
9825 } 9540 }
9826 9541
9827 if (er.what != mouseDown && part_code != inContent) 9542 if (er.what != mouseDown &&
9543 (part_code != inContent || dpyinfo->grabbed == 0))
9828 break; 9544 break;
9829 9545
9830 switch (part_code) 9546 switch (part_code)
@@ -9947,12 +9663,6 @@ XTread_socket (sd, expected, hold_quit)
9947 { 9663 {
9948 dpyinfo->grabbed |= (1 << inev.code); 9664 dpyinfo->grabbed |= (1 << inev.code);
9949 last_mouse_frame = f; 9665 last_mouse_frame = f;
9950 /* Ignore any mouse motion that happened
9951 before this event; any subsequent
9952 mouse-movement Emacs events should reflect
9953 only motion after the ButtonPress. */
9954 if (f != 0)
9955 f->mouse_moved = 0;
9956 9666
9957 if (!tool_bar_p) 9667 if (!tool_bar_p)
9958 last_tool_bar_item = -1; 9668 last_tool_bar_item = -1;
@@ -9968,6 +9678,13 @@ XTread_socket (sd, expected, hold_quit)
9968 dpyinfo->grabbed &= ~(1 << inev.code); 9678 dpyinfo->grabbed &= ~(1 << inev.code);
9969 } 9679 }
9970 9680
9681 /* Ignore any mouse motion that happened before
9682 this event; any subsequent mouse-movement Emacs
9683 events should reflect only motion after the
9684 ButtonPress. */
9685 if (f != 0)
9686 f->mouse_moved = 0;
9687
9971#ifdef USE_TOOLKIT_SCROLL_BARS 9688#ifdef USE_TOOLKIT_SCROLL_BARS
9972 if (inev.kind == MOUSE_CLICK_EVENT) 9689 if (inev.kind == MOUSE_CLICK_EVENT)
9973#endif 9690#endif
diff --git a/src/macterm.h b/src/macterm.h
index e7a5fc2450e..277fd2051c6 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -562,6 +562,8 @@ extern void XSetBackground P_ ((Display *, GC, unsigned long));
562extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); 562extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
563extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, 563extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
564 int, int)); 564 int, int));
565extern void mac_clear_area P_ ((struct frame *, int, int,
566 unsigned int, unsigned int));
565extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); 567extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
566extern OSErr install_window_handler P_ ((WindowPtr)); 568extern OSErr install_window_handler P_ ((WindowPtr));
567extern void remove_window_handler P_ ((WindowPtr)); 569extern void remove_window_handler P_ ((WindowPtr));
diff --git a/src/minibuf.c b/src/minibuf.c
index b7f9fd4838c..74d55a8abfd 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2342,7 +2342,7 @@ Return nil if there is no valid completion, else t. */)
2342} 2342}
2343 2343
2344DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list, 2344DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list,
2345 1, 1, 0, 2345 1, 2, 0,
2346 doc: /* Display the list of completions, COMPLETIONS, using `standard-output'. 2346 doc: /* Display the list of completions, COMPLETIONS, using `standard-output'.
2347Each element may be just a symbol or string 2347Each element may be just a symbol or string
2348or may be a list of two strings to be printed as if concatenated. 2348or may be a list of two strings to be printed as if concatenated.
@@ -2352,14 +2352,23 @@ alternative, the second serves as annotation.
2352The actual completion alternatives, as inserted, are given `mouse-face' 2352The actual completion alternatives, as inserted, are given `mouse-face'
2353properties of `highlight'. 2353properties of `highlight'.
2354At the end, this runs the normal hook `completion-setup-hook'. 2354At the end, this runs the normal hook `completion-setup-hook'.
2355It can find the completion buffer in `standard-output'. */) 2355It can find the completion buffer in `standard-output'.
2356 (completions) 2356The optional second arg COMMON-SUBSTRING is a string.
2357It is used to put faces, `completions-first-difference` and
2358`completions-common-part' on the completion buffer. The
2359`completions-common-part' face is put on the common substring
2360specified by COMMON-SUBSTRING. If COMMON-SUBSTRING is nil,
2361the faces are not put.
2362Internally, COMMON-SUBSTRING is bound to `completion-common-substring'
2363during running `completion-setup-hook'. */)
2364 (completions, common_substring)
2357 Lisp_Object completions; 2365 Lisp_Object completions;
2366 Lisp_Object common_substring;
2358{ 2367{
2359 Lisp_Object tail, elt; 2368 Lisp_Object tail, elt;
2360 register int i; 2369 register int i;
2361 int column = 0; 2370 int column = 0;
2362 struct gcpro gcpro1, gcpro2; 2371 struct gcpro gcpro1, gcpro2, gcpro3;
2363 struct buffer *old = current_buffer; 2372 struct buffer *old = current_buffer;
2364 int first = 1; 2373 int first = 1;
2365 2374
@@ -2368,7 +2377,7 @@ It can find the completion buffer in `standard-output'. */)
2368 except for ELT. ELT can be pointing to a string 2377 except for ELT. ELT can be pointing to a string
2369 when terpri or Findent_to calls a change hook. */ 2378 when terpri or Findent_to calls a change hook. */
2370 elt = Qnil; 2379 elt = Qnil;
2371 GCPRO2 (completions, elt); 2380 GCPRO3 (completions, elt, common_substring);
2372 2381
2373 if (BUFFERP (Vstandard_output)) 2382 if (BUFFERP (Vstandard_output))
2374 set_buffer_internal (XBUFFER (Vstandard_output)); 2383 set_buffer_internal (XBUFFER (Vstandard_output));
@@ -2517,17 +2526,32 @@ It can find the completion buffer in `standard-output'. */)
2517 } 2526 }
2518 } 2527 }
2519 2528
2520 UNGCPRO;
2521
2522 if (BUFFERP (Vstandard_output)) 2529 if (BUFFERP (Vstandard_output))
2523 set_buffer_internal (old); 2530 set_buffer_internal (old);
2524 2531
2525 if (!NILP (Vrun_hooks)) 2532 if (!NILP (Vrun_hooks))
2526 call1 (Vrun_hooks, intern ("completion-setup-hook")); 2533 {
2534 int count1 = SPECPDL_INDEX ();
2535
2536 specbind (intern ("completion-common-substring"), common_substring);
2537 call1 (Vrun_hooks, intern ("completion-setup-hook"));
2538
2539 unbind_to (count1, Qnil);
2540 }
2541
2542 UNGCPRO;
2527 2543
2528 return Qnil; 2544 return Qnil;
2529} 2545}
2530 2546
2547
2548static Lisp_Object
2549display_completion_list_1 (list)
2550 Lisp_Object list;
2551{
2552 return Fdisplay_completion_list (list, Qnil);
2553}
2554
2531DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_completion_help, 2555DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_completion_help,
2532 0, 0, "", 2556 0, 0, "",
2533 doc: /* Display a list of possible completions of the current minibuffer contents. */) 2557 doc: /* Display a list of possible completions of the current minibuffer contents. */)
@@ -2549,7 +2573,7 @@ DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_co
2549 } 2573 }
2550 else 2574 else
2551 internal_with_output_to_temp_buffer ("*Completions*", 2575 internal_with_output_to_temp_buffer ("*Completions*",
2552 Fdisplay_completion_list, 2576 display_completion_list_1,
2553 Fsort (completions, Qstring_lessp)); 2577 Fsort (completions, Qstring_lessp));
2554 return Qnil; 2578 return Qnil;
2555} 2579}
diff --git a/src/search.c b/src/search.c
index 0a28085308a..346c0e589fa 100644
--- a/src/search.c
+++ b/src/search.c
@@ -395,7 +395,7 @@ string_match_1 (regexp, string, start, posix)
395 395
396DEFUN ("string-match", Fstring_match, Sstring_match, 2, 3, 0, 396DEFUN ("string-match", Fstring_match, Sstring_match, 2, 3, 0,
397 doc: /* Return index of start of first match for REGEXP in STRING, or nil. 397 doc: /* Return index of start of first match for REGEXP in STRING, or nil.
398Case is ignored if `case-fold-search' is non-nil in the current buffer. 398Matching ignores case if `case-fold-search' is non-nil.
399If third arg START is non-nil, start search at that index in STRING. 399If third arg START is non-nil, start search at that index in STRING.
400For index of first char beyond the match, do (match-end 0). 400For index of first char beyond the match, do (match-end 0).
401`match-end' and `match-beginning' also give indices of substrings 401`match-end' and `match-beginning' also give indices of substrings
@@ -1687,7 +1687,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
1687 if (ASCII_BYTE_P (*ptr) || ! multibyte) 1687 if (ASCII_BYTE_P (*ptr) || ! multibyte)
1688 ch = *ptr; 1688 ch = *ptr;
1689 else if (char_base 1689 else if (char_base
1690 && (pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1])) 1690 && ((pat_end - ptr) == 1 || CHAR_HEAD_P (ptr[1])))
1691 { 1691 {
1692 unsigned char *charstart = ptr - 1; 1692 unsigned char *charstart = ptr - 1;
1693 1693
diff --git a/src/syssignal.h b/src/syssignal.h
index 6a5cd39bde9..43e8847cea5 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -146,7 +146,10 @@ extern SIGMASKTYPE sigprocmask_set;
146#undef SIGINFO 146#undef SIGINFO
147#endif 147#endif
148#if defined (SIGIO) && defined (BROKEN_SIGIO) 148#if defined (SIGIO) && defined (BROKEN_SIGIO)
149#undef SIGIO 149# undef SIGIO
150# if defined (__Lynx__)
151# undef SIGPOLL /* Defined as SIGIO on LynxOS */
152# endif
150#endif 153#endif
151#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL) 154#if defined (SIGPOLL) && defined (BROKEN_SIGPOLL)
152#undef SIGPOLL 155#undef SIGPOLL
diff --git a/src/term.c b/src/term.c
index eb575c1792e..0a409931fc1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -820,7 +820,7 @@ encode_terminal_code (src, src_len, coding)
820 int src_len; 820 int src_len;
821 struct coding_system *coding; 821 struct coding_system *coding;
822{ 822{
823 struct glyph *src_start = src, *src_end = src + src_len; 823 struct glyph *src_end = src + src_len;
824 register GLYPH g; 824 register GLYPH g;
825 unsigned char *buf; 825 unsigned char *buf;
826 int nchars, nbytes, required; 826 int nchars, nbytes, required;
@@ -1836,7 +1836,7 @@ produce_stretch_glyph (it)
1836 && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to)) 1836 && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to))
1837 { 1837 {
1838 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p) 1838 if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
1839 align_to = (align_to < 0 1839 align_to = (align_to < 0
1840 ? 0 1840 ? 0
1841 : align_to - window_box_left_offset (it->w, TEXT_AREA)); 1841 : align_to - window_box_left_offset (it->w, TEXT_AREA));
1842 else if (align_to < 0) 1842 else if (align_to < 0)
diff --git a/src/unexelf.c b/src/unexelf.c
index e33a9a1aeb3..f50e849fdcf 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -702,7 +702,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
702#if MAP_ANON == 0 702#if MAP_ANON == 0
703 mmap_fd = open ("/dev/zero", O_RDONLY); 703 mmap_fd = open ("/dev/zero", O_RDONLY);
704 if (mmap_fd < 0) 704 if (mmap_fd < 0)
705 fatal ("Can't open /dev/zero for reading: errno %d\n", errno); 705 fatal ("Can't open /dev/zero for reading: errno %d\n", errno, 0);
706#endif 706#endif
707 707
708 /* We cannot use malloc here because that may use sbrk. If it does, 708 /* We cannot use malloc here because that may use sbrk. If it does,
@@ -713,7 +713,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
713 old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE, 713 old_base = mmap (NULL, old_file_size, PROT_READ | PROT_WRITE,
714 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); 714 MAP_ANON | MAP_PRIVATE, mmap_fd, 0);
715 if (old_base == MAP_FAILED) 715 if (old_base == MAP_FAILED)
716 fatal ("Can't allocate buffer for %s\n", old_name); 716 fatal ("Can't allocate buffer for %s\n", old_name, 0);
717 717
718 if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size) 718 if (read (old_file, old_base, stat_buf.st_size) != stat_buf.st_size)
719 fatal ("Didn't read all of %s: errno %d\n", old_name, errno); 719 fatal ("Didn't read all of %s: errno %d\n", old_name, errno);
@@ -802,7 +802,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
802 new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE, 802 new_base = mmap (NULL, new_file_size, PROT_READ | PROT_WRITE,
803 MAP_ANON | MAP_PRIVATE, mmap_fd, 0); 803 MAP_ANON | MAP_PRIVATE, mmap_fd, 0);
804 if (new_base == MAP_FAILED) 804 if (new_base == MAP_FAILED)
805 fatal ("Can't allocate buffer for %s\n", old_name); 805 fatal ("Can't allocate buffer for %s\n", old_name, 0);
806 806
807 new_file_h = (ElfW(Ehdr) *) new_base; 807 new_file_h = (ElfW(Ehdr) *) new_base;
808 new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff); 808 new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff);
@@ -1079,7 +1079,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
1079 && old_mdebug_index != -1) 1079 && old_mdebug_index != -1)
1080 { 1080 {
1081 int diff = NEW_SECTION_H(nn).sh_offset 1081 int diff = NEW_SECTION_H(nn).sh_offset
1082 - OLD_SECTION_H(old_mdebug_index).sh_offset; 1082 - OLD_SECTION_H(old_mdebug_index).sh_offset;
1083 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); 1083 HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base);
1084 1084
1085 if (diff) 1085 if (diff)
@@ -1257,9 +1257,13 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
1257 /* Write out new_file, and free the buffers. */ 1257 /* Write out new_file, and free the buffers. */
1258 1258
1259 if (write (new_file, new_base, new_file_size) != new_file_size) 1259 if (write (new_file, new_base, new_file_size) != new_file_size)
1260#ifndef emacs
1261 fatal ("Didn't write %d bytes: errno %d\n",
1262 new_file_size, errno);
1263#else
1260 fatal ("Didn't write %d bytes to %s: errno %d\n", 1264 fatal ("Didn't write %d bytes to %s: errno %d\n",
1261 new_file_size, new_base, errno); 1265 new_file_size, new_base, errno);
1262 1266#endif
1263 munmap (old_base, old_file_size); 1267 munmap (old_base, old_file_size);
1264 munmap (new_base, new_file_size); 1268 munmap (new_base, new_file_size);
1265 1269
diff --git a/src/window.c b/src/window.c
index 50212b0c114..be3ecaa2b0b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6293,7 +6293,6 @@ selected frame. */)
6293 (frame) 6293 (frame)
6294 Lisp_Object frame; 6294 Lisp_Object frame;
6295{ 6295{
6296 Lisp_Object alist;
6297 FRAME_PTR f; 6296 FRAME_PTR f;
6298 6297
6299 if (NILP (frame)) 6298 if (NILP (frame))
diff --git a/src/xterm.c b/src/xterm.c
index ce46bd16f42..e20935f0be4 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8100,7 +8100,6 @@ void
8100x_calc_absolute_position (f) 8100x_calc_absolute_position (f)
8101 struct frame *f; 8101 struct frame *f;
8102{ 8102{
8103 int win_x = 0, win_y = 0;
8104 int flags = f->size_hint_flags; 8103 int flags = f->size_hint_flags;
8105 8104
8106 /* We have nothing to do if the current position 8105 /* We have nothing to do if the current position