aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-10-19 14:06:17 +0000
committerKaroly Lorentey2005-10-19 14:06:17 +0000
commit1072671b5b0f1fda9f91ea99da4bf0bd275ce6eb (patch)
treef1b05485825e65d7c0ca06cb273be4fe16a44a3f /src
parent6d8cf83040cdb54a0b1d72bd6a021f9815bd4af2 (diff)
parent8b1b64617b37243f75c4052653761d2e2a3943f3 (diff)
downloademacs-1072671b5b0f1fda9f91ea99da4bf0bd275ce6eb.tar.gz
emacs-1072671b5b0f1fda9f91ea99da4bf0bd275ce6eb.zip
Merged from miles@gnu.org--gnu-2005 (patch 133-141, 596-609)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-596 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-597 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-598 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-599 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-600 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-601 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-602 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-603 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-604 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-605 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-606 Remove lisp/toolbar directory * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-607 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-608 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-609 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-133 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-134 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-135 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-136 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-137 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-138 Update from CVS: texi/gnus.texi (RSS): Fix key description. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-139 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-140 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-141 Update from CVS: texi/gnus.texi (Document Server Internals): Addition. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-426
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog68
-rw-r--r--src/casefiddle.c8
-rw-r--r--src/mac.c40
-rw-r--r--src/macfns.c21
-rw-r--r--src/macterm.c683
-rw-r--r--src/macterm.h2
-rw-r--r--src/minibuf.c32
-rw-r--r--src/search.c40
-rw-r--r--src/w32term.c18
9 files changed, 373 insertions, 539 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 30db0548172..61b658b6b88 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,62 @@
12005-10-18 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macterm.c (note_mouse_movement): Use PtInRect.
4 (XTread_socket): Also ignore mouse motion just before a button
5 release event. Don't process button release event when mouse is
6 not grabbed.
7
82005-10-16 Masatake YAMATO <jet@gyve.org>
9
10 * minibuf.c (Fdisplay_completion_list): Add new optional
11 argument COMMON_SUBSTRING. Bind `completion-common-substring'
12 to the optional argument during running `completion-setup-hook'.
13
142005-10-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
15
16 * mac.c [TARGET_API_MAC_CARBON] (get_cfstring_encoding_from_lisp):
17 Allow nil as argument.
18 [TARGET_API_MAC_CARBON] (Fmac_code_convert_string): Regard nil
19 for encoding arguments as UTF-16 in native byte order, no BOM.
20
21 * macfns.c (Fx_create_frame): Add debugging code.
22 (Fx_show_tip): Set frame pixel width and height.
23
24 * macterm.c (MAC_WINDOW_NORMAL_GC): Remove macro.
25 (FRAME_NORMAL_GC): New macro.
26 (mac_draw_line, mac_clear_area, mac_clear_window)
27 (mac_fill_rectangle, mac_draw_string, mac_draw_string_16)
28 (mac_draw_image_string, mac_draw_image_string_16): Rename from
29 XDrawLine, XClearArea, XClearWindow, XFillRectangle, XDrawString,
30 XDrawString16, XDrawImageString, and XDrawImageString16, respectively.
31 All uses changed.
32 (mac_draw_line, mac_erase_rectangle, mac_clear_area)
33 (mac_clear_window, mac_draw_bitmap, mac_draw_rectangle)
34 (mac_invert_rectangle, mac_draw_string_common, mac_draw_string)
35 (mac_draw_string_16, mac_draw_image_string)
36 (mac_draw_image_string_16, mac_copy_area, mac_copy_area_with_mask)
37 (mac_scroll_area): Drawing functions now take frame as destination.
38 All uses changed.
39 (mac_draw_string_common): Get port height with FRAME_PIXEL_HEIGHT.
40 (x_draw_fringe_bitmap): Set clipping area in face->gc.
41
42 * macterm.h (mac_clear_area): Add extern.
43
442005-10-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
45
46 * macterm.c (note_mouse_movement, XTread_socket): Apply 2005-10-14
47 changes for xterm.c.
48
49 * w32term.c (note_mouse_movement, w32_read_socket): Likewise.
50
512005-10-14 Kenichi Handa <handa@m17n.org>
52
53 * search.c (search_buffer): Give up BM search on case-fold-search
54 if one of a target character has a case-equivalence of different
55 charset even if that target charcter is an ASCII.
56
57 * casefiddle.c (casify_object): Fix for the case that case
58 conversion change the byte length.
59
12005-10-14 Kim F. Storm <storm@cua.dk> 602005-10-14 Kim F. Storm <storm@cua.dk>
2 61
3 * xterm.c (note_mouse_movement): Return 1 if mouse moved; 0 otherwise. 62 * xterm.c (note_mouse_movement): Return 1 if mouse moved; 0 otherwise.
@@ -177,7 +236,7 @@
177 (FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc. 236 (FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc.
178 237
179 * xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT. 238 * xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT.
180 Add debug code. 239 Add debugging code.
181 240
1822005-10-08 Kim F. Storm <storm@cua.dk> 2412005-10-08 Kim F. Storm <storm@cua.dk>
183 242
@@ -221,6 +280,11 @@
221 * xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in 280 * xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in
222 struct glyph_string to for_overlaps. 281 struct glyph_string to for_overlaps.
223 282
2832005-10-04 Richard M. Stallman <rms@gnu.org>
284
285 * alloc.c (refill_memory_reserve): Conditionalize the body,
286 not the function's existence.
287
2242005-10-04 Kim F. Storm <storm@cua.dk> 2882005-10-04 Kim F. Storm <storm@cua.dk>
225 289
226 * window.c (window_split_tree): New function. 290 * window.c (window_split_tree): New function.
@@ -262,7 +326,7 @@
262 * keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler. 326 * keyboard.c (init_keyboard) [MAC_OSX]: Don't install SIGINT handler.
263 327
264 * macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c. 328 * macfns.c (start_hourglass): Apply 2005-05-07 change for xfns.c.
265 (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debug code. 329 (x_create_tip_frame) [GLYPH_DEBUG]: Uncomment debugging code.
266 (Fx_create_frame, x_create_tip_frame) [USE_ATSUI]: 330 (Fx_create_frame, x_create_tip_frame) [USE_ATSUI]:
267 Try ATSUI-compatible 12pt Monaco font first. 331 Try ATSUI-compatible 12pt Monaco font first.
268 332
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 454d184b99b..dee68fcf8c0 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -92,7 +92,8 @@ casify_object (flag, obj)
92 else if (!UPPERCASEP (c) 92 else if (!UPPERCASEP (c)
93 && (!inword || flag != CASE_CAPITALIZE_UP)) 93 && (!inword || flag != CASE_CAPITALIZE_UP))
94 c = UPCASE1 (c); 94 c = UPCASE1 (c);
95 if (ASCII_BYTE_P (c) || (! multibyte && SINGLE_BYTE_CHAR_P (c))) 95 if ((ASCII_BYTE_P (c) && from_len == 1)
96 || (! multibyte && SINGLE_BYTE_CHAR_P (c)))
96 SSET (obj, i, c); 97 SSET (obj, i, c);
97 else 98 else
98 { 99 {
@@ -100,7 +101,10 @@ casify_object (flag, obj)
100 if (from_len == to_len) 101 if (from_len == to_len)
101 CHAR_STRING (c, SDATA (obj) + i); 102 CHAR_STRING (c, SDATA (obj) + i);
102 else 103 else
103 Faset (obj, make_number (n), make_number (c)); 104 {
105 Faset (obj, make_number (n), make_number (c));
106 len += to_len - from_len;
107 }
104 } 108 }
105 if ((int) flag >= (int) CASE_CAPITALIZE) 109 if ((int) flag >= (int) CASE_CAPITALIZE)
106 inword = SYNTAX (c) == Sword; 110 inword = SYNTAX (c) == Sword;
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 f0d07a9fe55..64e20af4a47 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 83561639cbf..a4fe2342a63 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -271,7 +271,7 @@ extern void menubar_selection_callback (FRAME_PTR, int);
271#define GC_BACK_COLOR(gc) (&(gc)->back_color) 271#define GC_BACK_COLOR(gc) (&(gc)->back_color)
272#define GC_FONT(gc) ((gc)->xgcv.font) 272#define GC_FONT(gc) ((gc)->xgcv.font)
273#define GC_CLIP_REGION(gc) ((gc)->clip_region) 273#define GC_CLIP_REGION(gc) ((gc)->clip_region)
274#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc) 274#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
275 275
276static RgnHandle saved_port_clip_region = NULL; 276static RgnHandle saved_port_clip_region = NULL;
277 277
@@ -317,13 +317,12 @@ XFreePixmap (display, pixmap)
317/* Mac version of XDrawLine. */ 317/* Mac version of XDrawLine. */
318 318
319static void 319static void
320XDrawLine (display, w, gc, x1, y1, x2, y2) 320mac_draw_line (f, gc, x1, y1, x2, y2)
321 Display *display; 321 struct frame *f;
322 WindowPtr w;
323 GC gc; 322 GC gc;
324 int x1, y1, x2, y2; 323 int x1, y1, x2, y2;
325{ 324{
326 SetPortWindowPort (w); 325 SetPortWindowPort (FRAME_MAC_WINDOW (f));
327 326
328 RGBForeColor (GC_FORE_COLOR (gc)); 327 RGBForeColor (GC_FORE_COLOR (gc));
329 328
@@ -358,15 +357,15 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
358 357
359 358
360static void 359static void
361mac_erase_rectangle (w, gc, x, y, width, height) 360mac_erase_rectangle (f, gc, x, y, width, height)
362 WindowPtr w; 361 struct frame *f;
363 GC gc; 362 GC gc;
364 int x, y; 363 int x, y;
365 unsigned int width, height; 364 unsigned int width, height;
366{ 365{
367 Rect r; 366 Rect r;
368 367
369 SetPortWindowPort (w); 368 SetPortWindowPort (FRAME_MAC_WINDOW (f));
370 369
371 RGBBackColor (GC_BACK_COLOR (gc)); 370 RGBBackColor (GC_BACK_COLOR (gc));
372 SetRect (&r, x, y, x + width, y + height); 371 SetRect (&r, x, y, x + width, y + height);
@@ -375,43 +374,40 @@ mac_erase_rectangle (w, gc, x, y, width, height)
375 EraseRect (&r); 374 EraseRect (&r);
376 mac_end_clip (GC_CLIP_REGION (gc)); 375 mac_end_clip (GC_CLIP_REGION (gc));
377 376
378 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 377 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
379} 378}
380 379
381 380
382/* Mac version of XClearArea. */ 381/* Mac version of XClearArea. */
383 382
384void 383void
385XClearArea (display, w, x, y, width, height, exposures) 384mac_clear_area (f, x, y, width, height)
386 Display *display; 385 struct frame *f;
387 WindowPtr w;
388 int x, y; 386 int x, y;
389 unsigned int width, height; 387 unsigned int width, height;
390 int exposures;
391{ 388{
392 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height); 389 mac_erase_rectangle (f, FRAME_NORMAL_GC (f), x, y, width, height);
393} 390}
394 391
395/* Mac version of XClearWindow. */ 392/* Mac version of XClearWindow. */
396 393
397static void 394static void
398XClearWindow (display, w) 395mac_clear_window (f)
399 Display *display; 396 struct frame *f;
400 WindowPtr w;
401{ 397{
402 SetPortWindowPort (w); 398 SetPortWindowPort (FRAME_MAC_WINDOW (f));
403 399
404 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 400 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
405 401
406#if TARGET_API_MAC_CARBON 402#if TARGET_API_MAC_CARBON
407 { 403 {
408 Rect r; 404 Rect r;
409 405
410 GetWindowPortBounds (w, &r); 406 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
411 EraseRect (&r); 407 EraseRect (&r);
412 } 408 }
413#else /* not TARGET_API_MAC_CARBON */ 409#else /* not TARGET_API_MAC_CARBON */
414 EraseRect (&(w->portRect)); 410 EraseRect (&(FRAME_MAC_WINDOW (f)->portRect));
415#endif /* not TARGET_API_MAC_CARBON */ 411#endif /* not TARGET_API_MAC_CARBON */
416} 412}
417 413
@@ -419,9 +415,8 @@ XClearWindow (display, w)
419/* Mac replacement for XCopyArea. */ 415/* Mac replacement for XCopyArea. */
420 416
421static void 417static void
422mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) 418mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p)
423 Display *display; 419 struct frame *f;
424 WindowPtr w;
425 GC gc; 420 GC gc;
426 int x, y, width, height; 421 int x, y, width, height;
427 unsigned short *bits; 422 unsigned short *bits;
@@ -434,7 +429,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
434 bitmap.baseAddr = (char *)bits; 429 bitmap.baseAddr = (char *)bits;
435 SetRect (&(bitmap.bounds), 0, 0, width, height); 430 SetRect (&(bitmap.bounds), 0, 0, width, height);
436 431
437 SetPortWindowPort (w); 432 SetPortWindowPort (FRAME_MAC_WINDOW (f));
438 433
439 RGBForeColor (GC_FORE_COLOR (gc)); 434 RGBForeColor (GC_FORE_COLOR (gc));
440 RGBBackColor (GC_BACK_COLOR (gc)); 435 RGBBackColor (GC_BACK_COLOR (gc));
@@ -442,17 +437,22 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
442 437
443 mac_begin_clip (GC_CLIP_REGION (gc)); 438 mac_begin_clip (GC_CLIP_REGION (gc));
444#if TARGET_API_MAC_CARBON 439#if TARGET_API_MAC_CARBON
445 LockPortBits (GetWindowPort (w)); 440 {
446 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)), 441 CGrafPtr port;
447 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0); 442
448 UnlockPortBits (GetWindowPort (w)); 443 GetPort (&port);
444 LockPortBits (port);
445 CopyBits (&bitmap, GetPortBitMapForCopyBits (port),
446 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0);
447 UnlockPortBits (port);
448 }
449#else /* not TARGET_API_MAC_CARBON */ 449#else /* not TARGET_API_MAC_CARBON */
450 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, 450 CopyBits (&bitmap, &(FRAME_MAC_WINDOW (f)->portBits), &(bitmap.bounds), &r,
451 overlay_p ? srcOr : srcCopy, 0); 451 overlay_p ? srcOr : srcCopy, 0);
452#endif /* not TARGET_API_MAC_CARBON */ 452#endif /* not TARGET_API_MAC_CARBON */
453 mac_end_clip (GC_CLIP_REGION (gc)); 453 mac_end_clip (GC_CLIP_REGION (gc));
454 454
455 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 455 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
456} 456}
457 457
458 458
@@ -569,16 +569,15 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
569/* Mac replacement for XFillRectangle. */ 569/* Mac replacement for XFillRectangle. */
570 570
571static void 571static void
572XFillRectangle (display, w, gc, x, y, width, height) 572mac_fill_rectangle (f, gc, x, y, width, height)
573 Display *display; 573 struct frame *f;
574 WindowPtr w;
575 GC gc; 574 GC gc;
576 int x, y; 575 int x, y;
577 unsigned int width, height; 576 unsigned int width, height;
578{ 577{
579 Rect r; 578 Rect r;
580 579
581 SetPortWindowPort (w); 580 SetPortWindowPort (FRAME_MAC_WINDOW (f));
582 581
583 RGBForeColor (GC_FORE_COLOR (gc)); 582 RGBForeColor (GC_FORE_COLOR (gc));
584 SetRect (&r, x, y, x + width, y + height); 583 SetRect (&r, x, y, x + width, y + height);
@@ -589,46 +588,18 @@ XFillRectangle (display, w, gc, x, y, width, height)
589} 588}
590 589
591 590
592#if 0 /* TODO: figure out if we need to do this on Mac. */
593static void
594mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
595 Display *display;
596 Pixmap p;
597 GC gc;
598 int x, y;
599 unsigned int width, height;
600{
601 CGrafPtr old_port;
602 GDHandle old_gdh;
603 Rect r;
604
605 GetGWorld (&old_port, &old_gdh);
606 SetGWorld (p, NULL);
607 RGBForeColor (GC_FORE_COLOR (gc));
608 SetRect (&r, x, y, x + width, y + height);
609
610 LockPixels (GetGWorldPixMap (p));
611 PaintRect (&r); /* using foreground color of gc */
612 UnlockPixels (GetGWorldPixMap (p));
613
614 SetGWorld (old_port, old_gdh);
615}
616#endif
617
618
619/* Mac replacement for XDrawRectangle: dest is a window. */ 591/* Mac replacement for XDrawRectangle: dest is a window. */
620 592
621static void 593static void
622mac_draw_rectangle (display, w, gc, x, y, width, height) 594mac_draw_rectangle (f, gc, x, y, width, height)
623 Display *display; 595 struct frame *f;
624 WindowPtr w;
625 GC gc; 596 GC gc;
626 int x, y; 597 int x, y;
627 unsigned int width, height; 598 unsigned int width, height;
628{ 599{
629 Rect r; 600 Rect r;
630 601
631 SetPortWindowPort (w); 602 SetPortWindowPort (FRAME_MAC_WINDOW (f));
632 603
633 RGBForeColor (GC_FORE_COLOR (gc)); 604 RGBForeColor (GC_FORE_COLOR (gc));
634 SetRect (&r, x, y, x + width + 1, y + height + 1); 605 SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -639,35 +610,6 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
639} 610}
640 611
641 612
642#if 0 /* TODO: figure out if we need to do this on Mac. */
643/* Mac replacement for XDrawRectangle: dest is a Pixmap. */
644
645static void
646mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
647 Display *display;
648 Pixmap p;
649 GC gc;
650 int x, y;
651 unsigned int width, height;
652{
653 CGrafPtr old_port;
654 GDHandle old_gdh;
655 Rect r;
656
657 GetGWorld (&old_port, &old_gdh);
658 SetGWorld (p, NULL);
659 RGBForeColor (GC_FORE_COLOR (gc));
660 SetRect (&r, x, y, x + width + 1, y + height + 1);
661
662 LockPixels (GetGWorldPixMap (p));
663 FrameRect (&r); /* using foreground color of gc */
664 UnlockPixels (GetGWorldPixMap (p));
665
666 SetGWorld (old_port, old_gdh);
667}
668#endif
669
670
671#if USE_ATSUI 613#if USE_ATSUI
672static OSStatus 614static OSStatus
673atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout) 615atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
@@ -724,16 +666,16 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
724} 666}
725#endif 667#endif
726 668
669
727static void 670static void
728mac_invert_rectangle (display, w, x, y, width, height) 671mac_invert_rectangle (f, x, y, width, height)
729 Display *display; 672 struct frame *f;
730 WindowPtr w;
731 int x, y; 673 int x, y;
732 unsigned int width, height; 674 unsigned int width, height;
733{ 675{
734 Rect r; 676 Rect r;
735 677
736 SetPortWindowPort (w); 678 SetPortWindowPort (FRAME_MAC_WINDOW (f));
737 679
738 SetRect (&r, x, y, x + width, y + height); 680 SetRect (&r, x, y, x + width, y + height);
739 681
@@ -742,10 +684,8 @@ mac_invert_rectangle (display, w, x, y, width, height)
742 684
743 685
744static void 686static void
745mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 687mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
746 bytes_per_char) 688 struct frame *f;
747 Display *display;
748 WindowPtr w;
749 GC gc; 689 GC gc;
750 int x, y; 690 int x, y;
751 char *buf; 691 char *buf;
@@ -759,7 +699,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
759 } 699 }
760#endif 700#endif
761 701
762 SetPortWindowPort (w); 702 SetPortWindowPort (FRAME_MAC_WINDOW (f));
763 703
764 RGBForeColor (GC_FORE_COLOR (gc)); 704 RGBForeColor (GC_FORE_COLOR (gc));
765 if (mode != srcOr) 705 if (mode != srcOr)
@@ -804,16 +744,13 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
804 { 744 {
805 CGrafPtr port; 745 CGrafPtr port;
806 CGContextRef context; 746 CGContextRef context;
807 Rect rect; 747 float port_height = FRAME_PIXEL_HEIGHT (f);
808 float port_height;
809 ATSUAttributeTag tags[] = {kATSUCGContextTag}; 748 ATSUAttributeTag tags[] = {kATSUCGContextTag};
810 ByteCount sizes[] = {sizeof (CGContextRef)}; 749 ByteCount sizes[] = {sizeof (CGContextRef)};
811 ATSUAttributeValuePtr values[] = {&context}; 750 ATSUAttributeValuePtr values[] = {&context};
812 751
813 GetPort (&port); 752 GetPort (&port);
814 QDBeginCGContext (port, &context); 753 QDBeginCGContext (port, &context);
815 GetPortBounds (port, &rect);
816 port_height = rect.bottom - rect.top;
817 if (gc->n_clip_rects) 754 if (gc->n_clip_rects)
818 { 755 {
819 CGContextTranslateCTM (context, 0, port_height); 756 CGContextTranslateCTM (context, 0, port_height);
@@ -862,7 +799,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
862#endif 799#endif
863 800
864 if (mode != srcOr) 801 if (mode != srcOr)
865 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 802 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
866#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 803#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
867 if (!NILP(Vmac_use_core_graphics)) 804 if (!NILP(Vmac_use_core_graphics))
868 SwapQDTextFlags(savedFlags); 805 SwapQDTextFlags(savedFlags);
@@ -873,73 +810,65 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
873/* Mac replacement for XDrawString. */ 810/* Mac replacement for XDrawString. */
874 811
875static void 812static void
876XDrawString (display, w, gc, x, y, buf, nchars) 813mac_draw_string (f, gc, x, y, buf, nchars)
877 Display *display; 814 struct frame *f;
878 WindowPtr w;
879 GC gc; 815 GC gc;
880 int x, y; 816 int x, y;
881 char *buf; 817 char *buf;
882 int nchars; 818 int nchars;
883{ 819{
884 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcOr, 1); 820 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1);
885} 821}
886 822
887 823
888/* Mac replacement for XDrawString16. */ 824/* Mac replacement for XDrawString16. */
889 825
890static void 826static void
891XDrawString16 (display, w, gc, x, y, buf, nchars) 827mac_draw_string_16 (f, gc, x, y, buf, nchars)
892 Display *display; 828 struct frame *f;
893 WindowPtr w;
894 GC gc; 829 GC gc;
895 int x, y; 830 int x, y;
896 XChar2b *buf; 831 XChar2b *buf;
897 int nchars; 832 int nchars;
898{ 833{
899 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcOr, 834 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2);
900 2);
901} 835}
902 836
903 837
904/* Mac replacement for XDrawImageString. */ 838/* Mac replacement for XDrawImageString. */
905 839
906static void 840static void
907XDrawImageString (display, w, gc, x, y, buf, nchars) 841mac_draw_image_string (f, gc, x, y, buf, nchars)
908 Display *display; 842 struct frame *f;
909 WindowPtr w;
910 GC gc; 843 GC gc;
911 int x, y; 844 int x, y;
912 char *buf; 845 char *buf;
913 int nchars; 846 int nchars;
914{ 847{
915 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcCopy, 1); 848 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1);
916} 849}
917 850
918 851
919/* Mac replacement for XDrawString16. */ 852/* Mac replacement for XDrawString16. */
920 853
921static void 854static void
922XDrawImageString16 (display, w, gc, x, y, buf, nchars) 855mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
923 Display *display; 856 struct frame *f;
924 WindowPtr w;
925 GC gc; 857 GC gc;
926 int x, y; 858 int x, y;
927 XChar2b *buf; 859 XChar2b *buf;
928 int nchars; 860 int nchars;
929{ 861{
930 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcCopy, 862 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
931 2);
932} 863}
933 864
934 865
935/* Mac replacement for XCopyArea: dest must be window. */ 866/* Mac replacement for XCopyArea: dest must be window. */
936 867
937static void 868static void
938mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x, 869mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y)
939 dest_y)
940 Display *display;
941 Pixmap src; 870 Pixmap src;
942 WindowPtr dest; 871 struct frame *f;
943 GC gc; 872 GC gc;
944 int src_x, src_y; 873 int src_x, src_y;
945 unsigned int width, height; 874 unsigned int width, height;
@@ -947,7 +876,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
947{ 876{
948 Rect src_r, dest_r; 877 Rect src_r, dest_r;
949 878
950 SetPortWindowPort (dest); 879 SetPortWindowPort (FRAME_MAC_WINDOW (f));
951 880
952 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 881 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
953 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 882 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -958,28 +887,32 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
958 mac_begin_clip (GC_CLIP_REGION (gc)); 887 mac_begin_clip (GC_CLIP_REGION (gc));
959 LockPixels (GetGWorldPixMap (src)); 888 LockPixels (GetGWorldPixMap (src));
960#if TARGET_API_MAC_CARBON 889#if TARGET_API_MAC_CARBON
961 LockPortBits (GetWindowPort (dest)); 890 {
962 CopyBits (GetPortBitMapForCopyBits (src), 891 CGrafPtr port;
963 GetPortBitMapForCopyBits (GetWindowPort (dest)), 892
964 &src_r, &dest_r, srcCopy, 0); 893 GetPort (&port);
965 UnlockPortBits (GetWindowPort (dest)); 894 LockPortBits (port);
895 CopyBits (GetPortBitMapForCopyBits (src),
896 GetPortBitMapForCopyBits (port),
897 &src_r, &dest_r, srcCopy, 0);
898 UnlockPortBits (port);
899 }
966#else /* not TARGET_API_MAC_CARBON */ 900#else /* not TARGET_API_MAC_CARBON */
967 CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits), 901 CopyBits (&(((GrafPtr)src)->portBits), &(FRAME_MAC_WINDOW (f)->portBits),
968 &src_r, &dest_r, srcCopy, 0); 902 &src_r, &dest_r, srcCopy, 0);
969#endif /* not TARGET_API_MAC_CARBON */ 903#endif /* not TARGET_API_MAC_CARBON */
970 UnlockPixels (GetGWorldPixMap (src)); 904 UnlockPixels (GetGWorldPixMap (src));
971 mac_end_clip (GC_CLIP_REGION (gc)); 905 mac_end_clip (GC_CLIP_REGION (gc));
972 906
973 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 907 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
974} 908}
975 909
976 910
977static void 911static void
978mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, 912mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y,
979 width, height, dest_x, dest_y) 913 width, height, dest_x, dest_y)
980 Display *display;
981 Pixmap src, mask; 914 Pixmap src, mask;
982 WindowPtr dest; 915 struct frame *f;
983 GC gc; 916 GC gc;
984 int src_x, src_y; 917 int src_x, src_y;
985 unsigned int width, height; 918 unsigned int width, height;
@@ -987,7 +920,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
987{ 920{
988 Rect src_r, dest_r; 921 Rect src_r, dest_r;
989 922
990 SetPortWindowPort (dest); 923 SetPortWindowPort (FRAME_MAC_WINDOW (f));
991 924
992 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 925 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
993 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 926 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -999,29 +932,33 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
999 LockPixels (GetGWorldPixMap (src)); 932 LockPixels (GetGWorldPixMap (src));
1000 LockPixels (GetGWorldPixMap (mask)); 933 LockPixels (GetGWorldPixMap (mask));
1001#if TARGET_API_MAC_CARBON 934#if TARGET_API_MAC_CARBON
1002 LockPortBits (GetWindowPort (dest)); 935 {
1003 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask), 936 CGrafPtr port;
1004 GetPortBitMapForCopyBits (GetWindowPort (dest)), 937
1005 &src_r, &src_r, &dest_r); 938 GetPort (&port);
1006 UnlockPortBits (GetWindowPort (dest)); 939 LockPortBits (port);
940 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
941 GetPortBitMapForCopyBits (port),
942 &src_r, &src_r, &dest_r);
943 UnlockPortBits (port);
944 }
1007#else /* not TARGET_API_MAC_CARBON */ 945#else /* not TARGET_API_MAC_CARBON */
1008 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits), 946 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1009 &(dest->portBits), &src_r, &src_r, &dest_r); 947 &(FRAME_MAC_WINDOW (f)->portBits), &src_r, &src_r, &dest_r);
1010#endif /* not TARGET_API_MAC_CARBON */ 948#endif /* not TARGET_API_MAC_CARBON */
1011 UnlockPixels (GetGWorldPixMap (mask)); 949 UnlockPixels (GetGWorldPixMap (mask));
1012 UnlockPixels (GetGWorldPixMap (src)); 950 UnlockPixels (GetGWorldPixMap (src));
1013 mac_end_clip (GC_CLIP_REGION (gc)); 951 mac_end_clip (GC_CLIP_REGION (gc));
1014 952
1015 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 953 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1016} 954}
1017 955
1018 956
1019/* Mac replacement for XCopyArea: used only for scrolling. */ 957/* Mac replacement for XCopyArea: used only for scrolling. */
1020 958
1021static void 959static void
1022mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 960mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
1023 Display *display; 961 struct frame *f;
1024 WindowPtr w;
1025 GC gc; 962 GC gc;
1026 int src_x, src_y; 963 int src_x, src_y;
1027 unsigned int width, height; 964 unsigned int width, height;
@@ -1032,11 +969,13 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1032 RgnHandle dummy = NewRgn (); /* For avoiding update events. */ 969 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
1033 970
1034 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 971 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1035 ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y, 972 ScrollWindowRect (FRAME_MAC_WINDOW (f),
973 &src_r, dest_x - src_x, dest_y - src_y,
1036 kScrollWindowNoOptions, dummy); 974 kScrollWindowNoOptions, dummy);
1037 DisposeRgn (dummy); 975 DisposeRgn (dummy);
1038#else /* not TARGET_API_MAC_CARBON */ 976#else /* not TARGET_API_MAC_CARBON */
1039 Rect src_r, dest_r; 977 Rect src_r, dest_r;
978 WindowPtr w = FRAME_MAC_WINDOW (f);
1040 979
1041 SetPort (w); 980 SetPort (w);
1042 981
@@ -1051,93 +990,11 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1051 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 990 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
1052 mac_end_clip (GC_CLIP_REGION (gc)); 991 mac_end_clip (GC_CLIP_REGION (gc));
1053 992
1054 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 993 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1055#endif /* not TARGET_API_MAC_CARBON */
1056}
1057
1058
1059#if 0 /* TODO: figure out if we need to do this on Mac. */
1060/* Mac replacement for XCopyArea: dest must be Pixmap. */
1061
1062static void
1063mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1064 dest_x, dest_y)
1065 Display *display;
1066 Pixmap src, dest;
1067 GC gc;
1068 int src_x, src_y;
1069 unsigned int width, height;
1070 int dest_x, dest_y;
1071{
1072 CGrafPtr old_port;
1073 GDHandle old_gdh;
1074 Rect src_r, dest_r;
1075
1076 GetGWorld (&old_port, &old_gdh);
1077 SetGWorld (dest, NULL);
1078 ForeColor (blackColor);
1079 BackColor (whiteColor);
1080
1081 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1082 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1083
1084 LockPixels (GetGWorldPixMap (src));
1085 LockPixels (GetGWorldPixMap (dest));
1086#if TARGET_API_MAC_CARBON
1087 CopyBits (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (dest),
1088 &src_r, &dest_r, srcCopy, 0);
1089#else /* not TARGET_API_MAC_CARBON */
1090 CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits),
1091 &src_r, &dest_r, srcCopy, 0);
1092#endif /* not TARGET_API_MAC_CARBON */ 994#endif /* not TARGET_API_MAC_CARBON */
1093 UnlockPixels (GetGWorldPixMap (dest));
1094 UnlockPixels (GetGWorldPixMap (src));
1095
1096 SetGWorld (old_port, old_gdh);
1097} 995}
1098 996
1099 997
1100static void
1101mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1102 width, height, dest_x, dest_y)
1103 Display *display;
1104 Pixmap src, mask, dest;
1105 GC gc;
1106 int src_x, src_y;
1107 unsigned int width, height;
1108 int dest_x, dest_y;
1109{
1110 CGrafPtr old_port;
1111 GDHandle old_gdh;
1112 Rect src_r, dest_r;
1113
1114 GetGWorld (&old_port, &old_gdh);
1115 SetGWorld (dest, NULL);
1116 ForeColor (blackColor);
1117 BackColor (whiteColor);
1118
1119 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1120 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1121
1122 LockPixels (GetGWorldPixMap (src));
1123 LockPixels (GetGWorldPixMap (mask));
1124 LockPixels (GetGWorldPixMap (dest));
1125#if TARGET_API_MAC_CARBON
1126 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
1127 GetPortBitMapForCopyBits (dest), &src_r, &src_r, &dest_r);
1128#else /* not TARGET_API_MAC_CARBON */
1129 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1130 &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r);
1131#endif /* not TARGET_API_MAC_CARBON */
1132 UnlockPixels (GetGWorldPixMap (dest));
1133 UnlockPixels (GetGWorldPixMap (mask));
1134 UnlockPixels (GetGWorldPixMap (src));
1135
1136 SetGWorld (old_port, old_gdh);
1137}
1138#endif
1139
1140
1141/* Mac replacement for XChangeGC. */ 998/* Mac replacement for XChangeGC. */
1142 999
1143static void 1000static void
@@ -1509,8 +1366,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1509 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc, 1366 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
1510 face->foreground); 1367 face->foreground);
1511 1368
1512 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1369 mac_draw_line (f, f->output_data.mac->normal_gc, x, y0, x, y1);
1513 f->output_data.mac->normal_gc, x, y0, x, y1);
1514} 1370}
1515 1371
1516/* End update of window W (which is equal to updated_window). 1372/* End update of window W (which is equal to updated_window).
@@ -1649,11 +1505,8 @@ x_after_update_window_line (desired_row)
1649 y -= width; 1505 y -= width;
1650 1506
1651 BLOCK_INPUT; 1507 BLOCK_INPUT;
1652 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1508 mac_clear_area (f, 0, y, width, height);
1653 0, y, width, height, 0); 1509 mac_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height);
1654 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1655 FRAME_PIXEL_WIDTH (f) - width, y,
1656 width, height, 0);
1657 UNBLOCK_INPUT; 1510 UNBLOCK_INPUT;
1658 } 1511 }
1659} 1512}
@@ -1672,8 +1525,6 @@ x_draw_fringe_bitmap (w, row, p)
1672{ 1525{
1673 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1526 struct frame *f = XFRAME (WINDOW_FRAME (w));
1674 Display *display = FRAME_MAC_DISPLAY (f); 1527 Display *display = FRAME_MAC_DISPLAY (f);
1675 WindowPtr window = FRAME_MAC_WINDOW (f);
1676 GC gc = f->output_data.mac->normal_gc;
1677 struct face *face = p->face; 1528 struct face *face = p->face;
1678 int rowY; 1529 int rowY;
1679 1530
@@ -1687,12 +1538,12 @@ x_draw_fringe_bitmap (w, row, p)
1687 int oldVH = row->visible_height; 1538 int oldVH = row->visible_height;
1688 row->visible_height = p->h; 1539 row->visible_height = p->h;
1689 row->y -= rowY - p->y; 1540 row->y -= rowY - p->y;
1690 x_clip_to_row (w, row, -1, gc); 1541 x_clip_to_row (w, row, -1, face->gc);
1691 row->y = oldY; 1542 row->y = oldY;
1692 row->visible_height = oldVH; 1543 row->visible_height = oldVH;
1693 } 1544 }
1694 else 1545 else
1695 x_clip_to_row (w, row, -1, gc); 1546 x_clip_to_row (w, row, -1, face->gc);
1696 1547
1697 if (p->bx >= 0 && !p->overlay_p) 1548 if (p->bx >= 0 && !p->overlay_p)
1698 { 1549 {
@@ -1707,7 +1558,7 @@ x_draw_fringe_bitmap (w, row, p)
1707 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); 1558 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
1708#endif 1559#endif
1709 1560
1710 mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny); 1561 mac_erase_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
1711 1562
1712#if 0 /* MAC_TODO: stipple */ 1563#if 0 /* MAC_TODO: stipple */
1713 if (!face->stipple) 1564 if (!face->stipple)
@@ -1726,12 +1577,12 @@ x_draw_fringe_bitmap (w, row, p)
1726 ? (p->overlay_p ? face->background 1577 ? (p->overlay_p ? face->background
1727 : f->output_data.mac->cursor_pixel) 1578 : f->output_data.mac->cursor_pixel)
1728 : face->foreground)); 1579 : face->foreground));
1729 mac_draw_bitmap (display, window, face->gc, p->x, p->y, 1580 mac_draw_bitmap (f, face->gc, p->x, p->y,
1730 p->wd, p->h, bits, p->overlay_p); 1581 p->wd, p->h, bits, p->overlay_p);
1731 XSetForeground (display, face->gc, gcv.foreground); 1582 XSetForeground (display, face->gc, gcv.foreground);
1732 } 1583 }
1733 1584
1734 mac_reset_clip_rectangles (display, gc); 1585 mac_reset_clip_rectangles (display, face->gc);
1735} 1586}
1736 1587
1737 1588
@@ -2282,7 +2133,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
2282 struct glyph_string *s; 2133 struct glyph_string *s;
2283 int x, y, w, h; 2134 int x, y, w, h;
2284{ 2135{
2285 mac_erase_rectangle (s->window, s->gc, x, y, w, h); 2136 mac_erase_rectangle (s->f, s->gc, x, y, w, h);
2286} 2137}
2287 2138
2288 2139
@@ -2364,9 +2215,8 @@ x_draw_glyph_string_foreground (s)
2364 for (i = 0; i < s->nchars; ++i) 2215 for (i = 0; i < s->nchars; ++i)
2365 { 2216 {
2366 struct glyph *g = s->first_glyph + i; 2217 struct glyph *g = s->first_glyph + i;
2367 mac_draw_rectangle (s->display, s->window, 2218 mac_draw_rectangle (s->f, s->gc, x, s->y,
2368 s->gc, x, s->y, g->pixel_width - 1, 2219 g->pixel_width - 1, s->height - 1);
2369 s->height - 1);
2370 x += g->pixel_width; 2220 x += g->pixel_width;
2371 } 2221 }
2372 } 2222 }
@@ -2403,21 +2253,21 @@ x_draw_glyph_string_foreground (s)
2403 || GC_FONT (s->gc)->mac_style 2253 || GC_FONT (s->gc)->mac_style
2404#endif 2254#endif
2405 ) 2255 )
2406 XDrawString16 (s->display, s->window, s->gc, x, 2256 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2407 s->ybase - boff, s->char2b, s->nchars); 2257 s->char2b, s->nchars);
2408 else 2258 else
2409 XDrawString (s->display, s->window, s->gc, x, 2259 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2410 s->ybase - boff, char1b, s->nchars); 2260 char1b, s->nchars);
2411 } 2261 }
2412#if defined (MAC_OS8) && !USE_ATSUI 2262#if defined (MAC_OS8) && !USE_ATSUI
2413 else 2263 else
2414 { 2264 {
2415 if (s->two_byte_p) 2265 if (s->two_byte_p)
2416 XDrawImageString16 (s->display, s->window, s->gc, x, 2266 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2417 s->ybase - boff, s->char2b, s->nchars); 2267 s->char2b, s->nchars);
2418 else 2268 else
2419 XDrawImageString (s->display, s->window, s->gc, x, 2269 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2420 s->ybase - boff, char1b, s->nchars); 2270 char1b, s->nchars);
2421 } 2271 }
2422#endif 2272#endif
2423 } 2273 }
@@ -2449,16 +2299,16 @@ x_draw_composite_glyph_string_foreground (s)
2449 if (s->font_not_found_p) 2299 if (s->font_not_found_p)
2450 { 2300 {
2451 if (s->gidx == 0) 2301 if (s->gidx == 0)
2452 mac_draw_rectangle (s->display, s->window, s->gc, x, s->y, 2302 mac_draw_rectangle (s->f, s->gc, x, s->y,
2453 s->width - 1, s->height - 1); 2303 s->width - 1, s->height - 1);
2454 } 2304 }
2455 else 2305 else
2456 { 2306 {
2457 for (i = 0; i < s->nchars; i++, ++s->gidx) 2307 for (i = 0; i < s->nchars; i++, ++s->gidx)
2458 XDrawString16 (s->display, s->window, s->gc, 2308 mac_draw_string_16 (s->f, s->gc,
2459 x + s->cmp->offsets[s->gidx * 2], 2309 x + s->cmp->offsets[s->gidx * 2],
2460 s->ybase - s->cmp->offsets[s->gidx * 2 + 1], 2310 s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
2461 s->char2b + i, 1); 2311 s->char2b + i, 1);
2462 } 2312 }
2463} 2313}
2464 2314
@@ -2814,7 +2664,6 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2814 Rect *clip_rect; 2664 Rect *clip_rect;
2815{ 2665{
2816 Display *dpy = FRAME_MAC_DISPLAY (f); 2666 Display *dpy = FRAME_MAC_DISPLAY (f);
2817 Window window = FRAME_MAC_WINDOW (f);
2818 int i; 2667 int i;
2819 GC gc; 2668 GC gc;
2820 2669
@@ -2827,15 +2676,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2827 /* Top. */ 2676 /* Top. */
2828 if (top_p) 2677 if (top_p)
2829 for (i = 0; i < width; ++i) 2678 for (i = 0; i < width; ++i)
2830 XDrawLine (dpy, window, gc, 2679 mac_draw_line (f, gc,
2831 left_x + i * left_p, top_y + i, 2680 left_x + i * left_p, top_y + i,
2832 right_x - i * right_p, top_y + i); 2681 right_x - i * right_p, top_y + i);
2833 2682
2834 /* Left. */ 2683 /* Left. */
2835 if (left_p) 2684 if (left_p)
2836 for (i = 0; i < width; ++i) 2685 for (i = 0; i < width; ++i)
2837 XDrawLine (dpy, window, gc, 2686 mac_draw_line (f, gc,
2838 left_x + i, top_y + i, left_x + i, bottom_y - i); 2687 left_x + i, top_y + i, left_x + i, bottom_y - i);
2839 2688
2840 mac_reset_clip_rectangles (dpy, gc); 2689 mac_reset_clip_rectangles (dpy, gc);
2841 if (raised_p) 2690 if (raised_p)
@@ -2847,15 +2696,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2847 /* Bottom. */ 2696 /* Bottom. */
2848 if (bot_p) 2697 if (bot_p)
2849 for (i = 0; i < width; ++i) 2698 for (i = 0; i < width; ++i)
2850 XDrawLine (dpy, window, gc, 2699 mac_draw_line (f, gc,
2851 left_x + i * left_p, bottom_y - i, 2700 left_x + i * left_p, bottom_y - i,
2852 right_x - i * right_p, bottom_y - i); 2701 right_x - i * right_p, bottom_y - i);
2853 2702
2854 /* Right. */ 2703 /* Right. */
2855 if (right_p) 2704 if (right_p)
2856 for (i = 0; i < width; ++i) 2705 for (i = 0; i < width; ++i)
2857 XDrawLine (dpy, window, gc, 2706 mac_draw_line (f, gc,
2858 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); 2707 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
2859 2708
2860 mac_reset_clip_rectangles (dpy, gc); 2709 mac_reset_clip_rectangles (dpy, gc);
2861} 2710}
@@ -2882,22 +2731,22 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2882 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1); 2731 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1);
2883 2732
2884 /* Top. */ 2733 /* Top. */
2885 XFillRectangle (s->display, s->window, s->gc, 2734 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2886 left_x, top_y, right_x - left_x + 1, width); 2735 right_x - left_x + 1, width);
2887 2736
2888 /* Left. */ 2737 /* Left. */
2889 if (left_p) 2738 if (left_p)
2890 XFillRectangle (s->display, s->window, s->gc, 2739 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2891 left_x, top_y, width, bottom_y - top_y + 1); 2740 width, bottom_y - top_y + 1);
2892 2741
2893 /* Bottom. */ 2742 /* Bottom. */
2894 XFillRectangle (s->display, s->window, s->gc, 2743 mac_fill_rectangle (s->f, s->gc, left_x, bottom_y - width + 1,
2895 left_x, bottom_y - width + 1, right_x - left_x + 1, width); 2744 right_x - left_x + 1, width);
2896 2745
2897 /* Right. */ 2746 /* Right. */
2898 if (right_p) 2747 if (right_p)
2899 XFillRectangle (s->display, s->window, s->gc, 2748 mac_fill_rectangle (s->f, s->gc, right_x - width + 1,
2900 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2749 top_y, width, bottom_y - top_y + 1);
2901 2750
2902 XSetForeground (s->display, s->gc, xgcv.foreground); 2751 XSetForeground (s->display, s->gc, xgcv.foreground);
2903 mac_reset_clip_rectangles (s->display, s->gc); 2752 mac_reset_clip_rectangles (s->display, s->gc);
@@ -2984,13 +2833,13 @@ x_draw_image_foreground (s)
2984 x_set_glyph_string_clipping (s); 2833 x_set_glyph_string_clipping (s);
2985 2834
2986 if (s->img->mask) 2835 if (s->img->mask)
2987 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, 2836 mac_copy_area_with_mask (s->img->pixmap, s->img->mask,
2988 s->window, s->gc, s->slice.x, s->slice.y, 2837 s->f, s->gc, s->slice.x, s->slice.y,
2989 s->slice.width, s->slice.height, x, y); 2838 s->slice.width, s->slice.height, x, y);
2990 else 2839 else
2991 { 2840 {
2992 mac_copy_area (s->display, s->img->pixmap, 2841 mac_copy_area (s->img->pixmap,
2993 s->window, s->gc, s->slice.x, s->slice.y, 2842 s->f, s->gc, s->slice.x, s->slice.y,
2994 s->slice.width, s->slice.height, x, y); 2843 s->slice.width, s->slice.height, x, y);
2995 2844
2996 /* When the image has a mask, we can expect that at 2845 /* When the image has a mask, we can expect that at
@@ -3003,8 +2852,7 @@ x_draw_image_foreground (s)
3003 { 2852 {
3004 int r = s->img->relief; 2853 int r = s->img->relief;
3005 if (r < 0) r = -r; 2854 if (r < 0) r = -r;
3006 mac_draw_rectangle (s->display, s->window, s->gc, 2855 mac_draw_rectangle (s->f, s->gc, x - r, y - r,
3007 x - r, y - r,
3008 s->slice.width + r*2 - 1, 2856 s->slice.width + r*2 - 1,
3009 s->slice.height + r*2 - 1); 2857 s->slice.height + r*2 - 1);
3010 } 2858 }
@@ -3012,7 +2860,7 @@ x_draw_image_foreground (s)
3012 } 2860 }
3013 else 2861 else
3014 /* Draw a rectangle if image could not be loaded. */ 2862 /* Draw a rectangle if image could not be loaded. */
3015 mac_draw_rectangle (s->display, s->window, s->gc, x, y, 2863 mac_draw_rectangle (s->f, s->gc, x, y,
3016 s->slice.width - 1, s->slice.height - 1); 2864 s->slice.width - 1, s->slice.height - 1);
3017} 2865}
3018 2866
@@ -3070,70 +2918,6 @@ x_draw_image_relief (s)
3070} 2918}
3071 2919
3072 2920
3073#if 0 /* TODO: figure out if we need to do this on Mac. */
3074/* Draw the foreground of image glyph string S to PIXMAP. */
3075
3076static void
3077x_draw_image_foreground_1 (s, pixmap)
3078 struct glyph_string *s;
3079 Pixmap pixmap;
3080{
3081 int x = 0;
3082 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
3083
3084 /* If first glyph of S has a left box line, start drawing it to the
3085 right of that line. */
3086 if (s->face->box != FACE_NO_BOX
3087 && s->first_glyph->left_box_line_p
3088 && s->slice.x == 0)
3089 x += abs (s->face->box_line_width);
3090
3091 /* If there is a margin around the image, adjust x- and y-position
3092 by that margin. */
3093 if (s->slice.x == 0)
3094 x += s->img->hmargin;
3095 if (s->slice.y == 0)
3096 y += s->img->vmargin;
3097
3098 if (s->img->pixmap)
3099 {
3100 if (s->img->mask)
3101 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
3102 s->img->mask, pixmap, s->gc,
3103 s->slice.x, s->slice.y,
3104 s->slice.width, s->slice.height,
3105 x, y);
3106 else
3107 {
3108 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
3109 s->slice.x, s->slice.y,
3110 s->slice.width, s->slice.height,
3111 x, y);
3112
3113 /* When the image has a mask, we can expect that at
3114 least part of a mouse highlight or a block cursor will
3115 be visible. If the image doesn't have a mask, make
3116 a block cursor visible by drawing a rectangle around
3117 the image. I believe it's looking better if we do
3118 nothing here for mouse-face. */
3119 if (s->hl == DRAW_CURSOR)
3120 {
3121 int r = s->img->relief;
3122 if (r < 0) r = -r;
3123 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
3124 s->slice.width + r*2 - 1,
3125 s->slice.height + r*2 - 1);
3126 }
3127 }
3128 }
3129 else
3130 /* Draw a rectangle if image could not be loaded. */
3131 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
3132 s->slice.width - 1, s->slice.height - 1);
3133}
3134#endif
3135
3136
3137/* Draw part of the background of glyph string S. X, Y, W, and H 2921/* Draw part of the background of glyph string S. X, Y, W, and H
3138 give the rectangle to draw. */ 2922 give the rectangle to draw. */
3139 2923
@@ -3203,62 +2987,13 @@ x_draw_image_glyph_string (s)
3203 if (s->slice.y == 0) 2987 if (s->slice.y == 0)
3204 y += box_line_vwidth; 2988 y += box_line_vwidth;
3205 2989
3206#if 0 /* TODO: figure out if we need to do this on Mac. */ 2990 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3207 if (s->img->mask)
3208 {
3209 /* Create a pixmap as large as the glyph string. Fill it
3210 with the background color. Copy the image to it, using
3211 its mask. Copy the temporary pixmap to the display. */
3212 int depth = one_mac_display_info.n_planes;
3213
3214 /* Create a pixmap as large as the glyph string. */
3215 pixmap = XCreatePixmap (s->display, s->window,
3216 s->background_width,
3217 s->height, depth);
3218
3219 /* Fill the pixmap with the background color/stipple. */
3220#if 0 /* TODO: stipple */
3221 if (s->stippled_p)
3222 {
3223 /* Fill background with a stipple pattern. */
3224 XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
3225 XFillRectangle (s->display, pixmap, s->gc,
3226 0, 0, s->background_width, s->height);
3227 XSetFillStyle (s->display, s->gc, FillSolid);
3228 }
3229 else
3230#endif
3231 {
3232 XGCValues xgcv;
3233 XGetGCValues (s->display, s->gc, GCForeground | GCBackground,
3234 &xgcv);
3235 XSetForeground (s->display, s->gc, xgcv.background);
3236 mac_fill_rectangle_to_pixmap (s->display, pixmap, s->gc,
3237 0, 0, s->background_width,
3238 s->height);
3239 XSetForeground (s->display, s->gc, xgcv.foreground);
3240 }
3241 }
3242 else
3243#endif
3244 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3245 2991
3246 s->background_filled_p = 1; 2992 s->background_filled_p = 1;
3247 } 2993 }
3248 2994
3249 /* Draw the foreground. */ 2995 /* Draw the foreground. */
3250#if 0 /* TODO: figure out if we need to do this on Mac. */ 2996 x_draw_image_foreground (s);
3251 if (pixmap != 0)
3252 {
3253 x_draw_image_foreground_1 (s, pixmap);
3254 x_set_glyph_string_clipping (s);
3255 mac_copy_area (s->display, pixmap, s->window, s->gc,
3256 0, 0, s->background_width, s->height, s->x, s->y);
3257 XFreePixmap (s->display, pixmap);
3258 }
3259 else
3260#endif
3261 x_draw_image_foreground (s);
3262 2997
3263 /* If we must draw a relief around the image, do it. */ 2998 /* If we must draw a relief around the image, do it. */
3264 if (s->img->relief 2999 if (s->img->relief
@@ -3317,7 +3052,7 @@ x_draw_stretch_glyph_string (s)
3317 } 3052 }
3318 else 3053 else
3319#endif /* MAC_TODO */ 3054#endif /* MAC_TODO */
3320 mac_erase_rectangle (s->window, gc, x, y, w, h); 3055 mac_erase_rectangle (s->f, gc, x, y, w, h);
3321 } 3056 }
3322 } 3057 }
3323 else if (!s->background_filled_p) 3058 else if (!s->background_filled_p)
@@ -3408,15 +3143,15 @@ x_draw_glyph_string (s)
3408 unsigned long dy = s->height - h; 3143 unsigned long dy = s->height - h;
3409 3144
3410 if (s->face->underline_defaulted_p) 3145 if (s->face->underline_defaulted_p)
3411 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3146 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3412 s->width, h); 3147 s->width, h);
3413 else 3148 else
3414 { 3149 {
3415 XGCValues xgcv; 3150 XGCValues xgcv;
3416 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3151 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3417 XSetForeground (s->display, s->gc, s->face->underline_color); 3152 XSetForeground (s->display, s->gc, s->face->underline_color);
3418 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3153 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3419 s->width, h); 3154 s->width, h);
3420 XSetForeground (s->display, s->gc, xgcv.foreground); 3155 XSetForeground (s->display, s->gc, xgcv.foreground);
3421 } 3156 }
3422 } 3157 }
@@ -3427,15 +3162,15 @@ x_draw_glyph_string (s)
3427 unsigned long dy = 0, h = 1; 3162 unsigned long dy = 0, h = 1;
3428 3163
3429 if (s->face->overline_color_defaulted_p) 3164 if (s->face->overline_color_defaulted_p)
3430 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3165 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3431 s->width, h); 3166 s->width, h);
3432 else 3167 else
3433 { 3168 {
3434 XGCValues xgcv; 3169 XGCValues xgcv;
3435 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3170 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3436 XSetForeground (s->display, s->gc, s->face->overline_color); 3171 XSetForeground (s->display, s->gc, s->face->overline_color);
3437 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3172 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3438 s->width, h); 3173 s->width, h);
3439 XSetForeground (s->display, s->gc, xgcv.foreground); 3174 XSetForeground (s->display, s->gc, xgcv.foreground);
3440 } 3175 }
3441 } 3176 }
@@ -3447,15 +3182,15 @@ x_draw_glyph_string (s)
3447 unsigned long dy = (s->height - h) / 2; 3182 unsigned long dy = (s->height - h) / 2;
3448 3183
3449 if (s->face->strike_through_color_defaulted_p) 3184 if (s->face->strike_through_color_defaulted_p)
3450 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3185 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3451 s->width, h); 3186 s->width, h);
3452 else 3187 else
3453 { 3188 {
3454 XGCValues xgcv; 3189 XGCValues xgcv;
3455 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3190 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3456 XSetForeground (s->display, s->gc, s->face->strike_through_color); 3191 XSetForeground (s->display, s->gc, s->face->strike_through_color);
3457 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3192 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3458 s->width, h); 3193 s->width, h);
3459 XSetForeground (s->display, s->gc, xgcv.foreground); 3194 XSetForeground (s->display, s->gc, xgcv.foreground);
3460 } 3195 }
3461 } 3196 }
@@ -3476,8 +3211,7 @@ mac_shift_glyphs_for_insert (f, x, y, width, height, shift_by)
3476 struct frame *f; 3211 struct frame *f;
3477 int x, y, width, height, shift_by; 3212 int x, y, width, height, shift_by;
3478{ 3213{
3479 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3214 mac_scroll_area (f, f->output_data.mac->normal_gc,
3480 f->output_data.mac->normal_gc,
3481 x, y, width, height, 3215 x, y, width, height,
3482 x + shift_by, y); 3216 x + shift_by, y);
3483} 3217}
@@ -3515,7 +3249,7 @@ x_clear_frame ()
3515 /* We don't set the output cursor here because there will always 3249 /* We don't set the output cursor here because there will always
3516 follow an explicit cursor_to. */ 3250 follow an explicit cursor_to. */
3517 BLOCK_INPUT; 3251 BLOCK_INPUT;
3518 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); 3252 mac_clear_window (f);
3519 3253
3520 /* We have to clear the scroll bars, too. If we have changed 3254 /* We have to clear the scroll bars, too. If we have changed
3521 colors or something like that, then they should be notified. */ 3255 colors or something like that, then they should be notified. */
@@ -3605,21 +3339,18 @@ XTflash (f)
3605 /* If window is tall, flash top and bottom line. */ 3339 /* If window is tall, flash top and bottom line. */
3606 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3340 if (height > 3 * FRAME_LINE_HEIGHT (f))
3607 { 3341 {
3608 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3342 mac_invert_rectangle (f, flash_left,
3609 flash_left,
3610 (FRAME_INTERNAL_BORDER_WIDTH (f) 3343 (FRAME_INTERNAL_BORDER_WIDTH (f)
3611 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3344 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3612 width, flash_height); 3345 width, flash_height);
3613 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3346 mac_invert_rectangle (f, flash_left,
3614 flash_left,
3615 (height - flash_height 3347 (height - flash_height
3616 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3348 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3617 width, flash_height); 3349 width, flash_height);
3618 } 3350 }
3619 else 3351 else
3620 /* If it is short, flash it all. */ 3352 /* If it is short, flash it all. */
3621 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3353 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3622 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3623 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3354 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3624 3355
3625 x_flush (f); 3356 x_flush (f);
@@ -3659,21 +3390,18 @@ XTflash (f)
3659 /* If window is tall, flash top and bottom line. */ 3390 /* If window is tall, flash top and bottom line. */
3660 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3391 if (height > 3 * FRAME_LINE_HEIGHT (f))
3661 { 3392 {
3662 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3393 mac_invert_rectangle (f, flash_left,
3663 flash_left,
3664 (FRAME_INTERNAL_BORDER_WIDTH (f) 3394 (FRAME_INTERNAL_BORDER_WIDTH (f)
3665 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3395 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3666 width, flash_height); 3396 width, flash_height);
3667 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3397 mac_invert_rectangle (f, flash_left,
3668 flash_left,
3669 (height - flash_height 3398 (height - flash_height
3670 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3399 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3671 width, flash_height); 3400 width, flash_height);
3672 } 3401 }
3673 else 3402 else
3674 /* If it is short, flash it all. */ 3403 /* If it is short, flash it all. */
3675 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3404 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3676 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3677 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3405 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3678 3406
3679 x_flush (f); 3407 x_flush (f);
@@ -3778,11 +3506,10 @@ x_scroll_run (w, run)
3778 updated_window = w; 3506 updated_window = w;
3779 x_clear_cursor (w); 3507 x_clear_cursor (w);
3780 3508
3781 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3509 mac_scroll_area (f, f->output_data.mac->normal_gc,
3782 f->output_data.mac->normal_gc, 3510 x, from_y,
3783 x, from_y, 3511 width, height,
3784 width, height, 3512 x, to_y);
3785 x, to_y);
3786 3513
3787 UNBLOCK_INPUT; 3514 UNBLOCK_INPUT;
3788} 3515}
@@ -4149,7 +3876,7 @@ x_get_keysym_name (keysym)
4149static Point last_mouse_motion_position; 3876static Point last_mouse_motion_position;
4150static Lisp_Object last_mouse_motion_frame; 3877static Lisp_Object last_mouse_motion_frame;
4151 3878
4152static void 3879static int
4153note_mouse_movement (frame, pos) 3880note_mouse_movement (frame, pos)
4154 FRAME_PTR frame; 3881 FRAME_PTR frame;
4155 Point *pos; 3882 Point *pos;
@@ -4180,19 +3907,20 @@ note_mouse_movement (frame, pos)
4180 rif->define_frame_cursor (frame, 3907 rif->define_frame_cursor (frame,
4181 frame->output_data.mac->nontext_cursor); 3908 frame->output_data.mac->nontext_cursor);
4182 } 3909 }
3910 return 1;
4183 } 3911 }
4184 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3912 /* Has the mouse moved off the glyph it was on at the last sighting? */
4185 else if (pos->h < last_mouse_glyph.left 3913 if (!PtInRect (*pos, &last_mouse_glyph))
4186 || pos->h >= last_mouse_glyph.right
4187 || pos->v < last_mouse_glyph.top
4188 || pos->v >= last_mouse_glyph.bottom)
4189 { 3914 {
4190 frame->mouse_moved = 1; 3915 frame->mouse_moved = 1;
4191 last_mouse_scroll_bar = Qnil; 3916 last_mouse_scroll_bar = Qnil;
4192 note_mouse_highlight (frame, pos->h, pos->v); 3917 note_mouse_highlight (frame, pos->h, pos->v);
4193 /* Remember which glyph we're now on. */ 3918 /* Remember which glyph we're now on. */
4194 remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph); 3919 remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph);
3920 return 1;
4195 } 3921 }
3922
3923 return 0;
4196} 3924}
4197 3925
4198 3926
@@ -4825,8 +4553,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4825 if (NILP (w->vertical_scroll_bar)) 4553 if (NILP (w->vertical_scroll_bar))
4826 { 4554 {
4827 BLOCK_INPUT; 4555 BLOCK_INPUT;
4828 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4556 mac_clear_area (f, left, top, width, height);
4829 left, top, width, height, 0);
4830 UNBLOCK_INPUT; 4557 UNBLOCK_INPUT;
4831 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top, 4558 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top,
4832 disp_height); 4559 disp_height);
@@ -4850,14 +4577,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4850 { 4577 {
4851 /* Since toolkit scroll bars are smaller than the space reserved 4578 /* Since toolkit scroll bars are smaller than the space reserved
4852 for them on the frame, we have to clear "under" them. */ 4579 for them on the frame, we have to clear "under" them. */
4853 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4580 mac_clear_area (f, left, top, width, height);
4854 left, top, width, height, 0);
4855
4856#if 0
4857 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
4858 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4859 sb_left - 1, top, 1, height, 0);
4860#endif
4861 4581
4862 HideControl (ch); 4582 HideControl (ch);
4863 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4583 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
@@ -5290,7 +5010,7 @@ x_draw_hollow_cursor (w, row)
5290 5010
5291 /* Set clipping, draw the rectangle, and reset clipping again. */ 5011 /* Set clipping, draw the rectangle, and reset clipping again. */
5292 x_clip_to_row (w, row, TEXT_AREA, gc); 5012 x_clip_to_row (w, row, TEXT_AREA, gc);
5293 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 5013 mac_draw_rectangle (f, gc, x, y, wd, h);
5294 mac_reset_clip_rectangles (dpy, gc); 5014 mac_reset_clip_rectangles (dpy, gc);
5295} 5015}
5296 5016
@@ -5363,17 +5083,17 @@ x_draw_bar_cursor (w, row, width, kind)
5363 x_clip_to_row (w, row, TEXT_AREA, gc); 5083 x_clip_to_row (w, row, TEXT_AREA, gc);
5364 5084
5365 if (kind == BAR_CURSOR) 5085 if (kind == BAR_CURSOR)
5366 XFillRectangle (dpy, window, gc, 5086 mac_fill_rectangle (f, gc,
5367 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5087 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5368 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 5088 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
5369 width, row->height); 5089 width, row->height);
5370 else 5090 else
5371 XFillRectangle (dpy, window, gc, 5091 mac_fill_rectangle (f, gc,
5372 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5092 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5373 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y + 5093 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
5374 row->height - width), 5094 row->height - width),
5375 cursor_glyph->pixel_width, 5095 cursor_glyph->pixel_width,
5376 width); 5096 width);
5377 5097
5378 mac_reset_clip_rectangles (dpy, gc); 5098 mac_reset_clip_rectangles (dpy, gc);
5379 } 5099 }
@@ -5398,8 +5118,7 @@ mac_clear_frame_area (f, x, y, width, height)
5398 struct frame *f; 5118 struct frame *f;
5399 int x, y, width, height; 5119 int x, y, width, height;
5400{ 5120{
5401 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 5121 mac_clear_area (f, x, y, width, height);
5402 x, y, width, height, 0);
5403} 5122}
5404 5123
5405 5124
@@ -9799,7 +9518,8 @@ XTread_socket (sd, expected, hold_quit)
9799 } 9518 }
9800 } 9519 }
9801 9520
9802 if (er.what != mouseDown && part_code != inContent) 9521 if (er.what != mouseDown &&
9522 (part_code != inContent || dpyinfo->grabbed == 0))
9803 break; 9523 break;
9804 9524
9805 switch (part_code) 9525 switch (part_code)
@@ -9922,12 +9642,6 @@ XTread_socket (sd, expected, hold_quit)
9922 { 9642 {
9923 dpyinfo->grabbed |= (1 << inev.code); 9643 dpyinfo->grabbed |= (1 << inev.code);
9924 last_mouse_frame = f; 9644 last_mouse_frame = f;
9925 /* Ignore any mouse motion that happened
9926 before this event; any subsequent
9927 mouse-movement Emacs events should reflect
9928 only motion after the ButtonPress. */
9929 if (f != 0)
9930 f->mouse_moved = 0;
9931 9645
9932 if (!tool_bar_p) 9646 if (!tool_bar_p)
9933 last_tool_bar_item = -1; 9647 last_tool_bar_item = -1;
@@ -9943,6 +9657,13 @@ XTread_socket (sd, expected, hold_quit)
9943 dpyinfo->grabbed &= ~(1 << inev.code); 9657 dpyinfo->grabbed &= ~(1 << inev.code);
9944 } 9658 }
9945 9659
9660 /* Ignore any mouse motion that happened before
9661 this event; any subsequent mouse-movement Emacs
9662 events should reflect only motion after the
9663 ButtonPress. */
9664 if (f != 0)
9665 f->mouse_moved = 0;
9666
9946#ifdef USE_TOOLKIT_SCROLL_BARS 9667#ifdef USE_TOOLKIT_SCROLL_BARS
9947 if (inev.kind == MOUSE_CLICK_EVENT) 9668 if (inev.kind == MOUSE_CLICK_EVENT)
9948#endif 9669#endif
@@ -10031,8 +9752,7 @@ XTread_socket (sd, expected, hold_quit)
10031 er.where.h + 1, er.where.v + 1); 9752 er.where.h + 1, er.where.v + 1);
10032#endif 9753#endif
10033 previous_help_echo_string = help_echo_string; 9754 previous_help_echo_string = help_echo_string;
10034 help_echo_string = help_echo_object = help_echo_window = Qnil; 9755 help_echo_string = Qnil;
10035 help_echo_pos = -1;
10036 9756
10037 if (dpyinfo->grabbed && last_mouse_frame 9757 if (dpyinfo->grabbed && last_mouse_frame
10038 && FRAME_LIVE_P (last_mouse_frame)) 9758 && FRAME_LIVE_P (last_mouse_frame))
@@ -10091,7 +9811,8 @@ XTread_socket (sd, expected, hold_quit)
10091 9811
10092 last_window=window; 9812 last_window=window;
10093 } 9813 }
10094 note_mouse_movement (f, &mouse_pos); 9814 if (!note_mouse_movement (f, &mouse_pos))
9815 help_echo_string = previous_help_echo_string;
10095 } 9816 }
10096 } 9817 }
10097 9818
diff --git a/src/macterm.h b/src/macterm.h
index ed645317990..ca6f82021fe 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -559,6 +559,8 @@ extern void XSetBackground P_ ((Display *, GC, unsigned long));
559extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long)); 559extern void XSetWindowBackground P_ ((Display *, WindowPtr, unsigned long));
560extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, 560extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
561 int, int)); 561 int, int));
562extern void mac_clear_area P_ ((struct frame *, int, int,
563 unsigned int, unsigned int));
562extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); 564extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
563extern OSErr install_window_handler P_ ((WindowPtr)); 565extern OSErr install_window_handler P_ ((WindowPtr));
564extern void remove_window_handler P_ ((WindowPtr)); 566extern void remove_window_handler P_ ((WindowPtr));
diff --git a/src/minibuf.c b/src/minibuf.c
index a84f37cad21..9c0f4a09284 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2357,7 +2357,7 @@ Return nil if there is no valid completion, else t. */)
2357} 2357}
2358 2358
2359DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list, 2359DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list,
2360 1, 1, 0, 2360 1, 2, 0,
2361 doc: /* Display the list of completions, COMPLETIONS, using `standard-output'. 2361 doc: /* Display the list of completions, COMPLETIONS, using `standard-output'.
2362Each element may be just a symbol or string 2362Each element may be just a symbol or string
2363or may be a list of two strings to be printed as if concatenated. 2363or may be a list of two strings to be printed as if concatenated.
@@ -2367,14 +2367,23 @@ alternative, the second serves as annotation.
2367The actual completion alternatives, as inserted, are given `mouse-face' 2367The actual completion alternatives, as inserted, are given `mouse-face'
2368properties of `highlight'. 2368properties of `highlight'.
2369At the end, this runs the normal hook `completion-setup-hook'. 2369At the end, this runs the normal hook `completion-setup-hook'.
2370It can find the completion buffer in `standard-output'. */) 2370It can find the completion buffer in `standard-output'.
2371 (completions) 2371The optional second arg COMMON-SUBSTRING is a string.
2372It is used to put faces, `completions-first-difference` and
2373`completions-common-part' on the completion bufffer. The
2374`completions-common-part' face is put on the common substring
2375specified by COMMON-SUBSTRING. If COMMON-SUBSTRING is nil,
2376the faces are not put.
2377Internally, COMMON-SUBSTRING is bound to `completion-common-substring'
2378during running `completion-setup-hook'. */)
2379 (completions, common_substring)
2372 Lisp_Object completions; 2380 Lisp_Object completions;
2381 Lisp_Object common_substring;
2373{ 2382{
2374 Lisp_Object tail, elt; 2383 Lisp_Object tail, elt;
2375 register int i; 2384 register int i;
2376 int column = 0; 2385 int column = 0;
2377 struct gcpro gcpro1, gcpro2; 2386 struct gcpro gcpro1, gcpro2, gcpro3;
2378 struct buffer *old = current_buffer; 2387 struct buffer *old = current_buffer;
2379 int first = 1; 2388 int first = 1;
2380 2389
@@ -2383,7 +2392,7 @@ It can find the completion buffer in `standard-output'. */)
2383 except for ELT. ELT can be pointing to a string 2392 except for ELT. ELT can be pointing to a string
2384 when terpri or Findent_to calls a change hook. */ 2393 when terpri or Findent_to calls a change hook. */
2385 elt = Qnil; 2394 elt = Qnil;
2386 GCPRO2 (completions, elt); 2395 GCPRO3 (completions, elt, common_substring);
2387 2396
2388 if (BUFFERP (Vstandard_output)) 2397 if (BUFFERP (Vstandard_output))
2389 set_buffer_internal (XBUFFER (Vstandard_output)); 2398 set_buffer_internal (XBUFFER (Vstandard_output));
@@ -2532,13 +2541,20 @@ It can find the completion buffer in `standard-output'. */)
2532 } 2541 }
2533 } 2542 }
2534 2543
2535 UNGCPRO;
2536
2537 if (BUFFERP (Vstandard_output)) 2544 if (BUFFERP (Vstandard_output))
2538 set_buffer_internal (old); 2545 set_buffer_internal (old);
2539 2546
2540 if (!NILP (Vrun_hooks)) 2547 if (!NILP (Vrun_hooks))
2541 call1 (Vrun_hooks, intern ("completion-setup-hook")); 2548 {
2549 int count1 = SPECPDL_INDEX ();
2550
2551 specbind (intern ("completion-common-substring"), common_substring);
2552 call1 (Vrun_hooks, intern ("completion-setup-hook"));
2553
2554 unbind_to (count1, Qnil);
2555 }
2556
2557 UNGCPRO;
2542 2558
2543 return Qnil; 2559 return Qnil;
2544} 2560}
diff --git a/src/search.c b/src/search.c
index aa7f6fda699..f60e6d0cfe2 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1175,9 +1175,9 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1175 unsigned char *patbuf; 1175 unsigned char *patbuf;
1176 int multibyte = !NILP (current_buffer->enable_multibyte_characters); 1176 int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1177 unsigned char *base_pat = SDATA (string); 1177 unsigned char *base_pat = SDATA (string);
1178 /* Set to nozero if we find a non-ASCII char that need 1178 /* Set to positive if we find a non-ASCII char that need
1179 translation. */ 1179 translation. Otherwise set to zero later. */
1180 int charset_base = 0; 1180 int charset_base = -1;
1181 int boyer_moore_ok = 1; 1181 int boyer_moore_ok = 1;
1182 1182
1183 /* MULTIBYTE says whether the text to be searched is multibyte. 1183 /* MULTIBYTE says whether the text to be searched is multibyte.
@@ -1275,24 +1275,30 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1275 always handle their translation. */ 1275 always handle their translation. */
1276 while (1) 1276 while (1)
1277 { 1277 {
1278 if (! ASCII_BYTE_P (inverse)) 1278 if (ASCII_BYTE_P (inverse))
1279 { 1279 {
1280 if (SINGLE_BYTE_CHAR_P (inverse)) 1280 if (charset_base > 0)
1281 {
1282 /* Boyer-moore search can't handle a
1283 translation of an eight-bit
1284 character. */
1285 boyer_moore_ok = 0;
1286 break;
1287 }
1288 else if (charset_base == 0)
1289 charset_base = inverse & ~CHAR_FIELD3_MASK;
1290 else if ((inverse & ~CHAR_FIELD3_MASK)
1291 != charset_base)
1292 { 1281 {
1293 boyer_moore_ok = 0; 1282 boyer_moore_ok = 0;
1294 break; 1283 break;
1295 } 1284 }
1285 charset_base = 0;
1286 }
1287 else if (SINGLE_BYTE_CHAR_P (inverse))
1288 {
1289 /* Boyer-moore search can't handle a
1290 translation of an eight-bit
1291 character. */
1292 boyer_moore_ok = 0;
1293 break;
1294 }
1295 else if (charset_base < 0)
1296 charset_base = inverse & ~CHAR_FIELD3_MASK;
1297 else if ((inverse & ~CHAR_FIELD3_MASK)
1298 != charset_base)
1299 {
1300 boyer_moore_ok = 0;
1301 break;
1296 } 1302 }
1297 if (c == inverse) 1303 if (c == inverse)
1298 break; 1304 break;
@@ -1300,6 +1306,8 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1300 } 1306 }
1301 } 1307 }
1302 } 1308 }
1309 if (charset_base < 0)
1310 charset_base = 0;
1303 1311
1304 /* Store this character into the translated pattern. */ 1312 /* Store this character into the translated pattern. */
1305 bcopy (str, pat, charlen); 1313 bcopy (str, pat, charlen);
diff --git a/src/w32term.c b/src/w32term.c
index 5f268867e8b..14b5d0ffb79 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -3204,7 +3204,7 @@ construct_drag_n_drop (result, msg, f)
3204static MSG last_mouse_motion_event; 3204static MSG last_mouse_motion_event;
3205static Lisp_Object last_mouse_motion_frame; 3205static Lisp_Object last_mouse_motion_frame;
3206 3206
3207static void 3207static int
3208note_mouse_movement (frame, msg) 3208note_mouse_movement (frame, msg)
3209 FRAME_PTR frame; 3209 FRAME_PTR frame;
3210 MSG *msg; 3210 MSG *msg;
@@ -3221,13 +3221,14 @@ note_mouse_movement (frame, msg)
3221 frame->mouse_moved = 1; 3221 frame->mouse_moved = 1;
3222 last_mouse_scroll_bar = Qnil; 3222 last_mouse_scroll_bar = Qnil;
3223 note_mouse_highlight (frame, -1, -1); 3223 note_mouse_highlight (frame, -1, -1);
3224 return 1;
3224 } 3225 }
3225 3226
3226 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3227 /* Has the mouse moved off the glyph it was on at the last sighting? */
3227 else if (mouse_x < last_mouse_glyph.left 3228 if (mouse_x < last_mouse_glyph.left
3228 || mouse_x >= last_mouse_glyph.right 3229 || mouse_x >= last_mouse_glyph.right
3229 || mouse_y < last_mouse_glyph.top 3230 || mouse_y < last_mouse_glyph.top
3230 || mouse_y >= last_mouse_glyph.bottom) 3231 || mouse_y >= last_mouse_glyph.bottom)
3231 { 3232 {
3232 frame->mouse_moved = 1; 3233 frame->mouse_moved = 1;
3233 last_mouse_scroll_bar = Qnil; 3234 last_mouse_scroll_bar = Qnil;
@@ -3237,7 +3238,10 @@ note_mouse_movement (frame, msg)
3237 to keep track of the mouse for help_echo and highlighting at 3238 to keep track of the mouse for help_echo and highlighting at
3238 other times. */ 3239 other times. */
3239 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph); 3240 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph);
3241 return 1;
3240 } 3242 }
3243
3244 return 0;
3241} 3245}
3242 3246
3243 3247
@@ -4314,6 +4318,7 @@ w32_read_socket (sd, expected, hold_quit)
4314 } 4318 }
4315 4319
4316 previous_help_echo_string = help_echo_string; 4320 previous_help_echo_string = help_echo_string;
4321 help_echo_string = Qnil;
4317 4322
4318 if (dpyinfo->grabbed && last_mouse_frame 4323 if (dpyinfo->grabbed && last_mouse_frame
4319 && FRAME_LIVE_P (last_mouse_frame)) 4324 && FRAME_LIVE_P (last_mouse_frame))
@@ -4352,7 +4357,8 @@ w32_read_socket (sd, expected, hold_quit)
4352 4357
4353 last_window=window; 4358 last_window=window;
4354 } 4359 }
4355 note_mouse_movement (f, &msg.msg); 4360 if (!note_mouse_movement (f, &msg.msg))
4361 help_echo_string = previous_help_echo_string;
4356 } 4362 }
4357 else 4363 else
4358 { 4364 {