aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2005-10-15 00:26:05 +0000
committerMiles Bader2005-10-15 00:26:05 +0000
commit9fe76e1b256aefe892edf84beb1fdfaf5ab0efa1 (patch)
tree4570b6861b88c36c99783d4103d49c8658027834 /src
parent2f0837ccf0ba386b9a9aab0eac2bad3076491a93 (diff)
parentd3a597b7b41c2ebdb457e7c8bb037958138028f2 (diff)
downloademacs-9fe76e1b256aefe892edf84beb1fdfaf5ab0efa1.tar.gz
emacs-9fe76e1b256aefe892edf84beb1fdfaf5ab0efa1.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-91
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 581-597) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 133-141) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: texi/gnus.texi (RSS): Fix key description. - Update from CVS: texi/gnus.texi (Document Server Internals): Addition.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog254
-rw-r--r--src/buffer.c12
-rw-r--r--src/dispextern.h24
-rw-r--r--src/dispnew.c49
-rw-r--r--src/emacs.c5
-rw-r--r--src/frame.c10
-rw-r--r--src/image.c153
-rw-r--r--src/keyboard.c64
-rw-r--r--src/macgui.h13
-rw-r--r--src/macterm.c919
-rw-r--r--src/macterm.h84
-rw-r--r--src/sysdep.c24
-rw-r--r--src/w32term.c140
-rw-r--r--src/window.c34
-rw-r--r--src/xdisp.c355
-rw-r--r--src/xfaces.c6
-rw-r--r--src/xfns.c2
-rw-r--r--src/xterm.c106
18 files changed, 1380 insertions, 874 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 172700a810b..3feb061a654 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,242 @@
12005-10-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * macterm.c (note_mouse_movement, XTread_socket): Apply 2005-10-14
4 changes for xterm.c.
5
6 * w32term.c (note_mouse_movement, w32_read_socket): Likewise.
7
82005-10-14 Kenichi Handa <handa@m17n.org>
9
10 * search.c (search_buffer): Give up BM search on case-fold-search
11 if one of a target character has a case-equivalence of different
12 charset even if that target charcter is an ASCII.
13
14 * casefiddle.c (casify_object): Fix for the case that case
15 conversion change the byte length.
16
172005-10-14 Kim F. Storm <storm@cua.dk>
18
19 * xterm.c (note_mouse_movement): Return 1 if mouse moved; 0 otherwise.
20 (handle_one_xevent): Only clear help_echo_string; restore it if
21 note_mouse_movement didn't record any mouse movement.
22
23 * xdisp.c (pos_visible_p): Convert w->hscroll to pixels before use.
24 (remember_mouse_glyph): Clear RECT if mouse is over an image glyph.
25
26 * keyboard.c (make_lispy_position): Adjust wx for left margin if ON_TEXT.
27 (Fposn_at_x_y): Fix calculation of x coordinate.
28 (Fposn_at_point): Return nil if point is hscrolled out of view.
29
302005-10-13 Andreas Schwab <schwab@suse.de>
31
32 * sysdep.c (request_sigio, unrequest_sigio): Do nothing in
33 non-interactive mode.
34
352005-10-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
36
37 * xterm.c, w32term.c, macterm.c (note_mouse_movement): Undo last change.
38
392005-10-12 Kim F. Storm <storm@cua.dk>
40
41 * xterm.c (handle_one_xevent): Clear last_mouse_glyph on mouse up/down.
42
432005-10-12 Romain Francoise <romain@orebokech.com>
44
45 * buffer.c (init_buffer): Rename `rc' to `len' for clarity.
46
472005-10-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
48
49 * xdisp.c (remember_mouse_glyph): Use MATRIX_BOTTOM_TEXT_ROW to
50 get end of text rows. Obtain header-line/mode-line rows directly.
51
52 * xterm.c, w32term.c, macterm.c (note_mouse_movement): Restore
53 help_echo_string if mouse is moved inside last_mouse_glyph.
54
552005-10-12 Kim F. Storm <storm@cua.dk>
56
57 * xdisp.c (remember_mouse_glyph): New generic version based on
58 glyph_rect and remember_mouse_glyph from xterm.c enhanced to
59 properly handle all different window areas.
60
61 * dispextern.h (remember_mouse_glyph): Add prototype.
62
63 * xterm.c (glyph_rect, remember_mouse_glyph): Remove X versions.
64 (note_mouse_movement, XTmouse_position): Use generic
65 remember_mouse_glyph, add last_mouse_glyph arg.
66
67 * w32term.c (note_mouse_movement): Fix last_mouse_glyph check.
68 (glyph_rect, remember_mouse_glyph): Remove w32 specific versions.
69 (note_mouse_movement, w32_mouse_position): Use generic
70 remember_mouse_glyph, add last_mouse_glyph arg.
71
72 * macterm.c (note_mouse_movement): Add call to remember_mouse_glyph.
73 (glyph_rect, remember_mouse_glyph): Remove mac specific versions.
74 (XTmouse_position): Adapt to use generic remember_mouse_glyph
75 instead of pixel_to_glyph_coords.
76
77 * window.c (coordinates_in_window): Fix x position for ON_RIGHT_MARGIN.
78 Fix x position for ON_TEXT when left margin width > 0.
79
802005-10-11 Kim F. Storm <storm@cua.dk>
81
82 * window.c (coordinates_in_window): Fix y position for ON_SCROLL_BAR.
83
84 * keyboard.c (make_lispy_position): Fix buffer calculations for
85 mouse click or movement in right fringe and the margins.
86
872005-10-11 Juanma Barranquero <lekktu@gmail.com>
88
89 * image.c (fn_jpeg_stdio_src): Don't define it.
90 (init_jpeg_functions): Don't initialize `fn_jpeg_stdio_src'.
91 (our_common_init_source): Rename from `our_init_source'.
92 (our_common_term_source): Rename from `our_term_source'.
93 (our_memory_fill_input_buffer): Rename from
94 `our_fill_input_buffer'.
95 (our_memory_skip_input_data): Rename from `our_skip_input_data'.
96 (jpeg_memory_src): Use the new names.
97 (struct jpeg_stdio_mgr): New struct.
98 (JPEG_STDIO_BUFFER_SIZE): New constant.
99 (our_stdio_fill_input_buffer, our_stdio_skip_input_data)
100 (jpeg_file_src): New functions.
101 (jpeg_load): Use `jpeg_file_src' instead of `fn_jpeg_stdio_src'.
102
1032005-10-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
104
105 * macterm.c (PER_CHAR_METRIC): Remove unused macro.
106 (fm_font_family_alist): New variable.
107 (syms_of_macterm): Initialize and staticpro it.
108 (decode_mac_font_name): Replace '-' in family name with '_' if it
109 occurs just once. Lower family name.
110 (parse_x_font_name): Rename from x_font_name_to_mac_font_name.
111 All uses changed. Remove argument MF and code conversion for it.
112 Add argument SIZE. Rename argument MF_DECODED to FAMILY, and CS
113 to CHARSET. Parse font size. Lower family name. Return integer
114 value for status of parsing.
115 (init_font_name_table) [USE_ATSUI]: Use decode_mac_font_name.
116 Don't use Fdowncase because family name is already lowered by
117 decode_mac_font_name.
118 (init_font_name_table): Always call decode_mac_font_name. Add
119 pair of family name and its reference to fm_font_family_alist.
120 (mac_clear_font_name_table): Clear fm_font_family_alist.
121 (XLoadQueryFont): Move font size parsing part to parse_x_font_name.
122 Lookup fm_font_family_alist to get font family reference.
123 (XLoadQueryFont) [USE_ATSUI]: Don't use Fdowncase because family
124 name is already lowered by parse_x_font_name.
125
1262005-10-11 Kim F. Storm <storm@cua.dk>
127
128 * xterm.c (glyph_rect): Return 0 if position is outside text area.
129
130 * keyboard.c (make_lispy_position): Fix buffer position calculation for
131 mouse click or movement in fringe.
132
1332005-10-10 Jason Rumney <jasonr@gnu.org>
134
135 * xterm.c (remember_mouse_glyph): New function.
136 (note_mouse_movement): Use it to remember the current glyph if changed.
137 (XTmouse_position): Fix calculation of fake glyph under mouse.
138 Move code to calculate glyph under mouse into remember_mouse_glyph.
139
1402005-10-10 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
141
142 * emacs.c (USAGE3, standard_args): -nb => -nbi.
143
1442005-10-10 Juanma Barranquero <lekktu@gmail.com>
145
146 * frame.c (Fredirect_frame_focus): Fix typos in docstring.
147 (next_frame, prev_frame, set_term_frame_name): Make static.
148
149 * window.c (Fwindow_tree): Fix spelling.
150
1512005-10-09 Romain Francoise <romain@orebokech.com>
152
153 * window.c (Fwindow_end): Don't try to redisplay if non-interactive.
154
1552005-10-09 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
156
157 * emacs.c (standard_args): Remove options -i, -itype, --icon-type.
158 Add options -nb, --no-bitmap-icon.
159
160 * xfns.c (Fx_create_frame): Make bitmapIcon have default on.
161
1622005-10-08 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
163
164 * macgui.h (MAX_CLIP_RECTS): New define.
165 (struct _XGC): New member clip_region.
166 (struct _XGC) [MAC_OSX && USE_ATSUI]: New members n_clip_rects and
167 clip_rects.
168
169 * macterm.c (GC_CLIP_REGION): New macro.
170 (saved_port_clip_region): New variable.
171 (mac_begin_clip, mac_end_clip): New functions.
172 (XDrawLine, mac_erase_rectangle, mac_draw_bitmap, XFillRectangle)
173 (mac_draw_rectangle, mac_draw_string_common, mac_copy_area)
174 (mac_copy_area_with_mask, mac_scroll_area): Use them.
175 (mac_set_clip_rectangle, mac_reset_clipping): Remove functions.
176 [USE_ATSUI] (atsu_get_text_layout_with_text_ptr)
177 [MAC_OS_X_VERSION_MAX_ALLOWED < 1020]: Specify kATSLineFractDisable.
178 (mac_draw_string_common) [MAC_OSX && USE_ATSUI]: Clip to clipping
179 rectangles stored in gc.
180 (XFreeGC): Dispose of clipping region.
181 (mac_set_clip_rectangles, mac_reset_clip_rectangles): New functions.
182 (x_draw_fringe_bitmap, x_set_glyph_string_clipping)
183 (x_draw_relief_rect, x_draw_box_rect, x_draw_stretch_glyph_string)
184 (x_draw_glyph_string, x_clip_to_row, x_draw_hollow_cursor)
185 (x_draw_bar_cursor): Use them.
186 (x_set_glyph_string_clipping): Use get_glyph_string_clip_rects to
187 get multiple clipping rectangles.
188
189 * macterm.h (mac_term_init): Add types to extern.
190 (struct mac_output): Remove members mWP and pending_menu_activation.
191 Put members scroll_bar_foreground_pixel and
192 scroll_bar_background_pixel in #if 0.
193 (FRAME_MAC_WINDOW, FRAME_X_WINDOW): Use window_desc.
194
195 * xfaces.c (x_create_gc, x_free_gc) [MAC_OS]: Add BLOCK_INPUT.
196 Add debug code.
197
1982005-10-08 Kim F. Storm <storm@cua.dk>
199
200 * window.c (window_tree, Fwindow_tree): Rename fns added 2005-10-04.
201
2022005-10-07 Kim F. Storm <storm@cua.dk>
203
204 * dispnew.c (redraw_overlapped_rows, redraw_overlapping_rows)
205 [!HAVE_WINDOW_SYSTEM]: Don't declare them...
206 (update_window) [!HAVE_WINDOW_SYSTEM]: ...and don't call them.
207
2082005-10-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
209
210 * dispextern.h (struct glyph_string): Rename member for_overlaps_p
211 to for_overlaps. Now occupy 3 bits.
212 (OVERLAPS_PRED, OVERLAPS_SUCC, OVERLAPS_BOTH)
213 (OVERLAPS_ERASED_CURSOR): New defines.
214 (struct redisplay_interface): Add new OVERLAPS arg to member
215 fix_overlapping_area.
216 (x_fix_overlapping_area): Add new OVERLAPS arg.
217 (get_glyph_string_clip_rects): Add extern.
218
219 * dispnew.c (redraw_overlapping_rows): Call
220 rif->fix_overlapping_area with new OVERLAPS arg as redrawn part.
221
222 * xdisp.c: Rename member for_overlaps_p in struct glyph_string to
223 for_overlaps.
224 (get_glyph_string_clip_rects): New function created from
225 get_glyph_string_clip_rect. Set clipping rectangles according to the
226 value of for_overlaps. Enable to store multiple clipping rectangles.
227 (get_glyph_string_clip_rect): Use get_glyph_string_clip_rects.
228 (fill_composite_glyph_string, fill_glyph_string, draw_glyphs):
229 Rename argument OVERLAPS_P to OVERLAPS. All uses in macros changed.
230 (x_fix_overlapping_area): Add OVERLAPS arg. Pass it to draw_glyphs.
231 (draw_phys_cursor_glyph): Set width of erased cursor to use it for
232 calculating clipping rectangles later. Call x_fix_overlapping_area
233 with new OVERLAPS arg to draw only erased cursor area.
234 (expose_overlaps): Call x_fix_overlapping_area with new OVERLAPS arg
235 to draw overlaps in both preceding and succeeding rows.
236
237 * xterm.c, w32term.c, macterm.c: Rename member for_overlaps_p in
238 struct glyph_string to for_overlaps.
239
12005-10-04 Kim F. Storm <storm@cua.dk> 2402005-10-04 Kim F. Storm <storm@cua.dk>
2 241
3 * window.c (window_split_tree): New function. 242 * window.c (window_split_tree): New function.
@@ -130,9 +369,9 @@
130 369
131 * systime.h (get_operating_system_release): ... here. 370 * systime.h (get_operating_system_release): ... here.
132 371
133 * xterm.c (set_vertical_scroll_bar): Move prototype ... 372 * xterm.c (handle_one_xevent): Refer to union field to match the
134 (handle_one_xevent): Refer to union field to match the type 373 type required by the function definition.
135 required by the function definition. 374 (set_vertical_scroll_bar): Move prototype ...
136 375
137 * xterm.h: ... here. 376 * xterm.h: ... here.
138 377
@@ -1483,7 +1722,7 @@
14832005-06-04 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 17222005-06-04 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
1484 1723
1485 * macmenu.c (cleanup_popup_menu): New function. 1724 * macmenu.c (cleanup_popup_menu): New function.
1486 (Fx_popup_menu): unwind protect cleanup_popup_menu in case 1725 (Fx_popup_menu): Unwind protect cleanup_popup_menu in case
1487 mac_menu_show Quit:s. 1726 mac_menu_show Quit:s.
1488 (mac_menu_show): Quit on cancel if not popped up on click (i.e. 1727 (mac_menu_show): Quit on cancel if not popped up on click (i.e.
1489 a dialog). 1728 a dialog).
@@ -3658,7 +3897,7 @@
3658 [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size 3897 [TARGET_API_MAC_CARBON] (Fx_file_dialog): Use MAXPATHLEN for size
3659 of filename string. Set event callback function when creating 3898 of filename string. Set event callback function when creating
3660 dialog boxes. Add code conversions for filenames. Don't dispose 3899 dialog boxes. Add code conversions for filenames. Don't dispose
3661 apple event descriptor record if failed to create it. 3900 of apple event descriptor record if failed to create it.
3662 3901
3663 * macterm.c: Include sys/param.h. 3902 * macterm.c: Include sys/param.h.
3664 [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for 3903 [USE_CARBON_EVENTS] (mac_handle_window_event): Add handler for
@@ -6760,7 +6999,8 @@
6760 (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a 6999 (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a
6761 scroll-bar click event. 7000 scroll-bar click event.
6762 (mac_define_frame_cursor): Change the pointer shape. 7001 (mac_define_frame_cursor): Change the pointer shape.
6763 (x_free_frame_resources): Reset tip_window to NULL when it is disposed. 7002 (x_free_frame_resources): Reset tip_window to NULL when it is
7003 disposed of.
6764 [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable. 7004 [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable.
6765 [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize arrow_cursor. 7005 [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize arrow_cursor.
6766 (do_window_update): Don't do anything if the updated window is the 7006 (do_window_update): Don't do anything if the updated window is the
@@ -16779,7 +17019,7 @@
16779 * w32.c (sys_getpeername, fcntl): New functions. 17019 * w32.c (sys_getpeername, fcntl): New functions.
16780 (_sys_read_ahead): Temporarily block on non-blocking sockets. 17020 (_sys_read_ahead): Temporarily block on non-blocking sockets.
16781 17021
16782 * w32proc.c: include sys/file.h. 17022 * w32proc.c: Include sys/file.h.
16783 17023
167842002-05-03 Colin Walters <walters@verbum.org> 170242002-05-03 Colin Walters <walters@verbum.org>
16785 17025
diff --git a/src/buffer.c b/src/buffer.c
index ae2a584e506..e8a45f42342 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5130,7 +5130,7 @@ init_buffer ()
5130 char *pwd; 5130 char *pwd;
5131 struct stat dotstat, pwdstat; 5131 struct stat dotstat, pwdstat;
5132 Lisp_Object temp; 5132 Lisp_Object temp;
5133 int rc; 5133 int len;
5134 5134
5135#ifdef USE_MMAP_FOR_BUFFERS 5135#ifdef USE_MMAP_FOR_BUFFERS
5136 { 5136 {
@@ -5157,13 +5157,13 @@ init_buffer ()
5157#ifndef VMS 5157#ifndef VMS
5158 /* Maybe this should really use some standard subroutine 5158 /* Maybe this should really use some standard subroutine
5159 whose definition is filename syntax dependent. */ 5159 whose definition is filename syntax dependent. */
5160 rc = strlen (pwd); 5160 len = strlen (pwd);
5161 if (!(IS_DIRECTORY_SEP (pwd[rc - 1]))) 5161 if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
5162 { 5162 {
5163 /* Grow buffer to add directory separator and '\0'. */ 5163 /* Grow buffer to add directory separator and '\0'. */
5164 pwd = (char *) xrealloc (pwd, rc + 2); 5164 pwd = (char *) xrealloc (pwd, len + 2);
5165 pwd[rc] = DIRECTORY_SEP; 5165 pwd[len] = DIRECTORY_SEP;
5166 pwd[rc + 1] = '\0'; 5166 pwd[len + 1] = '\0';
5167 } 5167 }
5168#endif /* not VMS */ 5168#endif /* not VMS */
5169 5169
diff --git a/src/dispextern.h b/src/dispextern.h
index db9cd53d042..b1f18e3ef25 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1182,10 +1182,18 @@ struct glyph_string
1182 stipple pattern. */ 1182 stipple pattern. */
1183 unsigned stippled_p : 1; 1183 unsigned stippled_p : 1;
1184 1184
1185 /* 1 means only the foreground of this glyph string must be drawn, 1185#define OVERLAPS_PRED (1 << 0)
1186 and we should use the physical height of the line this glyph 1186#define OVERLAPS_SUCC (1 << 1)
1187 string appears in as clip rect. */ 1187#define OVERLAPS_BOTH (OVERLAPS_PRED | OVERLAPS_SUCC)
1188 unsigned for_overlaps_p : 1; 1188#define OVERLAPS_ERASED_CURSOR (1 << 2)
1189 /* Non-zero means only the foreground of this glyph string must be
1190 drawn, and we should use the physical height of the line this
1191 glyph string appears in as clip rect. If the value is
1192 OVERLAPS_ERASED_CURSOR, the clip rect is restricted to the rect
1193 of the erased cursor. OVERLAPS_PRED and OVERLAPS_SUCC mean we
1194 draw overlaps with the preceding and the succeeding rows,
1195 respectively. */
1196 unsigned for_overlaps : 3;
1189 1197
1190 /* The GC to use for drawing this glyph string. */ 1198 /* The GC to use for drawing this glyph string. */
1191#if defined(HAVE_X_WINDOWS) || defined(MAC_OS) 1199#if defined(HAVE_X_WINDOWS) || defined(MAC_OS)
@@ -2260,7 +2268,7 @@ struct redisplay_interface
2260 This function is called from redraw_overlapping_rows after 2268 This function is called from redraw_overlapping_rows after
2261 desired rows have been made current. */ 2269 desired rows have been made current. */
2262 void (*fix_overlapping_area) P_ ((struct window *w, struct glyph_row *row, 2270 void (*fix_overlapping_area) P_ ((struct window *w, struct glyph_row *row,
2263 enum glyph_row_area area)); 2271 enum glyph_row_area area, int));
2264 2272
2265#ifdef HAVE_WINDOW_SYSTEM 2273#ifdef HAVE_WINDOW_SYSTEM
2266 2274
@@ -2603,6 +2611,8 @@ int estimate_mode_line_height P_ ((struct frame *, enum face_id));
2603void pixel_to_glyph_coords P_ ((struct frame *, int, int, int *, int *, 2611void pixel_to_glyph_coords P_ ((struct frame *, int, int, int *, int *,
2604 NativeRectangle *, int)); 2612 NativeRectangle *, int));
2605int glyph_to_pixel_coords P_ ((struct window *, int, int, int *, int *)); 2613int glyph_to_pixel_coords P_ ((struct window *, int, int, int *, int *));
2614void remember_mouse_glyph P_ ((struct frame *, int, int, NativeRectangle *));
2615
2606void mark_window_display_accurate P_ ((Lisp_Object, int)); 2616void mark_window_display_accurate P_ ((Lisp_Object, int));
2607void redisplay_preserve_echo_area P_ ((int)); 2617void redisplay_preserve_echo_area P_ ((int));
2608void set_cursor_from_row P_ ((struct window *, struct glyph_row *, 2618void set_cursor_from_row P_ ((struct window *, struct glyph_row *,
@@ -2660,7 +2670,7 @@ extern int x_stretch_cursor_p;
2660extern struct cursor_pos output_cursor; 2670extern struct cursor_pos output_cursor;
2661 2671
2662extern void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *, 2672extern void x_fix_overlapping_area P_ ((struct window *, struct glyph_row *,
2663 enum glyph_row_area)); 2673 enum glyph_row_area, int));
2664extern void draw_phys_cursor_glyph P_ ((struct window *, 2674extern void draw_phys_cursor_glyph P_ ((struct window *,
2665 struct glyph_row *, 2675 struct glyph_row *,
2666 enum draw_glyphs_face)); 2676 enum draw_glyphs_face));
@@ -2678,6 +2688,8 @@ extern void x_clear_cursor P_ ((struct window *));
2678extern void x_draw_vertical_border P_ ((struct window *w)); 2688extern void x_draw_vertical_border P_ ((struct window *w));
2679 2689
2680extern void frame_to_window_pixel_xy P_ ((struct window *, int *, int *)); 2690extern void frame_to_window_pixel_xy P_ ((struct window *, int *, int *));
2691extern int get_glyph_string_clip_rects P_ ((struct glyph_string *,
2692 NativeRectangle *, int));
2681extern void get_glyph_string_clip_rect P_ ((struct glyph_string *, 2693extern void get_glyph_string_clip_rect P_ ((struct glyph_string *,
2682 NativeRectangle *nr)); 2694 NativeRectangle *nr));
2683extern Lisp_Object find_hot_spot P_ ((Lisp_Object, int, int)); 2695extern Lisp_Object find_hot_spot P_ ((Lisp_Object, int, int));
diff --git a/src/dispnew.c b/src/dispnew.c
index b001db82781..d0a1ba6c7ff 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3949,6 +3949,7 @@ update_single_window (w, force_p)
3949 } 3949 }
3950} 3950}
3951 3951
3952#ifdef HAVE_WINDOW_SYSTEM
3952 3953
3953/* Redraw lines from the current matrix of window W that are 3954/* Redraw lines from the current matrix of window W that are
3954 overlapped by other rows. YB is bottom-most y-position in W. */ 3955 overlapped by other rows. YB is bottom-most y-position in W. */
@@ -4021,23 +4022,33 @@ redraw_overlapping_rows (w, yb)
4021 4022
4022 if (row->overlapping_p && i > 0 && bottom_y < yb) 4023 if (row->overlapping_p && i > 0 && bottom_y < yb)
4023 { 4024 {
4024 if (row->used[LEFT_MARGIN_AREA]) 4025 int overlaps = 0;
4025 rif->fix_overlapping_area (w, row, LEFT_MARGIN_AREA); 4026
4026 4027 if (MATRIX_ROW_OVERLAPS_PRED_P (row)
4027 if (row->used[TEXT_AREA]) 4028 && !MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p)
4028 rif->fix_overlapping_area (w, row, TEXT_AREA); 4029 overlaps |= OVERLAPS_PRED;
4029 4030 if (MATRIX_ROW_OVERLAPS_SUCC_P (row)
4030 if (row->used[RIGHT_MARGIN_AREA]) 4031 && !MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p)
4031 rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA); 4032 overlaps |= OVERLAPS_SUCC;
4032 4033
4033 /* Record in neighbour rows that ROW overwrites part of their 4034 if (overlaps)
4034 display. */ 4035 {
4035 if (row->phys_ascent > row->ascent && i > 0) 4036 if (row->used[LEFT_MARGIN_AREA])
4036 MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1; 4037 rif->fix_overlapping_area (w, row, LEFT_MARGIN_AREA, overlaps);
4037 if ((row->phys_height - row->phys_ascent 4038
4038 > row->height - row->ascent) 4039 if (row->used[TEXT_AREA])
4039 && bottom_y < yb) 4040 rif->fix_overlapping_area (w, row, TEXT_AREA, overlaps);
4040 MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p = 1; 4041
4042 if (row->used[RIGHT_MARGIN_AREA])
4043 rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, overlaps);
4044
4045 /* Record in neighbour rows that ROW overwrites part of
4046 their display. */
4047 if (overlaps & OVERLAPS_PRED)
4048 MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1;
4049 if (overlaps & OVERLAPS_SUCC)
4050 MATRIX_ROW (w->current_matrix, i + 1)->overlapped_p = 1;
4051 }
4041 } 4052 }
4042 4053
4043 if (bottom_y >= yb) 4054 if (bottom_y >= yb)
@@ -4045,6 +4056,8 @@ redraw_overlapping_rows (w, yb)
4045 } 4056 }
4046} 4057}
4047 4058
4059#endif /* HAVE_WINDOW_SYSTEM */
4060
4048 4061
4049#ifdef GLYPH_DEBUG 4062#ifdef GLYPH_DEBUG
4050 4063
@@ -4205,11 +4218,13 @@ update_window (w, force_p)
4205 /* Fix the appearance of overlapping/overlapped rows. */ 4218 /* Fix the appearance of overlapping/overlapped rows. */
4206 if (!paused_p && !w->pseudo_window_p) 4219 if (!paused_p && !w->pseudo_window_p)
4207 { 4220 {
4221#ifdef HAVE_WINDOW_SYSTEM
4208 if (changed_p && rif->fix_overlapping_area) 4222 if (changed_p && rif->fix_overlapping_area)
4209 { 4223 {
4210 redraw_overlapped_rows (w, yb); 4224 redraw_overlapped_rows (w, yb);
4211 redraw_overlapping_rows (w, yb); 4225 redraw_overlapping_rows (w, yb);
4212 } 4226 }
4227#endif
4213 4228
4214 /* Make cursor visible at cursor position of W. */ 4229 /* Make cursor visible at cursor position of W. */
4215 set_window_cursor_after_update (w); 4230 set_window_cursor_after_update (w);
diff --git a/src/emacs.c b/src/emacs.c
index a4416354c12..0149bec6d5e 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -311,7 +311,7 @@ Display options:\n\
311--fullscreen, -fs make first frame fullscreen\n\ 311--fullscreen, -fs make first frame fullscreen\n\
312--fullwidth, -fw make the first frame wide as the screen\n\ 312--fullwidth, -fw make the first frame wide as the screen\n\
313--geometry, -g GEOMETRY window geometry\n\ 313--geometry, -g GEOMETRY window geometry\n\
314--icon-type, -i use picture of gnu for Emacs icon\n\ 314--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
315--iconic start Emacs in iconified state\n\ 315--iconic start Emacs in iconified state\n\
316--internal-border, -ib WIDTH width between text and main border\n\ 316--internal-border, -ib WIDTH width between text and main border\n\
317--line-spacing, -lsp PIXELS additional space to put between lines\n\ 317--line-spacing, -lsp PIXELS additional space to put between lines\n\
@@ -1836,8 +1836,7 @@ struct standard_args standard_args[] =
1836 { "-u", "--user", 30, 1 }, 1836 { "-u", "--user", 30, 1 },
1837 { "-user", 0, 30, 1 }, 1837 { "-user", 0, 30, 1 },
1838 { "-debug-init", "--debug-init", 20, 0 }, 1838 { "-debug-init", "--debug-init", 20, 0 },
1839 { "-i", "--icon-type", 15, 0 }, 1839 { "-nbi", "--no-bitmap-icon", 15, 0 },
1840 { "-itype", 0, 15, 0 },
1841 { "-iconic", "--iconic", 15, 0 }, 1840 { "-iconic", "--iconic", 15, 0 },
1842 { "-D", "--basic-display", 12, 0}, 1841 { "-D", "--basic-display", 12, 0},
1843 { "-basic-display", 0, 12, 0}, 1842 { "-basic-display", 0, 12, 0},
diff --git a/src/frame.c b/src/frame.c
index 9c6345a0b40..ae7ac842fa2 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -901,7 +901,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
901 If MINIBUF is 0, include all visible and iconified frames. 901 If MINIBUF is 0, include all visible and iconified frames.
902 Otherwise, include all frames. */ 902 Otherwise, include all frames. */
903 903
904Lisp_Object 904static Lisp_Object
905next_frame (frame, minibuf) 905next_frame (frame, minibuf)
906 Lisp_Object frame; 906 Lisp_Object frame;
907 Lisp_Object minibuf; 907 Lisp_Object minibuf;
@@ -978,7 +978,7 @@ next_frame (frame, minibuf)
978 If MINIBUF is 0, include all visible and iconified frames. 978 If MINIBUF is 0, include all visible and iconified frames.
979 Otherwise, include all frames. */ 979 Otherwise, include all frames. */
980 980
981Lisp_Object 981static Lisp_Object
982prev_frame (frame, minibuf) 982prev_frame (frame, minibuf)
983 Lisp_Object frame; 983 Lisp_Object frame;
984 Lisp_Object minibuf; 984 Lisp_Object minibuf;
@@ -1813,7 +1813,7 @@ Focus redirection is useful for temporarily redirecting keystrokes to
1813a surrogate minibuffer frame when a frame doesn't have its own 1813a surrogate minibuffer frame when a frame doesn't have its own
1814minibuffer window. 1814minibuffer window.
1815 1815
1816A frame's focus redirection can be changed by select-frame. If frame 1816A frame's focus redirection can be changed by `select-frame'. If frame
1817FOO is selected, and then a different frame BAR is selected, any 1817FOO is selected, and then a different frame BAR is selected, any
1818frames redirecting their focus to FOO are shifted to redirect their 1818frames redirecting their focus to FOO are shifted to redirect their
1819focus to BAR. This allows focus redirection to work properly when the 1819focus to BAR. This allows focus redirection to work properly when the
@@ -1821,7 +1821,7 @@ user switches from one frame to another using `select-window'.
1821 1821
1822This means that a frame whose focus is redirected to itself is treated 1822This means that a frame whose focus is redirected to itself is treated
1823differently from a frame whose focus is redirected to nil; the former 1823differently from a frame whose focus is redirected to nil; the former
1824is affected by select-frame, while the latter is not. 1824is affected by `select-frame', while the latter is not.
1825 1825
1826The redirection lasts until `redirect-frame-focus' is called to change it. */) 1826The redirection lasts until `redirect-frame-focus' is called to change it. */)
1827 (frame, focus_frame) 1827 (frame, focus_frame)
@@ -1952,7 +1952,7 @@ frame_name_fnn_p (str, len)
1952/* Set the name of the terminal frame. Also used by MSDOS frames. 1952/* Set the name of the terminal frame. Also used by MSDOS frames.
1953 Modeled after x_set_name which is used for WINDOW frames. */ 1953 Modeled after x_set_name which is used for WINDOW frames. */
1954 1954
1955void 1955static void
1956set_term_frame_name (f, name) 1956set_term_frame_name (f, name)
1957 struct frame *f; 1957 struct frame *f;
1958 Lisp_Object name; 1958 Lisp_Object name;
diff --git a/src/image.c b/src/image.c
index 3b6969b0c28..2463c24a33a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6358,7 +6358,6 @@ DEF_IMGLIB_FN (jpeg_finish_decompress);
6358DEF_IMGLIB_FN (jpeg_destroy_decompress); 6358DEF_IMGLIB_FN (jpeg_destroy_decompress);
6359DEF_IMGLIB_FN (jpeg_read_header); 6359DEF_IMGLIB_FN (jpeg_read_header);
6360DEF_IMGLIB_FN (jpeg_read_scanlines); 6360DEF_IMGLIB_FN (jpeg_read_scanlines);
6361DEF_IMGLIB_FN (jpeg_stdio_src);
6362DEF_IMGLIB_FN (jpeg_std_error); 6361DEF_IMGLIB_FN (jpeg_std_error);
6363DEF_IMGLIB_FN (jpeg_resync_to_restart); 6362DEF_IMGLIB_FN (jpeg_resync_to_restart);
6364 6363
@@ -6374,7 +6373,6 @@ init_jpeg_functions (Lisp_Object libraries)
6374 LOAD_IMGLIB_FN (library, jpeg_read_scanlines); 6373 LOAD_IMGLIB_FN (library, jpeg_read_scanlines);
6375 LOAD_IMGLIB_FN (library, jpeg_start_decompress); 6374 LOAD_IMGLIB_FN (library, jpeg_start_decompress);
6376 LOAD_IMGLIB_FN (library, jpeg_read_header); 6375 LOAD_IMGLIB_FN (library, jpeg_read_header);
6377 LOAD_IMGLIB_FN (library, jpeg_stdio_src);
6378 LOAD_IMGLIB_FN (library, jpeg_CreateDecompress); 6376 LOAD_IMGLIB_FN (library, jpeg_CreateDecompress);
6379 LOAD_IMGLIB_FN (library, jpeg_destroy_decompress); 6377 LOAD_IMGLIB_FN (library, jpeg_destroy_decompress);
6380 LOAD_IMGLIB_FN (library, jpeg_std_error); 6378 LOAD_IMGLIB_FN (library, jpeg_std_error);
@@ -6400,7 +6398,6 @@ jpeg_resync_to_restart_wrapper(cinfo, desired)
6400#define fn_jpeg_destroy_decompress jpeg_destroy_decompress 6398#define fn_jpeg_destroy_decompress jpeg_destroy_decompress
6401#define fn_jpeg_read_header jpeg_read_header 6399#define fn_jpeg_read_header jpeg_read_header
6402#define fn_jpeg_read_scanlines jpeg_read_scanlines 6400#define fn_jpeg_read_scanlines jpeg_read_scanlines
6403#define fn_jpeg_stdio_src jpeg_stdio_src
6404#define fn_jpeg_std_error jpeg_std_error 6401#define fn_jpeg_std_error jpeg_std_error
6405#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart 6402#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart
6406 6403
@@ -6427,7 +6424,17 @@ my_error_exit (cinfo)
6427 libjpeg.doc from the JPEG lib distribution. */ 6424 libjpeg.doc from the JPEG lib distribution. */
6428 6425
6429static void 6426static void
6430our_init_source (cinfo) 6427our_common_init_source (cinfo)
6428 j_decompress_ptr cinfo;
6429{
6430}
6431
6432
6433/* Method to terminate data source. Called by
6434 jpeg_finish_decompress() after all data has been processed. */
6435
6436static void
6437our_common_term_source (cinfo)
6431 j_decompress_ptr cinfo; 6438 j_decompress_ptr cinfo;
6432{ 6439{
6433} 6440}
@@ -6438,7 +6445,7 @@ our_init_source (cinfo)
6438 so this only adds a fake end of input marker at the end. */ 6445 so this only adds a fake end of input marker at the end. */
6439 6446
6440static boolean 6447static boolean
6441our_fill_input_buffer (cinfo) 6448our_memory_fill_input_buffer (cinfo)
6442 j_decompress_ptr cinfo; 6449 j_decompress_ptr cinfo;
6443{ 6450{
6444 /* Insert a fake EOI marker. */ 6451 /* Insert a fake EOI marker. */
@@ -6458,7 +6465,7 @@ our_fill_input_buffer (cinfo)
6458 is the JPEG data source manager. */ 6465 is the JPEG data source manager. */
6459 6466
6460static void 6467static void
6461our_skip_input_data (cinfo, num_bytes) 6468our_memory_skip_input_data (cinfo, num_bytes)
6462 j_decompress_ptr cinfo; 6469 j_decompress_ptr cinfo;
6463 long num_bytes; 6470 long num_bytes;
6464{ 6471{
@@ -6475,16 +6482,6 @@ our_skip_input_data (cinfo, num_bytes)
6475} 6482}
6476 6483
6477 6484
6478/* Method to terminate data source. Called by
6479 jpeg_finish_decompress() after all data has been processed. */
6480
6481static void
6482our_term_source (cinfo)
6483 j_decompress_ptr cinfo;
6484{
6485}
6486
6487
6488/* Set up the JPEG lib for reading an image from DATA which contains 6485/* Set up the JPEG lib for reading an image from DATA which contains
6489 LEN bytes. CINFO is the decompression info structure created for 6486 LEN bytes. CINFO is the decompression info structure created for
6490 reading the image. */ 6487 reading the image. */
@@ -6508,16 +6505,130 @@ jpeg_memory_src (cinfo, data, len)
6508 } 6505 }
6509 6506
6510 src = (struct jpeg_source_mgr *) cinfo->src; 6507 src = (struct jpeg_source_mgr *) cinfo->src;
6511 src->init_source = our_init_source; 6508 src->init_source = our_common_init_source;
6512 src->fill_input_buffer = our_fill_input_buffer; 6509 src->fill_input_buffer = our_memory_fill_input_buffer;
6513 src->skip_input_data = our_skip_input_data; 6510 src->skip_input_data = our_memory_skip_input_data;
6514 src->resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ 6511 src->resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */
6515 src->term_source = our_term_source; 6512 src->term_source = our_common_term_source;
6516 src->bytes_in_buffer = len; 6513 src->bytes_in_buffer = len;
6517 src->next_input_byte = data; 6514 src->next_input_byte = data;
6518} 6515}
6519 6516
6520 6517
6518struct jpeg_stdio_mgr
6519{
6520 struct jpeg_source_mgr mgr;
6521 boolean finished;
6522 FILE *file;
6523 JOCTET *buffer;
6524};
6525
6526
6527/* Size of buffer to read JPEG from file.
6528 Not too big, as we want to use alloc_small. */
6529#define JPEG_STDIO_BUFFER_SIZE 8192
6530
6531
6532/* Fill input buffer method for JPEG data source manager. Called
6533 whenever more data is needed. The data is read from a FILE *. */
6534
6535static boolean
6536our_stdio_fill_input_buffer (cinfo)
6537 j_decompress_ptr cinfo;
6538{
6539 struct jpeg_stdio_mgr *src;
6540
6541 src = (struct jpeg_stdio_mgr *) cinfo->src;
6542 if (!src->finished)
6543 {
6544 size_t bytes;
6545
6546 bytes = fread (src->buffer, 1, JPEG_STDIO_BUFFER_SIZE, src->file);
6547 if (bytes > 0)
6548 src->mgr.bytes_in_buffer = bytes;
6549 else
6550 {
6551 WARNMS (cinfo, JWRN_JPEG_EOF);
6552 src->finished = 1;
6553 src->buffer[0] = (JOCTET) 0xFF;
6554 src->buffer[1] = (JOCTET) JPEG_EOI;
6555 src->mgr.bytes_in_buffer = 2;
6556 }
6557 src->mgr.next_input_byte = src->buffer;
6558 }
6559
6560 return 1;
6561}
6562
6563
6564/* Method to skip over NUM_BYTES bytes in the image data. CINFO->src
6565 is the JPEG data source manager. */
6566
6567static void
6568our_stdio_skip_input_data (cinfo, num_bytes)
6569 j_decompress_ptr cinfo;
6570 long num_bytes;
6571{
6572 struct jpeg_stdio_mgr *src;
6573 src = (struct jpeg_stdio_mgr *) cinfo->src;
6574
6575 while (num_bytes > 0 && !src->finished)
6576 {
6577 if (num_bytes <= src->mgr.bytes_in_buffer)
6578 {
6579 src->mgr.bytes_in_buffer -= num_bytes;
6580 src->mgr.next_input_byte += num_bytes;
6581 break;
6582 }
6583 else
6584 {
6585 num_bytes -= src->mgr.bytes_in_buffer;
6586 src->mgr.bytes_in_buffer = 0;
6587 src->mgr.next_input_byte = NULL;
6588
6589 our_stdio_fill_input_buffer (cinfo);
6590 }
6591 }
6592}
6593
6594
6595/* Set up the JPEG lib for reading an image from a FILE *.
6596 CINFO is the decompression info structure created for
6597 reading the image. */
6598
6599static void
6600jpeg_file_src (cinfo, fp)
6601 j_decompress_ptr cinfo;
6602 FILE *fp;
6603{
6604 struct jpeg_stdio_mgr *src;
6605
6606 if (cinfo->src != NULL)
6607 src = (struct jpeg_stdio_mgr *) cinfo->src;
6608 else
6609 {
6610 /* First time for this JPEG object? */
6611 cinfo->src = (struct jpeg_source_mgr *)
6612 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
6613 sizeof (struct jpeg_stdio_mgr));
6614 src = (struct jpeg_stdio_mgr *) cinfo->src;
6615 src->buffer = (JOCTET *)
6616 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
6617 JPEG_STDIO_BUFFER_SIZE);
6618 }
6619
6620 src->file = fp;
6621 src->finished = 0;
6622 src->mgr.init_source = our_common_init_source;
6623 src->mgr.fill_input_buffer = our_stdio_fill_input_buffer;
6624 src->mgr.skip_input_data = our_stdio_skip_input_data;
6625 src->mgr.resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */
6626 src->mgr.term_source = our_common_term_source;
6627 src->mgr.bytes_in_buffer = 0;
6628 src->mgr.next_input_byte = NULL;
6629}
6630
6631
6521/* Load image IMG for use on frame F. Patterned after example.c 6632/* Load image IMG for use on frame F. Patterned after example.c
6522 from the JPEG lib. */ 6633 from the JPEG lib. */
6523 6634
@@ -6601,7 +6712,7 @@ jpeg_load (f, img)
6601 fn_jpeg_CreateDecompress (&cinfo, JPEG_LIB_VERSION, sizeof (cinfo)); 6712 fn_jpeg_CreateDecompress (&cinfo, JPEG_LIB_VERSION, sizeof (cinfo));
6602 6713
6603 if (NILP (specified_data)) 6714 if (NILP (specified_data))
6604 fn_jpeg_stdio_src (&cinfo, (FILE *) fp); 6715 jpeg_file_src (&cinfo, (FILE *) fp);
6605 else 6716 else
6606 jpeg_memory_src (&cinfo, SDATA (specified_data), 6717 jpeg_memory_src (&cinfo, SDATA (specified_data),
6607 SBYTES (specified_data)); 6718 SBYTES (specified_data));
diff --git a/src/keyboard.c b/src/keyboard.c
index 97d4509eeb6..5467d5ff903 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5053,7 +5053,11 @@ make_lispy_position (f, x, y, time)
5053 XSETINT (*x, wx); 5053 XSETINT (*x, wx);
5054 XSETINT (*y, wy); 5054 XSETINT (*y, wy);
5055 5055
5056 if (part == ON_MODE_LINE || part == ON_HEADER_LINE) 5056 if (part == ON_TEXT)
5057 {
5058 wx += WINDOW_LEFT_MARGIN_WIDTH (w);
5059 }
5060 else if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
5057 { 5061 {
5058 /* Mode line or header line. Look for a string under 5062 /* Mode line or header line. Look for a string under
5059 the mouse that may have a `local-map' property. */ 5063 the mouse that may have a `local-map' property. */
@@ -5089,20 +5093,37 @@ make_lispy_position (f, x, y, time)
5089 &object, &dx, &dy, &width, &height); 5093 &object, &dx, &dy, &width, &height);
5090 if (STRINGP (string)) 5094 if (STRINGP (string))
5091 string_info = Fcons (string, make_number (charpos)); 5095 string_info = Fcons (string, make_number (charpos));
5096 if (part == ON_LEFT_MARGIN)
5097 wx = 0;
5098 else
5099 wx = window_box_right_offset (w, TEXT_AREA) - 1;
5092 } 5100 }
5093 else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE) 5101 else if (part == ON_LEFT_FRINGE)
5094 { 5102 {
5095 posn = (part == ON_LEFT_FRINGE) ? Qleft_fringe : Qright_fringe; 5103 posn = Qleft_fringe;
5096 rx = 0; 5104 rx = 0;
5097 dx = wx; 5105 dx = wx;
5098 if (part == ON_RIGHT_FRINGE) 5106 wx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
5099 dx -= (window_box_width (w, LEFT_MARGIN_AREA) 5107 ? 0
5100 + window_box_width (w, TEXT_AREA) 5108 : window_box_width (w, LEFT_MARGIN_AREA));
5101 + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w) 5109 dx -= wx;
5102 ? window_box_width (w, RIGHT_MARGIN_AREA) 5110 }
5103 : 0)); 5111 else if (part == ON_RIGHT_FRINGE)
5104 else if (!WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) 5112 {
5105 dx -= window_box_width (w, LEFT_MARGIN_AREA); 5113 posn = Qright_fringe;
5114 rx = 0;
5115 dx = wx;
5116 wx = (window_box_width (w, LEFT_MARGIN_AREA)
5117 + window_box_width (w, TEXT_AREA)
5118 + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
5119 ? window_box_width (w, RIGHT_MARGIN_AREA)
5120 : 0));
5121 dx -= wx;
5122 }
5123 else
5124 {
5125 /* Note: We have no special posn for part == ON_SCROLL_BAR. */
5126 wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx);
5106 } 5127 }
5107 5128
5108 if (textpos < 0) 5129 if (textpos < 0)
@@ -5111,7 +5132,6 @@ make_lispy_position (f, x, y, time)
5111 struct display_pos p; 5132 struct display_pos p;
5112 int dx2, dy2; 5133 int dx2, dy2;
5113 int width2, height2; 5134 int width2, height2;
5114 wx = max (WINDOW_LEFT_MARGIN_WIDTH (w), wx);
5115 string2 = buffer_posn_from_coords (w, &wx, &wy, &p, 5135 string2 = buffer_posn_from_coords (w, &wx, &wy, &p,
5116 &object2, &dx2, &dy2, 5136 &object2, &dx2, &dy2,
5117 &width2, &height2); 5137 &width2, &height2);
@@ -10574,11 +10594,11 @@ The `posn-' functions access elements of such lists. */)
10574 CHECK_LIVE_WINDOW (frame_or_window); 10594 CHECK_LIVE_WINDOW (frame_or_window);
10575 10595
10576 w = XWINDOW (frame_or_window); 10596 w = XWINDOW (frame_or_window);
10577 XSETINT (x, (WINDOW_TO_FRAME_PIXEL_X (w, XINT (x)) 10597 XSETINT (x, (XINT (x)
10598 + WINDOW_LEFT_EDGE_X (w)
10578 + (NILP (whole) 10599 + (NILP (whole)
10579 ? window_box_left_offset (w, TEXT_AREA) 10600 ? window_box_left_offset (w, TEXT_AREA)
10580 : - (WINDOW_LEFT_SCROLL_BAR_COLS (w) 10601 : 0)));
10581 * WINDOW_FRAME_COLUMN_WIDTH (w)))));
10582 XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y))); 10602 XSETINT (y, WINDOW_TO_FRAME_PIXEL_Y (w, XINT (y)));
10583 frame_or_window = w->frame; 10603 frame_or_window = w->frame;
10584 } 10604 }
@@ -10604,9 +10624,21 @@ The `posn-' functions access elements of such lists. */)
10604{ 10624{
10605 Lisp_Object tem; 10625 Lisp_Object tem;
10606 10626
10627 if (NILP (window))
10628 window = selected_window;
10629
10607 tem = Fpos_visible_in_window_p (pos, window, Qt); 10630 tem = Fpos_visible_in_window_p (pos, window, Qt);
10608 if (!NILP (tem)) 10631 if (!NILP (tem))
10609 tem = Fposn_at_x_y (XCAR (tem), XCAR (XCDR (tem)), window, Qnil); 10632 {
10633 Lisp_Object x = XCAR (tem);
10634 Lisp_Object y = XCAR (XCDR (tem));
10635
10636 /* Point invisible due to hscrolling? */
10637 if (XINT (x) < 0)
10638 return Qnil;
10639 tem = Fposn_at_x_y (x, y, window, Qnil);
10640 }
10641
10610 return tem; 10642 return tem;
10611} 10643}
10612 10644
diff --git a/src/macgui.h b/src/macgui.h
index 378dbcd9e5c..6e2adb092c6 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -192,6 +192,19 @@ typedef struct _XGC
192 192
193 /* QuickDraw background color. */ 193 /* QuickDraw background color. */
194 RGBColor back_color; 194 RGBColor back_color;
195
196#define MAX_CLIP_RECTS 2
197 /* QuickDraw clipping region. */
198 RgnHandle clip_region;
199
200#if defined (MAC_OSX) && USE_ATSUI
201 /* Number of clipping rectangles used in Quartz 2D drawing. */
202 int n_clip_rects;
203
204 /* Clipping rectangles used in Quartz 2D drawing. The y-coordinate
205 is in QuickDraw's. */
206 CGRect clip_rects[MAX_CLIP_RECTS];
207#endif
195} *GC; 208} *GC;
196 209
197#define GCForeground (1L<<2) 210#define GCForeground (1L<<2)
diff --git a/src/macterm.c b/src/macterm.c
index 8001678ab92..470851a3ffe 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -272,8 +272,38 @@ extern void menubar_selection_callback (FRAME_PTR, int);
272#define GC_FORE_COLOR(gc) (&(gc)->fore_color) 272#define GC_FORE_COLOR(gc) (&(gc)->fore_color)
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 MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc) 276#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc)
276 277
278static RgnHandle saved_port_clip_region = NULL;
279
280static void
281mac_begin_clip (region)
282 RgnHandle region;
283{
284 static RgnHandle new_region = NULL;
285
286 if (saved_port_clip_region == NULL)
287 saved_port_clip_region = NewRgn ();
288 if (new_region == NULL)
289 new_region = NewRgn ();
290
291 if (region)
292 {
293 GetClip (saved_port_clip_region);
294 SectRgn (saved_port_clip_region, region, new_region);
295 SetClip (new_region);
296 }
297}
298
299static void
300mac_end_clip (region)
301 RgnHandle region;
302{
303 if (region)
304 SetClip (saved_port_clip_region);
305}
306
277 307
278/* X display function emulation */ 308/* X display function emulation */
279 309
@@ -299,8 +329,10 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
299 329
300 RGBForeColor (GC_FORE_COLOR (gc)); 330 RGBForeColor (GC_FORE_COLOR (gc));
301 331
332 mac_begin_clip (GC_CLIP_REGION (gc));
302 MoveTo (x1, y1); 333 MoveTo (x1, y1);
303 LineTo (x2, y2); 334 LineTo (x2, y2);
335 mac_end_clip (GC_CLIP_REGION (gc));
304} 336}
305 337
306void 338void
@@ -341,7 +373,9 @@ mac_erase_rectangle (w, gc, x, y, width, height)
341 RGBBackColor (GC_BACK_COLOR (gc)); 373 RGBBackColor (GC_BACK_COLOR (gc));
342 SetRect (&r, x, y, x + width, y + height); 374 SetRect (&r, x, y, x + width, y + height);
343 375
376 mac_begin_clip (GC_CLIP_REGION (gc));
344 EraseRect (&r); 377 EraseRect (&r);
378 mac_end_clip (GC_CLIP_REGION (gc));
345 379
346 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 380 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
347} 381}
@@ -408,6 +442,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
408 RGBBackColor (GC_BACK_COLOR (gc)); 442 RGBBackColor (GC_BACK_COLOR (gc));
409 SetRect (&r, x, y, x + width, y + height); 443 SetRect (&r, x, y, x + width, y + height);
410 444
445 mac_begin_clip (GC_CLIP_REGION (gc));
411#if TARGET_API_MAC_CARBON 446#if TARGET_API_MAC_CARBON
412 LockPortBits (GetWindowPort (w)); 447 LockPortBits (GetWindowPort (w));
413 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)), 448 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)),
@@ -417,41 +452,12 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
417 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, 452 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
418 overlay_p ? srcOr : srcCopy, 0); 453 overlay_p ? srcOr : srcCopy, 0);
419#endif /* not TARGET_API_MAC_CARBON */ 454#endif /* not TARGET_API_MAC_CARBON */
455 mac_end_clip (GC_CLIP_REGION (gc));
420 456
421 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 457 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
422} 458}
423 459
424 460
425/* Mac replacement for XSetClipRectangles. */
426
427static void
428mac_set_clip_rectangle (display, w, r)
429 Display *display;
430 WindowPtr w;
431 Rect *r;
432{
433 SetPortWindowPort (w);
434
435 ClipRect (r);
436}
437
438
439/* Mac replacement for XSetClipMask. */
440
441static void
442mac_reset_clipping (display, w)
443 Display *display;
444 WindowPtr w;
445{
446 Rect r;
447
448 SetPortWindowPort (w);
449
450 SetRect (&r, -32767, -32767, 32767, 32767);
451 ClipRect (&r);
452}
453
454
455/* Mac replacement for XCreateBitmapFromBitmapData. */ 461/* Mac replacement for XCreateBitmapFromBitmapData. */
456 462
457static void 463static void
@@ -579,7 +585,9 @@ XFillRectangle (display, w, gc, x, y, width, height)
579 RGBForeColor (GC_FORE_COLOR (gc)); 585 RGBForeColor (GC_FORE_COLOR (gc));
580 SetRect (&r, x, y, x + width, y + height); 586 SetRect (&r, x, y, x + width, y + height);
581 587
588 mac_begin_clip (GC_CLIP_REGION (gc));
582 PaintRect (&r); /* using foreground color of gc */ 589 PaintRect (&r); /* using foreground color of gc */
590 mac_end_clip (GC_CLIP_REGION (gc));
583} 591}
584 592
585 593
@@ -627,7 +635,9 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
627 RGBForeColor (GC_FORE_COLOR (gc)); 635 RGBForeColor (GC_FORE_COLOR (gc));
628 SetRect (&r, x, y, x + width + 1, y + height + 1); 636 SetRect (&r, x, y, x + width + 1, y + height + 1);
629 637
638 mac_begin_clip (GC_CLIP_REGION (gc));
630 FrameRect (&r); /* using foreground color of gc */ 639 FrameRect (&r); /* using foreground color of gc */
640 mac_end_clip (GC_CLIP_REGION (gc));
631} 641}
632 642
633 643
@@ -680,7 +690,7 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
680#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 690#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
681 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics 691 kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics
682#else 692#else
683 kATSLineIsDisplayOnly 693 kATSLineIsDisplayOnly | kATSLineFractDisable
684#endif 694#endif
685 ; 695 ;
686 ATSUAttributeValuePtr values[] = {&line_layout}; 696 ATSUAttributeValuePtr values[] = {&line_layout};
@@ -784,10 +794,12 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
784 if (NILP (Vmac_use_core_graphics)) 794 if (NILP (Vmac_use_core_graphics))
785 { 795 {
786#endif 796#endif
797 mac_begin_clip (GC_CLIP_REGION (gc));
787 MoveTo (x, y); 798 MoveTo (x, y);
788 ATSUDrawText (text_layout, 799 ATSUDrawText (text_layout,
789 kATSUFromTextBeginning, kATSUToTextEnd, 800 kATSUFromTextBeginning, kATSUToTextEnd,
790 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc); 801 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
802 mac_end_clip (GC_CLIP_REGION (gc));
791#ifdef MAC_OSX 803#ifdef MAC_OSX
792 } 804 }
793 else 805 else
@@ -795,7 +807,6 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
795 CGrafPtr port; 807 CGrafPtr port;
796 CGContextRef context; 808 CGContextRef context;
797 Rect rect; 809 Rect rect;
798 RgnHandle region = NewRgn ();
799 float port_height; 810 float port_height;
800 ATSUAttributeTag tags[] = {kATSUCGContextTag}; 811 ATSUAttributeTag tags[] = {kATSUCGContextTag};
801 ByteCount sizes[] = {sizeof (CGContextRef)}; 812 ByteCount sizes[] = {sizeof (CGContextRef)};
@@ -805,16 +816,15 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
805 QDBeginCGContext (port, &context); 816 QDBeginCGContext (port, &context);
806 GetPortBounds (port, &rect); 817 GetPortBounds (port, &rect);
807 port_height = rect.bottom - rect.top; 818 port_height = rect.bottom - rect.top;
808 GetClip (region); 819 if (gc->n_clip_rects)
809 GetRegionBounds (region, &rect); 820 {
810 /* XXX: This is not correct if the clip region is not a 821 CGContextTranslateCTM (context, 0, port_height);
811 simple rectangle. */ 822 CGContextScaleCTM (context, 1, -1);
812 CGContextClipToRect (context, 823 CGContextClipToRects (context, gc->clip_rects,
813 CGRectMake (rect.left, 824 gc->n_clip_rects);
814 port_height - rect.bottom, 825 CGContextScaleCTM (context, 1, -1);
815 rect.right - rect.left, 826 CGContextTranslateCTM (context, 0, -port_height);
816 rect.bottom - rect.top)); 827 }
817 DisposeRgn (region);
818 CGContextSetRGBFillColor 828 CGContextSetRGBFillColor
819 (context, 829 (context,
820 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0, 830 RED_FROM_ULONG (gc->xgcv.foreground) / 255.0,
@@ -845,8 +855,10 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
845 TextFace (GC_FONT (gc)->mac_fontface); 855 TextFace (GC_FONT (gc)->mac_fontface);
846 TextMode (mode); 856 TextMode (mode);
847 857
858 mac_begin_clip (GC_CLIP_REGION (gc));
848 MoveTo (x, y); 859 MoveTo (x, y);
849 DrawText (buf, 0, nchars * bytes_per_char); 860 DrawText (buf, 0, nchars * bytes_per_char);
861 mac_end_clip (GC_CLIP_REGION (gc));
850#if USE_ATSUI 862#if USE_ATSUI
851 } 863 }
852#endif 864#endif
@@ -945,6 +957,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
945 ForeColor (blackColor); 957 ForeColor (blackColor);
946 BackColor (whiteColor); 958 BackColor (whiteColor);
947 959
960 mac_begin_clip (GC_CLIP_REGION (gc));
948 LockPixels (GetGWorldPixMap (src)); 961 LockPixels (GetGWorldPixMap (src));
949#if TARGET_API_MAC_CARBON 962#if TARGET_API_MAC_CARBON
950 LockPortBits (GetWindowPort (dest)); 963 LockPortBits (GetWindowPort (dest));
@@ -957,6 +970,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
957 &src_r, &dest_r, srcCopy, 0); 970 &src_r, &dest_r, srcCopy, 0);
958#endif /* not TARGET_API_MAC_CARBON */ 971#endif /* not TARGET_API_MAC_CARBON */
959 UnlockPixels (GetGWorldPixMap (src)); 972 UnlockPixels (GetGWorldPixMap (src));
973 mac_end_clip (GC_CLIP_REGION (gc));
960 974
961 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 975 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
962} 976}
@@ -983,6 +997,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
983 ForeColor (blackColor); 997 ForeColor (blackColor);
984 BackColor (whiteColor); 998 BackColor (whiteColor);
985 999
1000 mac_begin_clip (GC_CLIP_REGION (gc));
986 LockPixels (GetGWorldPixMap (src)); 1001 LockPixels (GetGWorldPixMap (src));
987 LockPixels (GetGWorldPixMap (mask)); 1002 LockPixels (GetGWorldPixMap (mask));
988#if TARGET_API_MAC_CARBON 1003#if TARGET_API_MAC_CARBON
@@ -997,6 +1012,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
997#endif /* not TARGET_API_MAC_CARBON */ 1012#endif /* not TARGET_API_MAC_CARBON */
998 UnlockPixels (GetGWorldPixMap (mask)); 1013 UnlockPixels (GetGWorldPixMap (mask));
999 UnlockPixels (GetGWorldPixMap (src)); 1014 UnlockPixels (GetGWorldPixMap (src));
1015 mac_end_clip (GC_CLIP_REGION (gc));
1000 1016
1001 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 1017 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
1002} 1018}
@@ -1033,7 +1049,9 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1033 color mapping in CopyBits. Otherwise, it will be slow. */ 1049 color mapping in CopyBits. Otherwise, it will be slow. */
1034 ForeColor (blackColor); 1050 ForeColor (blackColor);
1035 BackColor (whiteColor); 1051 BackColor (whiteColor);
1052 mac_begin_clip (GC_CLIP_REGION (gc));
1036 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 1053 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
1054 mac_end_clip (GC_CLIP_REGION (gc));
1037 1055
1038 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 1056 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
1039#endif /* not TARGET_API_MAC_CARBON */ 1057#endif /* not TARGET_API_MAC_CARBON */
@@ -1168,6 +1186,8 @@ XFreeGC (display, gc)
1168 Display *display; 1186 Display *display;
1169 GC gc; 1187 GC gc;
1170{ 1188{
1189 if (gc->clip_region)
1190 DisposeRgn (gc->clip_region);
1171 xfree (gc); 1191 xfree (gc);
1172} 1192}
1173 1193
@@ -1238,6 +1258,70 @@ XSetFont (display, gc, font)
1238} 1258}
1239 1259
1240 1260
1261/* Mac replacement for XSetClipRectangles. */
1262
1263static void
1264mac_set_clip_rectangles (display, gc, rectangles, n)
1265 Display *display;
1266 GC gc;
1267 Rect *rectangles;
1268 int n;
1269{
1270 int i;
1271
1272 if (n < 0 || n > MAX_CLIP_RECTS)
1273 abort ();
1274 if (n == 0)
1275 {
1276 if (gc->clip_region)
1277 {
1278 DisposeRgn (gc->clip_region);
1279 gc->clip_region = NULL;
1280 }
1281 }
1282 else
1283 {
1284 if (gc->clip_region == NULL)
1285 gc->clip_region = NewRgn ();
1286 RectRgn (gc->clip_region, rectangles);
1287 if (n > 1)
1288 {
1289 RgnHandle region = NewRgn ();
1290
1291 for (i = 1; i < n; i++)
1292 {
1293 RectRgn (region, rectangles + i);
1294 UnionRgn (gc->clip_region, region, gc->clip_region);
1295 }
1296 DisposeRgn (region);
1297 }
1298 }
1299#if defined (MAC_OSX) && USE_ATSUI
1300 gc->n_clip_rects = n;
1301
1302 for (i = 0; i < n; i++)
1303 {
1304 Rect *rect = rectangles + i;
1305
1306 gc->clip_rects[i] = CGRectMake (rect->left, rect->top,
1307 rect->right - rect->left,
1308 rect->bottom - rect->top);
1309 }
1310#endif
1311}
1312
1313
1314/* Mac replacement for XSetClipMask. */
1315
1316static INLINE void
1317mac_reset_clip_rectangles (display, gc)
1318 Display *display;
1319 GC gc;
1320{
1321 mac_set_clip_rectangles (display, gc, NULL, 0);
1322}
1323
1324
1241/* Mac replacement for XSetWindowBackground. */ 1325/* Mac replacement for XSetWindowBackground. */
1242 1326
1243void 1327void
@@ -1649,7 +1733,7 @@ x_draw_fringe_bitmap (w, row, p)
1649 XSetForeground (display, face->gc, gcv.foreground); 1733 XSetForeground (display, face->gc, gcv.foreground);
1650 } 1734 }
1651 1735
1652 mac_reset_clipping (display, window); 1736 mac_reset_clip_rectangles (display, gc);
1653} 1737}
1654 1738
1655 1739
@@ -1685,19 +1769,6 @@ static int mac_encode_char P_ ((int, XChar2b *, struct font_info *,
1685 struct charset *, int *)); 1769 struct charset *, int *));
1686 1770
1687 1771
1688/* Return a pointer to per-char metric information in FONT of a
1689 character pointed by B which is a pointer to an XChar2b. */
1690
1691#define PER_CHAR_METRIC(font, b) \
1692 ((font)->per_char \
1693 ? ((font)->per_char + (b)->byte2 - (font)->min_char_or_byte2 \
1694 + (((font)->min_byte1 || (font)->max_byte1) \
1695 ? (((b)->byte1 - (font)->min_byte1) \
1696 * ((font)->max_char_or_byte2 - (font)->min_char_or_byte2 + 1)) \
1697 : 0)) \
1698 : &((font)->max_bounds))
1699
1700
1701/* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B 1772/* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B
1702 is not contained in the font. */ 1773 is not contained in the font. */
1703 1774
@@ -2127,9 +2198,11 @@ static INLINE void
2127x_set_glyph_string_clipping (s) 2198x_set_glyph_string_clipping (s)
2128 struct glyph_string *s; 2199 struct glyph_string *s;
2129{ 2200{
2130 Rect r; 2201 Rect rects[MAX_CLIP_RECTS];
2131 get_glyph_string_clip_rect (s, &r); 2202 int n;
2132 mac_set_clip_rectangle (s->display, s->window, &r); 2203
2204 n = get_glyph_string_clip_rects (s, rects, MAX_CLIP_RECTS);
2205 mac_set_clip_rectangles (s->display, s->gc, rects, n);
2133} 2206}
2134 2207
2135 2208
@@ -2325,7 +2398,7 @@ x_draw_glyph_string_foreground (s)
2325 XDrawImageString is usually faster than XDrawString.) Always 2398 XDrawImageString is usually faster than XDrawString.) Always
2326 use XDrawImageString when drawing the cursor so that there is 2399 use XDrawImageString when drawing the cursor so that there is
2327 no chance that characters under a box cursor are invisible. */ 2400 no chance that characters under a box cursor are invisible. */
2328 if (s->for_overlaps_p 2401 if (s->for_overlaps
2329 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 2402 || (s->background_filled_p && s->hl != DRAW_CURSOR))
2330#endif 2403#endif
2331 { 2404 {
@@ -2346,7 +2419,7 @@ x_draw_glyph_string_foreground (s)
2346 { 2419 {
2347 if (s->two_byte_p) 2420 if (s->two_byte_p)
2348 XDrawImageString16 (s->display, s->window, s->gc, x, 2421 XDrawImageString16 (s->display, s->window, s->gc, x,
2349 s->ybase - boff, s->char2b, s->nchars); 2422 s->ybase - boff, s->char2b, s->nchars);
2350 else 2423 else
2351 XDrawImageString (s->display, s->window, s->gc, x, 2424 XDrawImageString (s->display, s->window, s->gc, x,
2352 s->ybase - boff, char1b, s->nchars); 2425 s->ybase - boff, char1b, s->nchars);
@@ -2754,7 +2827,7 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2754 gc = f->output_data.mac->white_relief.gc; 2827 gc = f->output_data.mac->white_relief.gc;
2755 else 2828 else
2756 gc = f->output_data.mac->black_relief.gc; 2829 gc = f->output_data.mac->black_relief.gc;
2757 mac_set_clip_rectangle (dpy, window, clip_rect); 2830 mac_set_clip_rectangles (dpy, gc, clip_rect, 1);
2758 2831
2759 /* Top. */ 2832 /* Top. */
2760 if (top_p) 2833 if (top_p)
@@ -2769,13 +2842,12 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2769 XDrawLine (dpy, window, gc, 2842 XDrawLine (dpy, window, gc,
2770 left_x + i, top_y + i, left_x + i, bottom_y - i); 2843 left_x + i, top_y + i, left_x + i, bottom_y - i);
2771 2844
2772 mac_reset_clipping (dpy, window); 2845 mac_reset_clip_rectangles (dpy, gc);
2773 if (raised_p) 2846 if (raised_p)
2774 gc = f->output_data.mac->black_relief.gc; 2847 gc = f->output_data.mac->black_relief.gc;
2775 else 2848 else
2776 gc = f->output_data.mac->white_relief.gc; 2849 gc = f->output_data.mac->white_relief.gc;
2777 mac_set_clip_rectangle (dpy, window, 2850 mac_set_clip_rectangles (dpy, gc, clip_rect, 1);
2778 clip_rect);
2779 2851
2780 /* Bottom. */ 2852 /* Bottom. */
2781 if (bot_p) 2853 if (bot_p)
@@ -2790,7 +2862,7 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2790 XDrawLine (dpy, window, gc, 2862 XDrawLine (dpy, window, gc,
2791 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); 2863 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
2792 2864
2793 mac_reset_clipping (dpy, window); 2865 mac_reset_clip_rectangles (dpy, gc);
2794} 2866}
2795 2867
2796 2868
@@ -2812,7 +2884,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2812 2884
2813 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 2885 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2814 XSetForeground (s->display, s->gc, s->face->box_color); 2886 XSetForeground (s->display, s->gc, s->face->box_color);
2815 mac_set_clip_rectangle (s->display, s->window, clip_rect); 2887 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1);
2816 2888
2817 /* Top. */ 2889 /* Top. */
2818 XFillRectangle (s->display, s->window, s->gc, 2890 XFillRectangle (s->display, s->window, s->gc,
@@ -2833,7 +2905,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2833 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2905 right_x - width + 1, top_y, width, bottom_y - top_y + 1);
2834 2906
2835 XSetForeground (s->display, s->gc, xgcv.foreground); 2907 XSetForeground (s->display, s->gc, xgcv.foreground);
2836 mac_reset_clipping (s->display, s->window); 2908 mac_reset_clip_rectangles (s->display, s->gc);
2837} 2909}
2838 2910
2839 2911
@@ -3187,7 +3259,6 @@ x_draw_image_glyph_string (s)
3187 x_set_glyph_string_clipping (s); 3259 x_set_glyph_string_clipping (s);
3188 mac_copy_area (s->display, pixmap, s->window, s->gc, 3260 mac_copy_area (s->display, pixmap, s->window, s->gc,
3189 0, 0, s->background_width, s->height, s->x, s->y); 3261 0, 0, s->background_width, s->height, s->x, s->y);
3190 mac_reset_clipping (s->display, s->window);
3191 XFreePixmap (s->display, pixmap); 3262 XFreePixmap (s->display, pixmap);
3192 } 3263 }
3193 else 3264 else
@@ -3239,7 +3310,7 @@ x_draw_stretch_glyph_string (s)
3239 gc = s->face->gc; 3310 gc = s->face->gc;
3240 3311
3241 get_glyph_string_clip_rect (s, &r); 3312 get_glyph_string_clip_rect (s, &r);
3242 mac_set_clip_rectangle (s->display, s->window, &r); 3313 mac_set_clip_rectangles (s->display, gc, &r, 1);
3243 3314
3244#if 0 /* MAC_TODO: stipple */ 3315#if 0 /* MAC_TODO: stipple */
3245 if (s->face->stipple) 3316 if (s->face->stipple)
@@ -3252,8 +3323,6 @@ x_draw_stretch_glyph_string (s)
3252 else 3323 else
3253#endif /* MAC_TODO */ 3324#endif /* MAC_TODO */
3254 mac_erase_rectangle (s->window, gc, x, y, w, h); 3325 mac_erase_rectangle (s->window, gc, x, y, w, h);
3255
3256 mac_reset_clipping (s->display, s->window);
3257 } 3326 }
3258 } 3327 }
3259 else if (!s->background_filled_p) 3328 else if (!s->background_filled_p)
@@ -3276,7 +3345,7 @@ x_draw_glyph_string (s)
3276 draw a cursor, draw the background of the successor first so that 3345 draw a cursor, draw the background of the successor first so that
3277 S can draw into it. This makes S->next use XDrawString instead 3346 S can draw into it. This makes S->next use XDrawString instead
3278 of XDrawImageString. */ 3347 of XDrawImageString. */
3279 if (s->next && s->right_overhang && !s->for_overlaps_p 3348 if (s->next && s->right_overhang && !s->for_overlaps
3280 && s->next->hl != DRAW_CURSOR) 3349 && s->next->hl != DRAW_CURSOR)
3281 { 3350 {
3282 xassert (s->next->img == NULL); 3351 xassert (s->next->img == NULL);
@@ -3290,7 +3359,7 @@ x_draw_glyph_string (s)
3290 3359
3291 /* Draw relief (if any) in advance for char/composition so that the 3360 /* Draw relief (if any) in advance for char/composition so that the
3292 glyph string can be drawn over it. */ 3361 glyph string can be drawn over it. */
3293 if (!s->for_overlaps_p 3362 if (!s->for_overlaps
3294 && s->face->box != FACE_NO_BOX 3363 && s->face->box != FACE_NO_BOX
3295 && (s->first_glyph->type == CHAR_GLYPH 3364 && (s->first_glyph->type == CHAR_GLYPH
3296 || s->first_glyph->type == COMPOSITE_GLYPH)) 3365 || s->first_glyph->type == COMPOSITE_GLYPH))
@@ -3316,7 +3385,7 @@ x_draw_glyph_string (s)
3316 break; 3385 break;
3317 3386
3318 case CHAR_GLYPH: 3387 case CHAR_GLYPH:
3319 if (s->for_overlaps_p) 3388 if (s->for_overlaps)
3320 s->background_filled_p = 1; 3389 s->background_filled_p = 1;
3321 else 3390 else
3322 x_draw_glyph_string_background (s, 0); 3391 x_draw_glyph_string_background (s, 0);
@@ -3324,7 +3393,7 @@ x_draw_glyph_string (s)
3324 break; 3393 break;
3325 3394
3326 case COMPOSITE_GLYPH: 3395 case COMPOSITE_GLYPH:
3327 if (s->for_overlaps_p || s->gidx > 0) 3396 if (s->for_overlaps || s->gidx > 0)
3328 s->background_filled_p = 1; 3397 s->background_filled_p = 1;
3329 else 3398 else
3330 x_draw_glyph_string_background (s, 1); 3399 x_draw_glyph_string_background (s, 1);
@@ -3335,7 +3404,7 @@ x_draw_glyph_string (s)
3335 abort (); 3404 abort ();
3336 } 3405 }
3337 3406
3338 if (!s->for_overlaps_p) 3407 if (!s->for_overlaps)
3339 { 3408 {
3340 /* Draw underline. */ 3409 /* Draw underline. */
3341 if (s->face->underline_p) 3410 if (s->face->underline_p)
@@ -3402,7 +3471,7 @@ x_draw_glyph_string (s)
3402 } 3471 }
3403 3472
3404 /* Reset clipping. */ 3473 /* Reset clipping. */
3405 mac_reset_clipping (s->display, s->window); 3474 mac_reset_clip_rectangles (s->display, s->gc);
3406} 3475}
3407 3476
3408/* Shift display to make room for inserted glyphs. */ 3477/* Shift display to make room for inserted glyphs. */
@@ -4085,7 +4154,7 @@ x_get_keysym_name (keysym)
4085static Point last_mouse_motion_position; 4154static Point last_mouse_motion_position;
4086static Lisp_Object last_mouse_motion_frame; 4155static Lisp_Object last_mouse_motion_frame;
4087 4156
4088static void 4157static int
4089note_mouse_movement (frame, pos) 4158note_mouse_movement (frame, pos)
4090 FRAME_PTR frame; 4159 FRAME_PTR frame;
4091 Point *pos; 4160 Point *pos;
@@ -4116,17 +4185,23 @@ note_mouse_movement (frame, pos)
4116 rif->define_frame_cursor (frame, 4185 rif->define_frame_cursor (frame,
4117 frame->output_data.mac->nontext_cursor); 4186 frame->output_data.mac->nontext_cursor);
4118 } 4187 }
4188 return 1;
4119 } 4189 }
4120 /* Has the mouse moved off the glyph it was on at the last sighting? */ 4190 /* Has the mouse moved off the glyph it was on at the last sighting? */
4121 else if (pos->h < last_mouse_glyph.left 4191 if (pos->h < last_mouse_glyph.left
4122 || pos->h >= last_mouse_glyph.right 4192 || pos->h >= last_mouse_glyph.right
4123 || pos->v < last_mouse_glyph.top 4193 || pos->v < last_mouse_glyph.top
4124 || pos->v >= last_mouse_glyph.bottom) 4194 || pos->v >= last_mouse_glyph.bottom)
4125 { 4195 {
4126 frame->mouse_moved = 1; 4196 frame->mouse_moved = 1;
4127 last_mouse_scroll_bar = Qnil; 4197 last_mouse_scroll_bar = Qnil;
4128 note_mouse_highlight (frame, pos->h, pos->v); 4198 note_mouse_highlight (frame, pos->h, pos->v);
4199 /* Remember which glyph we're now on. */
4200 remember_mouse_glyph (frame, pos->h, pos->v, &last_mouse_glyph);
4201 return 1;
4129 } 4202 }
4203
4204 return 0;
4130} 4205}
4131 4206
4132 4207
@@ -4134,9 +4209,6 @@ note_mouse_movement (frame, pos)
4134 Mouse Face 4209 Mouse Face
4135 ************************************************************************/ 4210 ************************************************************************/
4136 4211
4137static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
4138
4139
4140/* MAC TODO: This should be called from somewhere (or removed) ++KFS */ 4212/* MAC TODO: This should be called from somewhere (or removed) ++KFS */
4141 4213
4142static void 4214static void
@@ -4150,110 +4222,6 @@ redo_mouse_highlight ()
4150} 4222}
4151 4223
4152 4224
4153/* Try to determine frame pixel position and size of the glyph under
4154 frame pixel coordinates X/Y on frame F . Return the position and
4155 size in *RECT. Value is non-zero if we could compute these
4156 values. */
4157
4158static int
4159glyph_rect (f, x, y, rect)
4160 struct frame *f;
4161 int x, y;
4162 Rect *rect;
4163{
4164 Lisp_Object window;
4165
4166 window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
4167
4168 if (!NILP (window))
4169 {
4170 struct window *w = XWINDOW (window);
4171 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
4172 struct glyph_row *end = r + w->current_matrix->nrows - 1;
4173
4174 for (; r < end && r->enabled_p; ++r)
4175 if (r->y <= y && r->y + r->height > y)
4176 {
4177 /* Found the row at y. */
4178 struct glyph *g = r->glyphs[TEXT_AREA];
4179 struct glyph *end = g + r->used[TEXT_AREA];
4180 int gx;
4181
4182 rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
4183 rect->bottom = rect->top + r->height;
4184
4185 if (x < r->x)
4186 {
4187 /* x is to the left of the first glyph in the row. */
4188 /* Shouldn't this be a pixel value?
4189 WINDOW_LEFT_EDGE_X (w) seems to be the right value.
4190 ++KFS */
4191 rect->left = WINDOW_LEFT_EDGE_COL (w);
4192 rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
4193 return 1;
4194 }
4195
4196 for (gx = r->x; g < end; gx += g->pixel_width, ++g)
4197 if (gx <= x && gx + g->pixel_width > x)
4198 {
4199 /* x is on a glyph. */
4200 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
4201 rect->right = rect->left + g->pixel_width;
4202 return 1;
4203 }
4204
4205 /* x is to the right of the last glyph in the row. */
4206 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
4207 /* Shouldn't this be a pixel value?
4208 WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
4209 ++KFS */
4210 rect->right = WINDOW_RIGHT_EDGE_COL (w);
4211 return 1;
4212 }
4213 }
4214
4215 /* The y is not on any row. */
4216 return 0;
4217}
4218
4219/* MAC TODO: This should be called from somewhere (or removed) ++KFS */
4220
4221/* Record the position of the mouse in last_mouse_glyph. */
4222static void
4223remember_mouse_glyph (f1, gx, gy)
4224 struct frame * f1;
4225 int gx, gy;
4226{
4227 if (!glyph_rect (f1, gx, gy, &last_mouse_glyph))
4228 {
4229 int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
4230 int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
4231
4232 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
4233 round down even for negative values. */
4234 if (gx < 0)
4235 gx -= width - 1;
4236 if (gy < 0)
4237 gy -= height - 1;
4238#if 0
4239 /* This was the original code from XTmouse_position, but it seems
4240 to give the position of the glyph diagonally next to the one
4241 the mouse is over. */
4242 gx = (gx + width - 1) / width * width;
4243 gy = (gy + height - 1) / height * height;
4244#else
4245 gx = gx / width * width;
4246 gy = gy / height * height;
4247#endif
4248
4249 last_mouse_glyph.left = gx;
4250 last_mouse_glyph.top = gy;
4251 last_mouse_glyph.right = gx + width;
4252 last_mouse_glyph.bottom = gy + height;
4253 }
4254}
4255
4256
4257static struct frame * 4225static struct frame *
4258mac_focus_frame (dpyinfo) 4226mac_focus_frame (dpyinfo)
4259 struct mac_display_info *dpyinfo; 4227 struct mac_display_info *dpyinfo;
@@ -4269,18 +4237,18 @@ mac_focus_frame (dpyinfo)
4269 4237
4270 4238
4271/* Return the current position of the mouse. 4239/* Return the current position of the mouse.
4272 *fp should be a frame which indicates which display to ask about. 4240 *FP should be a frame which indicates which display to ask about.
4273 4241
4274 If the mouse movement started in a scroll bar, set *fp, *bar_window, 4242 If the mouse movement started in a scroll bar, set *FP, *BAR_WINDOW,
4275 and *part to the frame, window, and scroll bar part that the mouse 4243 and *PART to the frame, window, and scroll bar part that the mouse
4276 is over. Set *x and *y to the portion and whole of the mouse's 4244 is over. Set *X and *Y to the portion and whole of the mouse's
4277 position on the scroll bar. 4245 position on the scroll bar.
4278 4246
4279 If the mouse movement started elsewhere, set *fp to the frame the 4247 If the mouse movement started elsewhere, set *FP to the frame the
4280 mouse is on, *bar_window to nil, and *x and *y to the character cell 4248 mouse is on, *BAR_WINDOW to nil, and *X and *Y to the character cell
4281 the mouse is over. 4249 the mouse is over.
4282 4250
4283 Set *time to the server time-stamp for the time at which the mouse 4251 Set *TIME to the server time-stamp for the time at which the mouse
4284 was at this position. 4252 was at this position.
4285 4253
4286 Don't store anything if we don't have a valid set of values to report. 4254 Don't store anything if we don't have a valid set of values to report.
@@ -4297,11 +4265,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4297 Lisp_Object *x, *y; 4265 Lisp_Object *x, *y;
4298 unsigned long *time; 4266 unsigned long *time;
4299{ 4267{
4300 Point mouse_pos; 4268 FRAME_PTR f1;
4301 int ignore1, ignore2;
4302 struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
4303 WindowPtr wp = FRAME_MAC_WINDOW (f);
4304 Lisp_Object frame, tail;
4305 4269
4306 BLOCK_INPUT; 4270 BLOCK_INPUT;
4307 4271
@@ -4309,25 +4273,43 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4309 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); 4273 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
4310 else 4274 else
4311 { 4275 {
4276 Lisp_Object frame, tail;
4277
4312 /* Clear the mouse-moved flag for every frame on this display. */ 4278 /* Clear the mouse-moved flag for every frame on this display. */
4313 FOR_EACH_FRAME (tail, frame) 4279 FOR_EACH_FRAME (tail, frame)
4314 XFRAME (frame)->mouse_moved = 0; 4280 XFRAME (frame)->mouse_moved = 0;
4315 4281
4316 last_mouse_scroll_bar = Qnil; 4282 last_mouse_scroll_bar = Qnil;
4317 4283
4318 SetPortWindowPort (wp); 4284 if (FRAME_MAC_DISPLAY_INFO (*fp)->grabbed && last_mouse_frame
4319 4285 && FRAME_LIVE_P (last_mouse_frame))
4320 GetMouse (&mouse_pos); 4286 f1 = last_mouse_frame;
4321 4287 else
4322 pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2, 4288 f1 = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
4323 &last_mouse_glyph, insist);
4324 4289
4325 *bar_window = Qnil; 4290 if (f1)
4326 *part = scroll_bar_handle; 4291 {
4327 *fp = f; 4292 /* Ok, we found a frame. Store all the values.
4328 XSETINT (*x, mouse_pos.h); 4293 last_mouse_glyph is a rectangle used to reduce the
4329 XSETINT (*y, mouse_pos.v); 4294 generation of mouse events. To not miss any motion
4330 *time = last_mouse_movement_time; 4295 events, we must divide the frame into rectangles of the
4296 size of the smallest character that could be displayed
4297 on it, i.e. into the same rectangles that matrices on
4298 the frame are divided into. */
4299 Point mouse_pos;
4300
4301 SetPortWindowPort (FRAME_MAC_WINDOW (f1));
4302 GetMouse (&mouse_pos);
4303 remember_mouse_glyph (f1, mouse_pos.h, mouse_pos.v,
4304 &last_mouse_glyph);
4305
4306 *bar_window = Qnil;
4307 *part = 0;
4308 *fp = f1;
4309 XSETINT (*x, mouse_pos.h);
4310 XSETINT (*y, mouse_pos.v);
4311 *time = last_mouse_movement_time;
4312 }
4331 } 4313 }
4332 4314
4333 UNBLOCK_INPUT; 4315 UNBLOCK_INPUT;
@@ -5275,7 +5257,7 @@ x_clip_to_row (w, row, area, gc)
5275 clip_rect.right = clip_rect.left + window_width; 5257 clip_rect.right = clip_rect.left + window_width;
5276 clip_rect.bottom = clip_rect.top + row->visible_height; 5258 clip_rect.bottom = clip_rect.top + row->visible_height;
5277 5259
5278 mac_set_clip_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), &clip_rect); 5260 mac_set_clip_rectangles (FRAME_MAC_DISPLAY (f), gc, &clip_rect, 1);
5279} 5261}
5280 5262
5281 5263
@@ -5318,7 +5300,7 @@ x_draw_hollow_cursor (w, row)
5318 /* Set clipping, draw the rectangle, and reset clipping again. */ 5300 /* Set clipping, draw the rectangle, and reset clipping again. */
5319 x_clip_to_row (w, row, TEXT_AREA, gc); 5301 x_clip_to_row (w, row, TEXT_AREA, gc);
5320 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 5302 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
5321 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f)); 5303 mac_reset_clip_rectangles (dpy, gc);
5322} 5304}
5323 5305
5324 5306
@@ -5402,7 +5384,7 @@ x_draw_bar_cursor (w, row, width, kind)
5402 cursor_glyph->pixel_width, 5384 cursor_glyph->pixel_width,
5403 width); 5385 width);
5404 5386
5405 mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f)); 5387 mac_reset_clip_rectangles (dpy, gc);
5406 } 5388 }
5407} 5389}
5408 5390
@@ -6777,7 +6759,13 @@ static char **font_name_table = NULL;
6777static int font_name_table_size = 0; 6759static int font_name_table_size = 0;
6778static int font_name_count = 0; 6760static int font_name_count = 0;
6779 6761
6762/* Alist linking font family names to Font Manager font family
6763 references (which can also be used as QuickDraw font IDs). We use
6764 an alist because hash tables are not ready when the terminal frame
6765 for Mac OS Classic is created. */
6766static Lisp_Object fm_font_family_alist;
6780#if USE_ATSUI 6767#if USE_ATSUI
6768/* Hash table linking font family names to ATSU font IDs. */
6781static Lisp_Object atsu_font_id_hash; 6769static Lisp_Object atsu_font_id_hash;
6782#endif 6770#endif
6783 6771
@@ -6827,28 +6815,42 @@ decode_mac_font_name (name, size, coding_system)
6827 struct coding_system coding; 6815 struct coding_system coding;
6828 char *buf, *p; 6816 char *buf, *p;
6829 6817
6830 for (p = name; *p; p++) 6818 if (!NILP (coding_system) && !NILP (Fcoding_system_p (coding_system)))
6831 if (!isascii (*p) || iscntrl (*p)) 6819 {
6832 break; 6820 for (p = name; *p; p++)
6821 if (!isascii (*p) || iscntrl (*p))
6822 break;
6833 6823
6834 if (*p == '\0' 6824 if (*p)
6835 || NILP (coding_system) || NILP (Fcoding_system_p (coding_system))) 6825 {
6836 return; 6826#if 0
6827/* MAC_TODO: Fix encoding system... */
6828 setup_coding_system (coding_system, &coding);
6829 coding.src_multibyte = 0;
6830 coding.dst_multibyte = 1;
6831 coding.mode |= CODING_MODE_LAST_BLOCK;
6832 coding.composing = COMPOSITION_DISABLED;
6833 buf = (char *) alloca (size);
6834
6835 decode_coding (&coding, name, buf, strlen (name), size - 1);
6836 bcopy (buf, name, coding.produced);
6837 name[coding.produced] = '\0';
6838#endif
6839 }
6840 }
6837 6841
6838 #if 0 6842 /* If there's just one occurrence of '-' in the family name, it is
6839 /* MAC_TODO: Fix encoding system... */ 6843 replaced with '_'. (More than one occurrence of '-' means a
6840 setup_coding_system (coding_system, &coding); 6844 "FOUNDRY-FAMILY-CHARSET"-style name.) */
6841 coding.src_multibyte = 0; 6845 p = strchr (name, '-');
6842 coding.dst_multibyte = 1; 6846 if (p && strchr (p + 1, '-') == NULL)
6843 coding.mode |= CODING_MODE_LAST_BLOCK; 6847 *p = '_';
6844 coding.dst_bytes = MAX_MULTsize;
6845 coding.destination = (char *) alloca (size);
6846 coding_decode_c_string(&coding, name, strlen(name), qNil);
6847 6848
6848 decode_coding (&coding, name, buf, strlen (name), size - 1); 6849 for (p = name; *p; p++)
6849 bcopy (buf, name, coding.produced); 6850 /* On Mac OS X 10.3, tolower also converts non-ASCII characters
6850 name[coding.produced] = '\0'; 6851 for some locales. */
6851 #endif 6852 if (isascii (*p))
6853 *p = tolower (*p);
6852} 6854}
6853 6855
6854 6856
@@ -6887,32 +6889,46 @@ mac_to_x_fontname (name, size, style, charset)
6887} 6889}
6888 6890
6889 6891
6890/* Convert an X font spec to the corresponding mac font name, which 6892/* Parse fully-specified and instantiated X11 font spec XF, and store
6891 can then be passed to GetFNum after conversion to a Pascal string. 6893 the results to FAMILY, *SIZE, *STYLE, and CHARSET. Return 1 if the
6892 For ordinary Mac fonts, this should just be their names, like 6894 parsing succeeded, and 0 otherwise. For FAMILY and CHARSET, the
6893 "monaco", "Taipei", etc. Fonts converted from the GNU intlfonts 6895 caller must allocate at least 256 and 32 bytes respectively. For
6894 collection contain their charset designation in their names, like 6896 ordinary Mac fonts, the value stored to FAMILY should just be their
6895 "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both types of font 6897 names, like "monaco", "Taipei", etc. Fonts converted from the GNU
6896 names are handled accordingly. */ 6898 intlfonts collection contain their charset designation in their
6897static void 6899 names, like "ETL-Fixed-iso8859-1", "ETL-Fixed-koi8-r", etc. Both
6898x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs) 6900 types of font names are handled accordingly. */
6899 char *xf, *mf, *mf_decoded; 6901
6902const int kDefaultFontSize = 12;
6903
6904static int
6905parse_x_font_name (xf, family, size, style, charset)
6906 char *xf, *family;
6907 int *size;
6900 Style *style; 6908 Style *style;
6901 char *cs; 6909 char *charset;
6902{ 6910{
6903 Str31 foundry; 6911 Str31 foundry, weight;
6904 Str255 family; 6912 int point_size, avgwidth;
6905 char weight[20], slant[2], *p; 6913 char slant[2], *p;
6906 Lisp_Object charset_info, coding_system = Qnil;
6907 struct coding_system coding;
6908 6914
6909 strcpy (mf, ""); 6915 if (sscanf (xf, "-%31[^-]-%255[^-]-%31[^-]-%1[^-]-%*[^-]-%*[^-]-%d-%d-%*[^-]-%*[^-]-%*c-%d-%31s",
6916 foundry, family, weight, slant, size,
6917 &point_size, &avgwidth, charset) != 8
6918 && sscanf (xf, "-%31[^-]-%255[^-]-%31[^-]-%1[^-]-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%31s",
6919 foundry, family, weight, slant, size,
6920 &point_size, &avgwidth, charset) != 8)
6921 return 0;
6910 6922
6911 if (sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", 6923 if (*size == 0)
6912 foundry, family, weight, slant, cs) != 5 && 6924 {
6913 sscanf (xf, "-%31[^-]-%255[^-]-%19[^-]-%1[^-]-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s", 6925 if (point_size > 0)
6914 foundry, family, weight, slant, cs) != 5) 6926 *size = point_size / 10;
6915 return; 6927 else if (avgwidth > 0)
6928 *size = avgwidth / 10;
6929 }
6930 if (*size == 0)
6931 *size = kDefaultFontSize;
6916 6932
6917 *style = normal; 6933 *style = normal;
6918 if (strcmp (weight, "bold") == 0) 6934 if (strcmp (weight, "bold") == 0)
@@ -6920,35 +6936,31 @@ x_font_name_to_mac_font_name (xf, mf, mf_decoded, style, cs)
6920 if (*slant == 'i') 6936 if (*slant == 'i')
6921 *style |= italic; 6937 *style |= italic;
6922 6938
6923 charset_info = Fassoc (build_string (cs), Vmac_charset_info_alist); 6939 if (NILP (Fassoc (build_string (charset), Vmac_charset_info_alist)))
6924 if (!NILP (charset_info))
6925 { 6940 {
6926 strcpy (mf_decoded, family); 6941 int foundry_len = strlen (foundry), family_len = strlen (family);
6927 coding_system = Fcar (Fcdr (Fcdr (charset_info))); 6942
6943 if (foundry_len + family_len + strlen (charset) + 2 < sizeof (Str255))
6944 {
6945 /* Like sprintf (family, "%s-%s-%s", foundry, family, charset),
6946 but take overlap into account. */
6947 memmove (family + foundry_len + 1, family, family_len);
6948 memcpy (family, foundry, foundry_len);
6949 family[foundry_len] = '-';
6950 family[foundry_len + 1 + family_len] = '-';
6951 strcpy (family + foundry_len + 1 + family_len + 1, charset);
6952 }
6953 else
6954 return 0;
6928 } 6955 }
6929 else
6930 sprintf (mf_decoded, "%s-%s-%s", foundry, family, cs);
6931 6956
6932 for (p = mf_decoded; *p; p++) 6957 for (p = family; *p; p++)
6933 if (!isascii (*p) || iscntrl (*p)) 6958 /* On Mac OS X 10.3, tolower also converts non-ASCII characters
6934 break; 6959 for some locales. */
6960 if (isascii (*p))
6961 *p = tolower (*p);
6935 6962
6936 if (*p == '\0' 6963 return 1;
6937 || NILP (coding_system) || NILP (Fcoding_system_p (coding_system)))
6938 strcpy (mf, mf_decoded);
6939#if 0
6940 /* MAC_TODO: Fix coding system to use objects */
6941 else
6942 {
6943 setup_coding_system (coding_system, &coding);
6944 coding.src_multibyte = 1;
6945 coding.dst_multibyte = 0;
6946 coding.mode |= CODING_MODE_LAST_BLOCK;
6947 encode_coding (&coding, mf_decoded, mf,
6948 strlen (mf_decoded), sizeof (Str255) - 1);
6949 mf[coding.produced] = '\0';
6950 }
6951#endif
6952} 6964}
6953 6965
6954 6966
@@ -7025,6 +7037,8 @@ init_font_name_table ()
7025 kFontMacintoshPlatform, kFontNoScript, 7037 kFontMacintoshPlatform, kFontNoScript,
7026 kFontNoLanguage, name_len, name, 7038 kFontNoLanguage, name_len, name,
7027 NULL, NULL); 7039 NULL, NULL);
7040 if (err == noErr)
7041 decode_mac_font_name (name, name_len + 1, Qnil);
7028 if (err == noErr 7042 if (err == noErr
7029 && *name != '.' 7043 && *name != '.'
7030 && (prev_name == NULL 7044 && (prev_name == NULL
@@ -7040,7 +7054,7 @@ init_font_name_table ()
7040 bold, cs)); 7054 bold, cs));
7041 add_font_name_table_entry (mac_to_x_fontname (name, 0, 7055 add_font_name_table_entry (mac_to_x_fontname (name, 0,
7042 italic | bold, cs)); 7056 italic | bold, cs));
7043 Fputhash (Fdowncase (make_unibyte_string (name, name_len)), 7057 Fputhash (make_unibyte_string (name, name_len),
7044 long_to_cons (font_ids[i]), atsu_font_id_hash); 7058 long_to_cons (font_ids[i]), atsu_font_id_hash);
7045 xfree (prev_name); 7059 xfree (prev_name);
7046 prev_name = name; 7060 prev_name = name;
@@ -7090,12 +7104,14 @@ init_font_name_table ()
7090 sc = GetTextEncodingBase (encoding); 7104 sc = GetTextEncodingBase (encoding);
7091 text_encoding_info = assq_no_quit (make_number (sc), 7105 text_encoding_info = assq_no_quit (make_number (sc),
7092 text_encoding_info_alist); 7106 text_encoding_info_alist);
7093 if (!NILP (text_encoding_info)) 7107 if (NILP (text_encoding_info))
7094 decode_mac_font_name (name, sizeof (name),
7095 XCAR (XCDR (text_encoding_info)));
7096 else
7097 text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman), 7108 text_encoding_info = assq_no_quit (make_number (kTextEncodingMacRoman),
7098 text_encoding_info_alist); 7109 text_encoding_info_alist);
7110 decode_mac_font_name (name, sizeof (name),
7111 XCAR (XCDR (text_encoding_info)));
7112 fm_font_family_alist = Fcons (Fcons (build_string (name),
7113 make_number (ff)),
7114 fm_font_family_alist);
7099 7115
7100 /* Point the instance iterator at the current font family. */ 7116 /* Point the instance iterator at the current font family. */
7101 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) 7117 if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
@@ -7174,12 +7190,14 @@ init_font_name_table ()
7174 scriptcode = FontToScript (fontnum); 7190 scriptcode = FontToScript (fontnum);
7175 text_encoding_info = assq_no_quit (make_number (scriptcode), 7191 text_encoding_info = assq_no_quit (make_number (scriptcode),
7176 text_encoding_info_alist); 7192 text_encoding_info_alist);
7177 if (!NILP (text_encoding_info)) 7193 if (NILP (text_encoding_info))
7178 decode_mac_font_name (name, sizeof (name),
7179 XCAR (XCDR (text_encoding_info)));
7180 else
7181 text_encoding_info = assq_no_quit (make_number (smRoman), 7194 text_encoding_info = assq_no_quit (make_number (smRoman),
7182 text_encoding_info_alist); 7195 text_encoding_info_alist);
7196 decode_mac_font_name (name, sizeof (name),
7197 XCAR (XCDR (text_encoding_info)));
7198 fm_font_family_alist = Fcons (Fcons (build_string (name),
7199 make_number (fontnum)),
7200 fm_font_family_alist);
7183 do 7201 do
7184 { 7202 {
7185 HLock (font_handle); 7203 HLock (font_handle);
@@ -7235,6 +7253,7 @@ mac_clear_font_name_table ()
7235 xfree (font_name_table); 7253 xfree (font_name_table);
7236 font_name_table = NULL; 7254 font_name_table = NULL;
7237 font_name_table_size = font_name_count = 0; 7255 font_name_table_size = font_name_count = 0;
7256 fm_font_family_alist = Qnil;
7238} 7257}
7239 7258
7240 7259
@@ -7543,9 +7562,6 @@ is_fully_specified_xlfd (char *p)
7543} 7562}
7544 7563
7545 7564
7546const int kDefaultFontSize = 12;
7547
7548
7549/* XLoadQueryFont creates and returns an internal representation for a 7565/* XLoadQueryFont creates and returns an internal representation for a
7550 font in a MacFontStruct struct. There is really no concept 7566 font in a MacFontStruct struct. There is really no concept
7551 corresponding to "loading" a font on the Mac. But we check its 7567 corresponding to "loading" a font on the Mac. But we check its
@@ -7555,12 +7571,9 @@ const int kDefaultFontSize = 12;
7555static MacFontStruct * 7571static MacFontStruct *
7556XLoadQueryFont (Display *dpy, char *fontname) 7572XLoadQueryFont (Display *dpy, char *fontname)
7557{ 7573{
7558 int i, size, point_size, avgwidth, is_two_byte_font, char_width; 7574 int i, size, char_width;
7559 char *name; 7575 char *name;
7560 GrafPtr port; 7576 Str255 family;
7561 SInt16 old_fontnum, old_fontsize;
7562 Style old_fontface;
7563 Str255 mfontname, mfontname_decoded;
7564 Str31 charset; 7577 Str31 charset;
7565 SInt16 fontnum; 7578 SInt16 fontnum;
7566#if USE_ATSUI 7579#if USE_ATSUI
@@ -7574,10 +7587,6 @@ XLoadQueryFont (Display *dpy, char *fontname)
7574 short scriptcode; 7587 short scriptcode;
7575#endif 7588#endif
7576 MacFontStruct *font; 7589 MacFontStruct *font;
7577 FontInfo the_fontinfo;
7578#ifdef MAC_OSX
7579 UInt32 old_flags, new_flags;
7580#endif
7581 7590
7582 if (is_fully_specified_xlfd (fontname)) 7591 if (is_fully_specified_xlfd (fontname))
7583 name = fontname; 7592 name = fontname;
@@ -7591,32 +7600,9 @@ XLoadQueryFont (Display *dpy, char *fontname)
7591 name = SDATA (XCAR (matched_fonts)); 7600 name = SDATA (XCAR (matched_fonts));
7592 } 7601 }
7593 7602
7594 GetPort (&port); /* save the current font number used */ 7603 if (parse_x_font_name (name, family, &size, &fontface, charset) == 0)
7595#if TARGET_API_MAC_CARBON 7604 return NULL;
7596 old_fontnum = GetPortTextFont (port);
7597 old_fontsize = GetPortTextSize (port);
7598 old_fontface = GetPortTextFace (port);
7599#else
7600 old_fontnum = port->txFont;
7601 old_fontsize = port->txSize;
7602 old_fontface = port->txFace;
7603#endif
7604
7605 if (sscanf (name, "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%d-%d-%*[^-]-%*[^-]-%*c-%d-%*s", &size, &point_size, &avgwidth) != 3)
7606 size = 0;
7607 else
7608 {
7609 if (size == 0)
7610 if (point_size > 0)
7611 size = point_size / 10;
7612 else if (avgwidth > 0)
7613 size = avgwidth / 10;
7614 }
7615 if (size == 0)
7616 size = kDefaultFontSize;
7617 7605
7618 x_font_name_to_mac_font_name (name, mfontname, mfontname_decoded,
7619 &fontface, charset);
7620#if USE_ATSUI 7606#if USE_ATSUI
7621 if (strcmp (charset, "iso10646-1") == 0) /* XXX */ 7607 if (strcmp (charset, "iso10646-1") == 0) /* XXX */
7622 { 7608 {
@@ -7633,10 +7619,8 @@ XLoadQueryFont (Display *dpy, char *fontname)
7633 ATSUFontFeatureType types[] = {kAllTypographicFeaturesType}; 7619 ATSUFontFeatureType types[] = {kAllTypographicFeaturesType};
7634 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector}; 7620 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector};
7635 Lisp_Object font_id_cons; 7621 Lisp_Object font_id_cons;
7636 7622
7637 font_id_cons = Fgethash (Fdowncase 7623 font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)),
7638 (make_unibyte_string (mfontname,
7639 strlen (mfontname))),
7640 atsu_font_id_hash, Qnil); 7624 atsu_font_id_hash, Qnil);
7641 if (NILP (font_id_cons)) 7625 if (NILP (font_id_cons))
7642 return NULL; 7626 return NULL;
@@ -7657,24 +7641,21 @@ XLoadQueryFont (Display *dpy, char *fontname)
7657 scriptcode = kTextEncodingMacUnicode; 7641 scriptcode = kTextEncodingMacUnicode;
7658 } 7642 }
7659 else 7643 else
7660 {
7661#endif 7644#endif
7662 c2pstr (mfontname); 7645 {
7646 Lisp_Object tmp = Fassoc (build_string (family), fm_font_family_alist);
7647
7648 if (NILP (tmp))
7649 return NULL;
7650 fontnum = XINT (XCDR (tmp));
7663#if TARGET_API_MAC_CARBON 7651#if TARGET_API_MAC_CARBON
7664 fontnum = FMGetFontFamilyFromName (mfontname); 7652 if (FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr)
7665 if (fontnum == kInvalidFontFamily 7653 return NULL;
7666 || FMGetFontFamilyTextEncoding (fontnum, &encoding) != noErr) 7654 scriptcode = GetTextEncodingBase (encoding);
7667 return NULL;
7668 scriptcode = GetTextEncodingBase (encoding);
7669#else 7655#else
7670 GetFNum (mfontname, &fontnum); 7656 scriptcode = FontToScript (fontnum);
7671 if (fontnum == 0)
7672 return NULL;
7673 scriptcode = FontToScript (fontnum);
7674#endif 7657#endif
7675#if USE_ATSUI
7676 } 7658 }
7677#endif
7678 7659
7679 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct)); 7660 font = (MacFontStruct *) xmalloc (sizeof (struct MacFontStruct));
7680 7661
@@ -7693,7 +7674,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7693 if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0) 7674 if (scriptcode == smJapanese && strcmp (charset, "jisx0201.1976-0") == 0)
7694 font->mac_scriptcode = smRoman; 7675 font->mac_scriptcode = smRoman;
7695 7676
7696 font->full_name = mac_to_x_fontname (mfontname_decoded, size, fontface, charset); 7677 font->full_name = mac_to_x_fontname (family, size, fontface, charset);
7697 7678
7698#if USE_ATSUI 7679#if USE_ATSUI
7699 if (font->mac_style) 7680 if (font->mac_style)
@@ -7778,130 +7759,149 @@ XLoadQueryFont (Display *dpy, char *fontname)
7778 font->max_char_or_byte2 = 0xff; 7759 font->max_char_or_byte2 = 0xff;
7779 } 7760 }
7780 else 7761 else
7762#endif
7781 { 7763 {
7764 GrafPtr port;
7765 SInt16 old_fontnum, old_fontsize;
7766 Style old_fontface;
7767 FontInfo the_fontinfo;
7768 int is_two_byte_font;
7769
7770 /* Save the current font number used. */
7771 GetPort (&port);
7772#if TARGET_API_MAC_CARBON
7773 old_fontnum = GetPortTextFont (port);
7774 old_fontsize = GetPortTextSize (port);
7775 old_fontface = GetPortTextFace (port);
7776#else
7777 old_fontnum = port->txFont;
7778 old_fontsize = port->txSize;
7779 old_fontface = port->txFace;
7782#endif 7780#endif
7783 is_two_byte_font = font->mac_scriptcode == smJapanese ||
7784 font->mac_scriptcode == smTradChinese ||
7785 font->mac_scriptcode == smSimpChinese ||
7786 font->mac_scriptcode == smKorean;
7787 7781
7788 TextFont (fontnum); 7782 TextFont (fontnum);
7789 TextSize (size); 7783 TextSize (size);
7790 TextFace (fontface); 7784 TextFace (fontface);
7791 7785
7792 GetFontInfo (&the_fontinfo); 7786 GetFontInfo (&the_fontinfo);
7793 7787
7794 font->ascent = the_fontinfo.ascent; 7788 font->ascent = the_fontinfo.ascent;
7795 font->descent = the_fontinfo.descent; 7789 font->descent = the_fontinfo.descent;
7796 7790
7797 if (is_two_byte_font) 7791 is_two_byte_font = (font->mac_scriptcode == smJapanese
7798 { 7792 || font->mac_scriptcode == smTradChinese
7799 font->min_byte1 = 0xa1; 7793 || font->mac_scriptcode == smSimpChinese
7800 font->max_byte1 = 0xfe; 7794 || font->mac_scriptcode == smKorean);
7801 font->min_char_or_byte2 = 0xa1;
7802 font->max_char_or_byte2 = 0xfe;
7803 7795
7804 /* Use the width of an "ideographic space" of that font because 7796 if (is_two_byte_font)
7805 the_fontinfo.widMax returns the wrong width for some fonts. */ 7797 {
7806 switch (font->mac_scriptcode) 7798 font->min_byte1 = 0xa1;
7807 { 7799 font->max_byte1 = 0xfe;
7808 case smJapanese: 7800 font->min_char_or_byte2 = 0xa1;
7809 font->min_byte1 = 0x81; 7801 font->max_char_or_byte2 = 0xfe;
7810 font->max_byte1 = 0xfc; 7802
7811 font->min_char_or_byte2 = 0x40; 7803 /* Use the width of an "ideographic space" of that font
7812 font->max_char_or_byte2 = 0xfc; 7804 because the_fontinfo.widMax returns the wrong width for
7813 char_width = StringWidth("\p\x81\x40"); 7805 some fonts. */
7814 break; 7806 switch (font->mac_scriptcode)
7815 case smTradChinese: 7807 {
7816 font->min_char_or_byte2 = 0x40; 7808 case smJapanese:
7817 char_width = StringWidth("\p\xa1\x40"); 7809 font->min_byte1 = 0x81;
7818 break; 7810 font->max_byte1 = 0xfc;
7819 case smSimpChinese: 7811 font->min_char_or_byte2 = 0x40;
7820 char_width = StringWidth("\p\xa1\xa1"); 7812 font->max_char_or_byte2 = 0xfc;
7821 break; 7813 char_width = StringWidth("\p\x81\x40");
7822 case smKorean: 7814 break;
7823 char_width = StringWidth("\p\xa1\xa1"); 7815 case smTradChinese:
7824 break; 7816 font->min_char_or_byte2 = 0x40;
7825 } 7817 char_width = StringWidth("\p\xa1\x40");
7826 } 7818 break;
7827 else 7819 case smSimpChinese:
7828 { 7820 char_width = StringWidth("\p\xa1\xa1");
7829 font->min_byte1 = font->max_byte1 = 0; 7821 break;
7830 font->min_char_or_byte2 = 0x20; 7822 case smKorean:
7831 font->max_char_or_byte2 = 0xff; 7823 char_width = StringWidth("\p\xa1\xa1");
7824 break;
7825 }
7826 }
7827 else
7828 {
7829 font->min_byte1 = font->max_byte1 = 0;
7830 font->min_char_or_byte2 = 0x20;
7831 font->max_char_or_byte2 = 0xff;
7832 7832
7833 /* Do this instead of use the_fontinfo.widMax, which incorrectly 7833 /* Do this instead of use the_fontinfo.widMax, which
7834 returns 15 for 12-point Monaco! */ 7834 incorrectly returns 15 for 12-point Monaco! */
7835 char_width = CharWidth ('m'); 7835 char_width = CharWidth ('m');
7836 } 7836 }
7837 7837
7838 if (is_two_byte_font) 7838 if (is_two_byte_font)
7839 { 7839 {
7840 font->per_char = NULL; 7840 font->per_char = NULL;
7841 7841
7842 if (fontface & italic) 7842 if (fontface & italic)
7843 font->max_bounds.rbearing = char_width + 1; 7843 font->max_bounds.rbearing = char_width + 1;
7844 else 7844 else
7845 font->max_bounds.rbearing = char_width; 7845 font->max_bounds.rbearing = char_width;
7846 font->max_bounds.lbearing = 0; 7846 font->max_bounds.lbearing = 0;
7847 font->max_bounds.width = char_width; 7847 font->max_bounds.width = char_width;
7848 font->max_bounds.ascent = the_fontinfo.ascent; 7848 font->max_bounds.ascent = the_fontinfo.ascent;
7849 font->max_bounds.descent = the_fontinfo.descent; 7849 font->max_bounds.descent = the_fontinfo.descent;
7850 7850
7851 font->min_bounds = font->max_bounds; 7851 font->min_bounds = font->max_bounds;
7852 } 7852 }
7853 else 7853 else
7854 { 7854 {
7855 int c, min_width, max_width; 7855 int c, min_width, max_width;
7856 Rect char_bounds, min_bounds, max_bounds; 7856 Rect char_bounds, min_bounds, max_bounds;
7857 char ch; 7857 char ch;
7858 7858
7859 font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1)); 7859 font->per_char = xmalloc (sizeof (XCharStruct) * (0xff - 0x20 + 1));
7860 bzero (font->per_char, sizeof (XCharStruct) * (0xff - 0x20 + 1));
7860 7861
7861 min_width = max_width = char_width; 7862 min_width = max_width = char_width;
7862 SetRect (&min_bounds, -32767, -32767, 32767, 32767); 7863 SetRect (&min_bounds, -32767, -32767, 32767, 32767);
7863 SetRect (&max_bounds, 0, 0, 0, 0); 7864 SetRect (&max_bounds, 0, 0, 0, 0);
7864 for (c = 0x20; c <= 0xff; c++) 7865 for (c = 0x20; c <= 0xff; c++)
7865 {
7866 ch = c;
7867 char_width = CharWidth (ch);
7868 QDTextBounds (1, &ch, &char_bounds);
7869 STORE_XCHARSTRUCT (font->per_char[c - 0x20],
7870 char_width, char_bounds);
7871 /* Some Japanese fonts (in SJIS encoding) return 0 as the
7872 character width of 0x7f. */
7873 if (char_width > 0)
7874 { 7866 {
7875 min_width = min (min_width, char_width); 7867 ch = c;
7876 max_width = max (max_width, char_width); 7868 char_width = CharWidth (ch);
7869 QDTextBounds (1, &ch, &char_bounds);
7870 STORE_XCHARSTRUCT (font->per_char[c - 0x20],
7871 char_width, char_bounds);
7872 /* Some Japanese fonts (in SJIS encoding) return 0 as
7873 the character width of 0x7f. */
7874 if (char_width > 0)
7875 {
7876 min_width = min (min_width, char_width);
7877 max_width = max (max_width, char_width);
7878 }
7879 if (!EmptyRect (&char_bounds))
7880 {
7881 SetRect (&min_bounds,
7882 max (min_bounds.left, char_bounds.left),
7883 max (min_bounds.top, char_bounds.top),
7884 min (min_bounds.right, char_bounds.right),
7885 min (min_bounds.bottom, char_bounds.bottom));
7886 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7887 }
7877 } 7888 }
7878 if (!EmptyRect (&char_bounds)) 7889 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7890 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7891 if (min_width == max_width
7892 && max_bounds.left >= 0 && max_bounds.right <= max_width)
7879 { 7893 {
7880 SetRect (&min_bounds, 7894 /* Fixed width and no overhangs. */
7881 max (min_bounds.left, char_bounds.left), 7895 xfree (font->per_char);
7882 max (min_bounds.top, char_bounds.top), 7896 font->per_char = NULL;
7883 min (min_bounds.right, char_bounds.right),
7884 min (min_bounds.bottom, char_bounds.bottom));
7885 UnionRect (&max_bounds, &char_bounds, &max_bounds);
7886 } 7897 }
7887 } 7898 }
7888 STORE_XCHARSTRUCT (font->min_bounds, min_width, min_bounds);
7889 STORE_XCHARSTRUCT (font->max_bounds, max_width, max_bounds);
7890 if (min_width == max_width
7891 && max_bounds.left >= 0 && max_bounds.right <= max_width)
7892 {
7893 /* Fixed width and no overhangs. */
7894 xfree (font->per_char);
7895 font->per_char = NULL;
7896 }
7897 }
7898 7899
7899 TextFont (old_fontnum); /* restore previous font number, size and face */ 7900 /* Restore previous font number, size and face. */
7900 TextSize (old_fontsize); 7901 TextFont (old_fontnum);
7901 TextFace (old_fontface); 7902 TextSize (old_fontsize);
7902#if USE_ATSUI 7903 TextFace (old_fontface);
7903 } 7904 }
7904#endif
7905 7905
7906 return font; 7906 return font;
7907} 7907}
@@ -10056,8 +10056,7 @@ XTread_socket (sd, expected, hold_quit)
10056 er.where.h + 1, er.where.v + 1); 10056 er.where.h + 1, er.where.v + 1);
10057#endif 10057#endif
10058 previous_help_echo_string = help_echo_string; 10058 previous_help_echo_string = help_echo_string;
10059 help_echo_string = help_echo_object = help_echo_window = Qnil; 10059 help_echo_string = Qnil;
10060 help_echo_pos = -1;
10061 10060
10062 if (dpyinfo->grabbed && last_mouse_frame 10061 if (dpyinfo->grabbed && last_mouse_frame
10063 && FRAME_LIVE_P (last_mouse_frame)) 10062 && FRAME_LIVE_P (last_mouse_frame))
@@ -10116,7 +10115,8 @@ XTread_socket (sd, expected, hold_quit)
10116 10115
10117 last_window=window; 10116 last_window=window;
10118 } 10117 }
10119 note_mouse_movement (f, &mouse_pos); 10118 if (!note_mouse_movement (f, &mouse_pos))
10119 help_echo_string = previous_help_echo_string;
10120 } 10120 }
10121 } 10121 }
10122 10122
@@ -10931,14 +10931,17 @@ syms_of_macterm ()
10931 staticpro (&Qreverse); 10931 staticpro (&Qreverse);
10932 Qreverse = intern ("reverse"); 10932 Qreverse = intern ("reverse");
10933 10933
10934 staticpro (&Qmac_ready_for_drag_n_drop);
10935 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
10936
10934 staticpro (&x_display_name_list); 10937 staticpro (&x_display_name_list);
10935 x_display_name_list = Qnil; 10938 x_display_name_list = Qnil;
10936 10939
10937 staticpro (&last_mouse_scroll_bar); 10940 staticpro (&last_mouse_scroll_bar);
10938 last_mouse_scroll_bar = Qnil; 10941 last_mouse_scroll_bar = Qnil;
10939 10942
10940 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); 10943 staticpro (&fm_font_family_alist);
10941 staticpro (&Qmac_ready_for_drag_n_drop); 10944 fm_font_family_alist = Qnil;
10942 10945
10943#if USE_ATSUI 10946#if USE_ATSUI
10944 staticpro (&atsu_font_id_hash); 10947 staticpro (&atsu_font_id_hash);
diff --git a/src/macterm.h b/src/macterm.h
index b3855f142c6..e7a5fc2450e 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -39,8 +39,8 @@ Boston, MA 02110-1301, USA. */
39#define BLACK_PIX_DEFAULT(f) RGB_TO_ULONG(0,0,0) 39#define BLACK_PIX_DEFAULT(f) RGB_TO_ULONG(0,0,0)
40#define WHITE_PIX_DEFAULT(f) RGB_TO_ULONG(255,255,255) 40#define WHITE_PIX_DEFAULT(f) RGB_TO_ULONG(255,255,255)
41 41
42#define FONT_WIDTH(f) ((f)->max_bounds.width) 42#define FONT_WIDTH(f) ((f)->max_bounds.width)
43#define FONT_HEIGHT(f) ((f)->ascent + (f)->descent) 43#define FONT_HEIGHT(f) ((f)->ascent + (f)->descent)
44#define FONT_BASE(f) ((f)->ascent) 44#define FONT_BASE(f) ((f)->ascent)
45#define FONT_DESCENT(f) ((f)->descent) 45#define FONT_DESCENT(f) ((f)->descent)
46 46
@@ -82,16 +82,8 @@ struct mac_display_info
82 /* Whether the screen supports color */ 82 /* Whether the screen supports color */
83 int color_p; 83 int color_p;
84 84
85#if 0
86 /* Number of bits per pixel on this screen. */
87 int n_cbits;
88#endif
89
90 /* Dimensions of this screen. */ 85 /* Dimensions of this screen. */
91 int height, width; 86 int height, width;
92#if 0
93 int height_in,width_in;
94#endif
95 87
96 /* Mask of things that cause the mouse to be grabbed. */ 88 /* Mask of things that cause the mouse to be grabbed. */
97 int grabbed; 89 int grabbed;
@@ -111,33 +103,12 @@ struct mac_display_info
111 /* Resource data base */ 103 /* Resource data base */
112 XrmDatabase xrdb; 104 XrmDatabase xrdb;
113 105
114#if 0
115 /* color palette information. */
116 int has_palette;
117 struct w32_palette_entry * color_list;
118 unsigned num_colors;
119 HPALETTE palette;
120
121 /* deferred action flags checked when starting frame update. */
122 int regen_palette;
123
124 /* Keystroke that has been faked by Emacs and will be ignored when
125 received; value is reset after key is received. */
126 int faked_key;
127
128#endif
129
130 /* A table of all the fonts we have already loaded. */ 106 /* A table of all the fonts we have already loaded. */
131 struct font_info *font_table; 107 struct font_info *font_table;
132 108
133 /* The current capacity of font_table. */ 109 /* The current capacity of font_table. */
134 int font_table_size; 110 int font_table_size;
135 111
136 /* The number of fonts actually stored in the font table.
137 font_table[n] is used and valid iff 0 <= n < n_fonts. 0 <=
138 n_fonts <= font_table_size. and font_table[i].name != 0. */
139 int n_fonts;
140
141 /* Minimum width over all characters in all fonts in font_table. */ 112 /* Minimum width over all characters in all fonts in font_table. */
142 int smallest_char_width; 113 int smallest_char_width;
143 114
@@ -148,7 +119,7 @@ struct mac_display_info
148 GC scratch_cursor_gc; 119 GC scratch_cursor_gc;
149 120
150 /* These variables describe the range of text currently shown in its 121 /* These variables describe the range of text currently shown in its
151 mouse-face, together with the window they apply to. As long as 122 mouse-face, together with the window they apply to. As long as
152 the mouse stays within this range, we need not redraw anything on 123 the mouse stays within this range, we need not redraw anything on
153 its account. Rows and columns are glyph matrix positions in 124 its account. Rows and columns are glyph matrix positions in
154 MOUSE_FACE_WINDOW. */ 125 MOUSE_FACE_WINDOW. */
@@ -168,7 +139,6 @@ struct mac_display_info
168 /* FRAME and X, Y position of mouse when last checked for 139 /* FRAME and X, Y position of mouse when last checked for
169 highlighting. X and Y can be negative or out of range for the frame. */ 140 highlighting. X and Y can be negative or out of range for the frame. */
170 struct frame *mouse_face_mouse_frame; 141 struct frame *mouse_face_mouse_frame;
171
172 int mouse_face_mouse_x, mouse_face_mouse_y; 142 int mouse_face_mouse_x, mouse_face_mouse_y;
173 143
174 /* Nonzero means defer mouse-motion highlighting. */ 144 /* Nonzero means defer mouse-motion highlighting. */
@@ -181,6 +151,11 @@ struct mac_display_info
181 151
182 char *mac_id_name; 152 char *mac_id_name;
183 153
154 /* The number of fonts actually stored in the font table.
155 font_table[n] is used and valid iff 0 <= n < n_fonts. 0 <=
156 n_fonts <= font_table_size and font_table[i].name != 0. */
157 int n_fonts;
158
184 /* Pointer to bitmap records. */ 159 /* Pointer to bitmap records. */
185 struct mac_bitmap_record *bitmaps; 160 struct mac_bitmap_record *bitmaps;
186 161
@@ -237,7 +212,7 @@ extern int unibyte_display_via_language_environment;
237extern struct x_display_info *x_display_info_for_display P_ ((Display *)); 212extern struct x_display_info *x_display_info_for_display P_ ((Display *));
238extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object)); 213extern struct x_display_info *x_display_info_for_name P_ ((Lisp_Object));
239 214
240extern struct mac_display_info *mac_term_init (); 215extern struct mac_display_info *mac_term_init P_ ((Lisp_Object, char *, char *));
241 216
242extern Lisp_Object x_list_fonts P_ ((struct frame *, Lisp_Object, int, int)); 217extern Lisp_Object x_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
243extern struct font_info *x_get_font_info P_ ((struct frame *f, int)); 218extern struct font_info *x_get_font_info P_ ((struct frame *f, int));
@@ -262,33 +237,8 @@ struct mac_output {
262 /* Menubar "widget" handle. */ 237 /* Menubar "widget" handle. */
263 int menubar_widget; 238 int menubar_widget;
264 239
265 Window mWP; /* pointer to QuickDraw window */
266 FRAME_PTR mFP; /* points back to the frame struct */ 240 FRAME_PTR mFP; /* points back to the frame struct */
267 241
268#if 0
269 int mNumCols; /* number of characters per column */
270 int mNumRows; /* number of characters per row */
271 int mLineHeight; /* height of one line of text in pixels */
272 int mCharWidth; /* width of one character in pixels */
273 int mHomeX; /* X pixel coordinate of lower left
274 corner of character at (0, 0) */
275 int mHomeY; /* Y pixel coordinate of lower left
276 corner of character at (0, 0) */
277 int mHighlight; /* current highlight state (0 = off). */
278 int mTermWinSize; /* num of lines from top of window
279 affected by ins_del_lines; set by
280 set_terminal_window. */
281#endif /* 0 */
282
283#if 0
284 /* stuffs used by xfaces.c */
285 struct face **param_faces;
286 int n_param_faces;
287 struct face **computed_faces;
288 int n_computed_faces;
289 int size_computed_faces;
290#endif
291
292 /* Here are the Graphics Contexts for the default font. */ 242 /* Here are the Graphics Contexts for the default font. */
293 GC normal_gc; /* Normal video */ 243 GC normal_gc; /* Normal video */
294 GC reverse_gc; /* Reverse video */ 244 GC reverse_gc; /* Reverse video */
@@ -322,6 +272,7 @@ struct mac_output {
322 unsigned long mouse_pixel; 272 unsigned long mouse_pixel;
323 unsigned long cursor_foreground_pixel; 273 unsigned long cursor_foreground_pixel;
324 274
275#if 0
325 /* Foreground color for scroll bars. A value of -1 means use the 276 /* Foreground color for scroll bars. A value of -1 means use the
326 default (black for non-toolkit scroll bars). */ 277 default (black for non-toolkit scroll bars). */
327 unsigned long scroll_bar_foreground_pixel; 278 unsigned long scroll_bar_foreground_pixel;
@@ -330,6 +281,7 @@ struct mac_output {
330 default (background color of the frame for non-toolkit scroll 281 default (background color of the frame for non-toolkit scroll
331 bars). */ 282 bars). */
332 unsigned long scroll_bar_background_pixel; 283 unsigned long scroll_bar_background_pixel;
284#endif
333 285
334 /* Descriptor for the cursor in use for this window. */ 286 /* Descriptor for the cursor in use for this window. */
335 Cursor text_cursor; 287 Cursor text_cursor;
@@ -357,10 +309,6 @@ struct mac_output {
357 ControlRef hourglass_control; 309 ControlRef hourglass_control;
358#endif 310#endif
359 311
360#if 0
361 DWORD dwStyle;
362#endif
363
364 /* This is the Emacs structure for the display this frame is on. */ 312 /* This is the Emacs structure for the display this frame is on. */
365 /* struct w32_display_info *display_info; */ 313 /* struct w32_display_info *display_info; */
366 314
@@ -377,10 +325,6 @@ struct mac_output {
377 /* Nonzero means a menu command is being processed. */ 325 /* Nonzero means a menu command is being processed. */
378 char menu_command_in_progress; 326 char menu_command_in_progress;
379 327
380 /* Nonzero means menubar is about to become active, but should be
381 brought up to date first. */
382 volatile char pending_menu_activation;
383
384 /* Relief GCs, colors etc. */ 328 /* Relief GCs, colors etc. */
385 struct relief 329 struct relief
386 { 330 {
@@ -404,8 +348,8 @@ typedef struct mac_output mac_output;
404#define FRAME_X_OUTPUT(f) ((f)->output_data.mac) 348#define FRAME_X_OUTPUT(f) ((f)->output_data.mac)
405 349
406/* Return the Mac window used for displaying data in frame F. */ 350/* Return the Mac window used for displaying data in frame F. */
407#define FRAME_MAC_WINDOW(f) ((f)->output_data.mac->mWP) 351#define FRAME_MAC_WINDOW(f) ((f)->output_data.mac->window_desc)
408#define FRAME_X_WINDOW(f) ((f)->output_data.mac->mWP) 352#define FRAME_X_WINDOW(f) ((f)->output_data.mac->window_desc)
409 353
410#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel) 354#define FRAME_FOREGROUND_PIXEL(f) ((f)->output_data.x->foreground_pixel)
411#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel) 355#define FRAME_BACKGROUND_PIXEL(f) ((f)->output_data.x->background_pixel)
@@ -531,7 +475,7 @@ struct scroll_bar {
531 475
532/* Return the inside width of a vertical scroll bar, given the outside 476/* Return the inside width of a vertical scroll bar, given the outside
533 width. */ 477 width. */
534#define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f,width) \ 478#define VERTICAL_SCROLL_BAR_INSIDE_WIDTH(f, width) \
535 ((width) \ 479 ((width) \
536 - VERTICAL_SCROLL_BAR_LEFT_BORDER \ 480 - VERTICAL_SCROLL_BAR_LEFT_BORDER \
537 - VERTICAL_SCROLL_BAR_RIGHT_BORDER \ 481 - VERTICAL_SCROLL_BAR_RIGHT_BORDER \
diff --git a/src/sysdep.c b/src/sysdep.c
index f70d4b18cff..3bc72c51193 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1012,7 +1012,7 @@ reset_sigio ()
1012void 1012void
1013request_sigio () 1013request_sigio ()
1014{ 1014{
1015 if (read_socket_hook) 1015 if (noninteractive || read_socket_hook)
1016 return; 1016 return;
1017 1017
1018#ifdef SIGWINCH 1018#ifdef SIGWINCH
@@ -1026,7 +1026,7 @@ request_sigio ()
1026void 1026void
1027unrequest_sigio () 1027unrequest_sigio ()
1028{ 1028{
1029 if (read_socket_hook) 1029 if (noninteractive || read_socket_hook)
1030 return; 1030 return;
1031 1031
1032#ifdef SIGWINCH 1032#ifdef SIGWINCH
@@ -1044,7 +1044,7 @@ request_sigio ()
1044{ 1044{
1045 int on = 1; 1045 int on = 1;
1046 1046
1047 if (read_socket_hook) 1047 if (noninteractive || read_socket_hook)
1048 return; 1048 return;
1049 1049
1050 ioctl (input_fd, FIOASYNC, &on); 1050 ioctl (input_fd, FIOASYNC, &on);
@@ -1056,7 +1056,7 @@ unrequest_sigio ()
1056{ 1056{
1057 int off = 0; 1057 int off = 0;
1058 1058
1059 if (read_socket_hook) 1059 if (noninteractive || read_socket_hook)
1060 return; 1060 return;
1061 1061
1062 ioctl (input_fd, FIOASYNC, &off); 1062 ioctl (input_fd, FIOASYNC, &off);
@@ -1075,7 +1075,7 @@ request_sigio ()
1075 int on = 1; 1075 int on = 1;
1076 sigset_t st; 1076 sigset_t st;
1077 1077
1078 if (read_socket_hook) 1078 if (noninteractive || read_socket_hook)
1079 return; 1079 return;
1080 1080
1081 sigemptyset (&st); 1081 sigemptyset (&st);
@@ -1090,7 +1090,7 @@ unrequest_sigio ()
1090{ 1090{
1091 int off = 0; 1091 int off = 0;
1092 1092
1093 if (read_socket_hook) 1093 if (noninteractive || read_socket_hook)
1094 return; 1094 return;
1095 1095
1096 ioctl (input_fd, FIOASYNC, &off); 1096 ioctl (input_fd, FIOASYNC, &off);
@@ -1103,7 +1103,7 @@ unrequest_sigio ()
1103void 1103void
1104request_sigio () 1104request_sigio ()
1105{ 1105{
1106 if (read_socket_hook) 1106 if (noninteractive || read_socket_hook)
1107 return; 1107 return;
1108 1108
1109 croak ("request_sigio"); 1109 croak ("request_sigio");
@@ -1112,7 +1112,7 @@ request_sigio ()
1112void 1112void
1113unrequest_sigio () 1113unrequest_sigio ()
1114{ 1114{
1115 if (read_socket_hook) 1115 if (noninteractive || read_socket_hook)
1116 return; 1116 return;
1117 1117
1118 croak ("unrequest_sigio"); 1118 croak ("unrequest_sigio");
@@ -2235,12 +2235,16 @@ reset_sigio ()
2235void 2235void
2236request_sigio () 2236request_sigio ()
2237{ 2237{
2238 if (noninteractive)
2239 return;
2238 croak ("request sigio"); 2240 croak ("request sigio");
2239} 2241}
2240 2242
2241void 2243void
2242unrequest_sigio () 2244unrequest_sigio ()
2243{ 2245{
2246 if (noninteractive)
2247 return;
2244 croak ("unrequest sigio"); 2248 croak ("unrequest sigio");
2245} 2249}
2246 2250
@@ -2775,6 +2779,8 @@ reset_sigio ()
2775void 2779void
2776request_sigio () 2780request_sigio ()
2777{ 2781{
2782 if (noninteractive)
2783 return;
2778 sigrelse (SIGTINT); 2784 sigrelse (SIGTINT);
2779 2785
2780 interrupts_deferred = 0; 2786 interrupts_deferred = 0;
@@ -2783,6 +2789,8 @@ request_sigio ()
2783void 2789void
2784unrequest_sigio () 2790unrequest_sigio ()
2785{ 2791{
2792 if (noninteractive)
2793 return;
2786 sighold (SIGTINT); 2794 sighold (SIGTINT);
2787 2795
2788 interrupts_deferred = 1; 2796 interrupts_deferred = 1;
diff --git a/src/w32term.c b/src/w32term.c
index f0d5dc507ac..75a4151e8f2 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1718,7 +1718,7 @@ x_draw_glyph_string_foreground (s)
1718 else 1718 else
1719 x = s->x; 1719 x = s->x;
1720 1720
1721 if (s->for_overlaps_p || (s->background_filled_p && s->hl != DRAW_CURSOR)) 1721 if (s->for_overlaps || (s->background_filled_p && s->hl != DRAW_CURSOR))
1722 SetBkMode (s->hdc, TRANSPARENT); 1722 SetBkMode (s->hdc, TRANSPARENT);
1723 else 1723 else
1724 SetBkMode (s->hdc, OPAQUE); 1724 SetBkMode (s->hdc, OPAQUE);
@@ -2599,7 +2599,7 @@ x_draw_glyph_string (s)
2599 /* If S draws into the background of its successor, draw the 2599 /* If S draws into the background of its successor, draw the
2600 background of the successor first so that S can draw into it. 2600 background of the successor first so that S can draw into it.
2601 This makes S->next use XDrawString instead of XDrawImageString. */ 2601 This makes S->next use XDrawString instead of XDrawImageString. */
2602 if (s->next && s->right_overhang && !s->for_overlaps_p) 2602 if (s->next && s->right_overhang && !s->for_overlaps)
2603 { 2603 {
2604 xassert (s->next->img == NULL); 2604 xassert (s->next->img == NULL);
2605 x_set_glyph_string_gc (s->next); 2605 x_set_glyph_string_gc (s->next);
@@ -2612,7 +2612,7 @@ x_draw_glyph_string (s)
2612 2612
2613 /* Draw relief (if any) in advance for char/composition so that the 2613 /* Draw relief (if any) in advance for char/composition so that the
2614 glyph string can be drawn over it. */ 2614 glyph string can be drawn over it. */
2615 if (!s->for_overlaps_p 2615 if (!s->for_overlaps
2616 && s->face->box != FACE_NO_BOX 2616 && s->face->box != FACE_NO_BOX
2617 && (s->first_glyph->type == CHAR_GLYPH 2617 && (s->first_glyph->type == CHAR_GLYPH
2618 || s->first_glyph->type == COMPOSITE_GLYPH)) 2618 || s->first_glyph->type == COMPOSITE_GLYPH))
@@ -2638,7 +2638,7 @@ x_draw_glyph_string (s)
2638 break; 2638 break;
2639 2639
2640 case CHAR_GLYPH: 2640 case CHAR_GLYPH:
2641 if (s->for_overlaps_p) 2641 if (s->for_overlaps)
2642 s->background_filled_p = 1; 2642 s->background_filled_p = 1;
2643 else 2643 else
2644 x_draw_glyph_string_background (s, 0); 2644 x_draw_glyph_string_background (s, 0);
@@ -2646,7 +2646,7 @@ x_draw_glyph_string (s)
2646 break; 2646 break;
2647 2647
2648 case COMPOSITE_GLYPH: 2648 case COMPOSITE_GLYPH:
2649 if (s->for_overlaps_p || s->gidx > 0) 2649 if (s->for_overlaps || s->gidx > 0)
2650 s->background_filled_p = 1; 2650 s->background_filled_p = 1;
2651 else 2651 else
2652 x_draw_glyph_string_background (s, 1); 2652 x_draw_glyph_string_background (s, 1);
@@ -2657,7 +2657,7 @@ x_draw_glyph_string (s)
2657 abort (); 2657 abort ();
2658 } 2658 }
2659 2659
2660 if (!s->for_overlaps_p) 2660 if (!s->for_overlaps)
2661 { 2661 {
2662 /* Draw underline. */ 2662 /* Draw underline. */
2663 if (s->face->underline_p 2663 if (s->face->underline_p
@@ -3355,9 +3355,7 @@ construct_drag_n_drop (result, msg, f)
3355static MSG last_mouse_motion_event; 3355static MSG last_mouse_motion_event;
3356static Lisp_Object last_mouse_motion_frame; 3356static Lisp_Object last_mouse_motion_frame;
3357 3357
3358static void remember_mouse_glyph P_ ((struct frame *, int, int)); 3358static int
3359
3360static void
3361note_mouse_movement (frame, msg) 3359note_mouse_movement (frame, msg)
3362 FRAME_PTR frame; 3360 FRAME_PTR frame;
3363 MSG *msg; 3361 MSG *msg;
@@ -3374,13 +3372,14 @@ note_mouse_movement (frame, msg)
3374 frame->mouse_moved = 1; 3372 frame->mouse_moved = 1;
3375 last_mouse_scroll_bar = Qnil; 3373 last_mouse_scroll_bar = Qnil;
3376 note_mouse_highlight (frame, -1, -1); 3374 note_mouse_highlight (frame, -1, -1);
3375 return 1;
3377 } 3376 }
3378 3377
3379 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3378 /* Has the mouse moved off the glyph it was on at the last sighting? */
3380 else if (mouse_x < last_mouse_glyph.left 3379 if (mouse_x < last_mouse_glyph.left
3381 || mouse_x > last_mouse_glyph.right 3380 || mouse_x >= last_mouse_glyph.right
3382 || mouse_y < last_mouse_glyph.top 3381 || mouse_y < last_mouse_glyph.top
3383 || mouse_y > last_mouse_glyph.bottom) 3382 || mouse_y >= last_mouse_glyph.bottom)
3384 { 3383 {
3385 frame->mouse_moved = 1; 3384 frame->mouse_moved = 1;
3386 last_mouse_scroll_bar = Qnil; 3385 last_mouse_scroll_bar = Qnil;
@@ -3389,8 +3388,11 @@ note_mouse_movement (frame, msg)
3389 gets called when mouse tracking is enabled but we also need 3388 gets called when mouse tracking is enabled but we also need
3390 to keep track of the mouse for help_echo and highlighting at 3389 to keep track of the mouse for help_echo and highlighting at
3391 other times. */ 3390 other times. */
3392 remember_mouse_glyph (frame, mouse_x, mouse_y); 3391 remember_mouse_glyph (frame, mouse_x, mouse_y, &last_mouse_glyph);
3392 return 1;
3393 } 3393 }
3394
3395 return 0;
3394} 3396}
3395 3397
3396 3398
@@ -3401,8 +3403,6 @@ note_mouse_movement (frame, msg)
3401static struct scroll_bar *x_window_to_scroll_bar (); 3403static struct scroll_bar *x_window_to_scroll_bar ();
3402static void x_scroll_bar_report_motion (); 3404static void x_scroll_bar_report_motion ();
3403static void x_check_fullscreen P_ ((struct frame *)); 3405static void x_check_fullscreen P_ ((struct frame *));
3404static int glyph_rect P_ ((struct frame *f, int, int, RECT *));
3405
3406 3406
3407static void 3407static void
3408redo_mouse_highlight () 3408redo_mouse_highlight ()
@@ -3421,108 +3421,6 @@ w32_define_cursor (window, cursor)
3421{ 3421{
3422 PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0); 3422 PostMessage (window, WM_EMACS_SETCURSOR, (WPARAM) cursor, 0);
3423} 3423}
3424
3425/* Try to determine frame pixel position and size of the glyph under
3426 frame pixel coordinates X/Y on frame F . Return the position and
3427 size in *RECT. Value is non-zero if we could compute these
3428 values. */
3429
3430static int
3431glyph_rect (f, x, y, rect)
3432 struct frame *f;
3433 int x, y;
3434 RECT *rect;
3435{
3436 Lisp_Object window;
3437
3438 window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
3439
3440 if (!NILP (window))
3441 {
3442 struct window *w = XWINDOW (window);
3443 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
3444 struct glyph_row *end = r + w->current_matrix->nrows - 1;
3445
3446 for (; r < end && r->enabled_p; ++r)
3447 if (r->y <= y && r->y + r->height > y)
3448 {
3449 /* Found the row at y. */
3450 struct glyph *g = r->glyphs[TEXT_AREA];
3451 struct glyph *end = g + r->used[TEXT_AREA];
3452 int gx;
3453
3454 rect->top = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
3455 rect->bottom = rect->top + r->height;
3456
3457 if (x < r->x)
3458 {
3459 /* x is to the left of the first glyph in the row. */
3460 /* Shouldn't this be a pixel value?
3461 WINDOW_LEFT_EDGE_X (w) seems to be the right value.
3462 ++KFS */
3463 rect->left = WINDOW_LEFT_EDGE_COL (w);
3464 rect->right = WINDOW_TO_FRAME_PIXEL_X (w, r->x);
3465 return 1;
3466 }
3467
3468 for (gx = r->x; g < end; gx += g->pixel_width, ++g)
3469 if (gx <= x && gx + g->pixel_width > x)
3470 {
3471 /* x is on a glyph. */
3472 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3473 rect->right = rect->left + g->pixel_width;
3474 return 1;
3475 }
3476
3477 /* x is to the right of the last glyph in the row. */
3478 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3479 /* Shouldn't this be a pixel value?
3480 WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
3481 ++KFS */
3482 rect->right = WINDOW_RIGHT_EDGE_COL (w);
3483 return 1;
3484 }
3485 }
3486
3487 /* The y is not on any row. */
3488 return 0;
3489}
3490
3491/* Record the position of the mouse in last_mouse_glyph. */
3492static void
3493remember_mouse_glyph (f1, gx, gy)
3494 struct frame * f1;
3495 int gx, gy;
3496{
3497 if (!glyph_rect (f1, gx, gy, &last_mouse_glyph))
3498 {
3499 int width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3500 int height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3501
3502 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3503 round down even for negative values. */
3504 if (gx < 0)
3505 gx -= width - 1;
3506 if (gy < 0)
3507 gy -= height - 1;
3508#if 0
3509 /* This was the original code from XTmouse_position, but it seems
3510 to give the position of the glyph diagonally next to the one
3511 the mouse is over. */
3512 gx = (gx + width - 1) / width * width;
3513 gy = (gy + height - 1) / height * height;
3514#else
3515 gx = gx / width * width;
3516 gy = gy / height * height;
3517#endif
3518
3519 last_mouse_glyph.left = gx;
3520 last_mouse_glyph.top = gy;
3521 last_mouse_glyph.right = gx + width;
3522 last_mouse_glyph.bottom = gy + height;
3523 }
3524}
3525
3526/* Return the current position of the mouse. 3424/* Return the current position of the mouse.
3527 *fp should be a frame which indicates which display to ask about. 3425 *fp should be a frame which indicates which display to ask about.
3528 3426
@@ -3625,7 +3523,7 @@ w32_mouse_position (fp, insist, bar_window, part, x, y, time)
3625 || insist); 3523 || insist);
3626#else 3524#else
3627 ScreenToClient (FRAME_W32_WINDOW (f1), &pt); 3525 ScreenToClient (FRAME_W32_WINDOW (f1), &pt);
3628 remember_mouse_glyph (f1, pt.x, pt.y); 3526 remember_mouse_glyph (f1, pt.x, pt.y, &last_mouse_glyph);
3629#endif 3527#endif
3630 3528
3631 *bar_window = Qnil; 3529 *bar_window = Qnil;
@@ -4571,6 +4469,7 @@ w32_read_socket (sd, expected, hold_quit)
4571 } 4469 }
4572 4470
4573 previous_help_echo_string = help_echo_string; 4471 previous_help_echo_string = help_echo_string;
4472 help_echo_string = Qnil;
4574 4473
4575 if (dpyinfo->grabbed && last_mouse_frame 4474 if (dpyinfo->grabbed && last_mouse_frame
4576 && FRAME_LIVE_P (last_mouse_frame)) 4475 && FRAME_LIVE_P (last_mouse_frame))
@@ -4609,7 +4508,8 @@ w32_read_socket (sd, expected, hold_quit)
4609 4508
4610 last_window=window; 4509 last_window=window;
4611 } 4510 }
4612 note_mouse_movement (f, &msg.msg); 4511 if (!note_mouse_movement (f, &msg.msg))
4512 help_echo_string = previous_help_echo_string;
4613 } 4513 }
4614 else 4514 else
4615 { 4515 {
diff --git a/src/window.c b/src/window.c
index 9a0d256cdce..50212b0c114 100644
--- a/src/window.c
+++ b/src/window.c
@@ -682,7 +682,10 @@ coordinates_in_window (w, x, y)
682 682
683 /* Outside any interesting column? */ 683 /* Outside any interesting column? */
684 if (*x < left_x || *x > right_x) 684 if (*x < left_x || *x > right_x)
685 return ON_SCROLL_BAR; 685 {
686 *y -= top_y;
687 return ON_SCROLL_BAR;
688 }
686 689
687 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA); 690 lmargin_width = window_box_width (w, LEFT_MARGIN_AREA);
688 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA); 691 rmargin_width = window_box_width (w, RIGHT_MARGIN_AREA);
@@ -739,9 +742,9 @@ coordinates_in_window (w, x, y)
739 ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w)) 742 ? (*x < right_x - WINDOW_RIGHT_FRINGE_WIDTH (w))
740 : (*x >= right_x - rmargin_width))) 743 : (*x >= right_x - rmargin_width)))
741 { 744 {
742 *x -= right_x; 745 *x -= right_x - rmargin_width;
743 if (!WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)) 746 if (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w))
744 *x -= WINDOW_RIGHT_FRINGE_WIDTH (w); 747 *x += WINDOW_RIGHT_FRINGE_WIDTH (w);
745 *y -= top_y; 748 *y -= top_y;
746 return ON_RIGHT_MARGIN; 749 return ON_RIGHT_MARGIN;
747 } 750 }
@@ -753,7 +756,7 @@ coordinates_in_window (w, x, y)
753 } 756 }
754 757
755 /* Everything special ruled out - must be on text area */ 758 /* Everything special ruled out - must be on text area */
756 *x -= left_x + WINDOW_LEFT_FRINGE_WIDTH (w); 759 *x -= text_left;
757 *y -= top_y; 760 *y -= top_y;
758 return ON_TEXT; 761 return ON_TEXT;
759} 762}
@@ -1029,7 +1032,8 @@ if it isn't already recorded. */)
1029 1032
1030 if (! NILP (update) 1033 if (! NILP (update)
1031 && ! (! NILP (w->window_end_valid) 1034 && ! (! NILP (w->window_end_valid)
1032 && XFASTINT (w->last_modified) >= MODIFF)) 1035 && XFASTINT (w->last_modified) >= MODIFF)
1036 && !noninteractive)
1033 { 1037 {
1034 struct text_pos startp; 1038 struct text_pos startp;
1035 struct it it; 1039 struct it it;
@@ -6232,7 +6236,7 @@ usage: (save-window-excursion BODY ...) */)
6232 ***********************************************************************/ 6236 ***********************************************************************/
6233 6237
6234static Lisp_Object 6238static Lisp_Object
6235window_split_tree (w) 6239window_tree (w)
6236 struct window *w; 6240 struct window *w;
6237{ 6241{
6238 Lisp_Object tail = Qnil; 6242 Lisp_Object tail = Qnil;
@@ -6245,10 +6249,10 @@ window_split_tree (w)
6245 XSETWINDOW (wn, w); 6249 XSETWINDOW (wn, w);
6246 if (!NILP (w->hchild)) 6250 if (!NILP (w->hchild))
6247 wn = Fcons (Qnil, Fcons (Fwindow_edges (wn), 6251 wn = Fcons (Qnil, Fcons (Fwindow_edges (wn),
6248 window_split_tree (XWINDOW (w->hchild)))); 6252 window_tree (XWINDOW (w->hchild))));
6249 else if (!NILP (w->vchild)) 6253 else if (!NILP (w->vchild))
6250 wn = Fcons (Qt, Fcons (Fwindow_edges (wn), 6254 wn = Fcons (Qt, Fcons (Fwindow_edges (wn),
6251 window_split_tree (XWINDOW (w->vchild)))); 6255 window_tree (XWINDOW (w->vchild))));
6252 6256
6253 if (NILP (result)) 6257 if (NILP (result))
6254 { 6258 {
@@ -6268,17 +6272,17 @@ window_split_tree (w)
6268 6272
6269 6273
6270 6274
6271DEFUN ("window-split-tree", Fwindow_split_tree, Swindow_split_tree, 6275DEFUN ("window-tree", Fwindow_tree, Swindow_tree,
6272 0, 1, 0, 6276 0, 1, 0,
6273 doc: /* Return the window split tree for frame FRAME. 6277 doc: /* Return the window tree for frame FRAME.
6274 6278
6275The return value is a list of the form (ROOT MINI), where ROOT 6279The return value is a list of the form (ROOT MINI), where ROOT
6276represents the window split tree of the frame's root window, and MINI 6280represents the window tree of the frame's root window, and MINI
6277is the frame's minibuffer window. 6281is the frame's minibuffer window.
6278 6282
6279If the root window is not split, ROOT is the root window itself. 6283If the root window is not split, ROOT is the root window itself.
6280Otherwise, ROOT is a list (DIR EDGES W1 W2 ...) where DIR is nil for a 6284Otherwise, ROOT is a list (DIR EDGES W1 W2 ...) where DIR is nil for a
6281horisontal split, and t for a vertical split, EDGES gives the combined 6285horizontal split, and t for a vertical split, EDGES gives the combined
6282size and position of the subwindows in the split, and the rest of the 6286size and position of the subwindows in the split, and the rest of the
6283elements are the subwindows in the split. Each of the subwindows may 6287elements are the subwindows in the split. Each of the subwindows may
6284again be a window or a list representing a window split, and so on. 6288again be a window or a list representing a window split, and so on.
@@ -6301,7 +6305,7 @@ selected frame. */)
6301 if (!FRAME_LIVE_P (f)) 6305 if (!FRAME_LIVE_P (f))
6302 return Qnil; 6306 return Qnil;
6303 6307
6304 return window_split_tree (XWINDOW (FRAME_ROOT_WINDOW (f))); 6308 return window_tree (XWINDOW (FRAME_ROOT_WINDOW (f)));
6305} 6309}
6306 6310
6307 6311
@@ -7110,7 +7114,7 @@ The selected frame is the one whose configuration has changed. */);
7110 defsubr (&Sset_window_configuration); 7114 defsubr (&Sset_window_configuration);
7111 defsubr (&Scurrent_window_configuration); 7115 defsubr (&Scurrent_window_configuration);
7112 defsubr (&Ssave_window_excursion); 7116 defsubr (&Ssave_window_excursion);
7113 defsubr (&Swindow_split_tree); 7117 defsubr (&Swindow_tree);
7114 defsubr (&Sset_window_margins); 7118 defsubr (&Sset_window_margins);
7115 defsubr (&Swindow_margins); 7119 defsubr (&Swindow_margins);
7116 defsubr (&Sset_window_fringes); 7120 defsubr (&Sset_window_fringes);
diff --git a/src/xdisp.c b/src/xdisp.c
index ef125409076..fd730075646 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1351,7 +1351,7 @@ pos_visible_p (w, charpos, x, y, rtop, rbot, exact_mode_line_heights_p)
1351 current_header_line_height = current_mode_line_height = -1; 1351 current_header_line_height = current_mode_line_height = -1;
1352 1352
1353 if (visible_p && XFASTINT (w->hscroll) > 0) 1353 if (visible_p && XFASTINT (w->hscroll) > 0)
1354 *x -= XFASTINT (w->hscroll); 1354 *x -= XFASTINT (w->hscroll) * WINDOW_FRAME_COLUMN_WIDTH (w);
1355 1355
1356 return visible_p; 1356 return visible_p;
1357} 1357}
@@ -1771,15 +1771,20 @@ frame_to_window_pixel_xy (w, x, y)
1771} 1771}
1772 1772
1773/* EXPORT: 1773/* EXPORT:
1774 Return in *R the clipping rectangle for glyph string S. */ 1774 Return in RECTS[] at most N clipping rectangles for glyph string S.
1775 Return the number of stored rectangles. */
1775 1776
1776void 1777int
1777get_glyph_string_clip_rect (s, nr) 1778get_glyph_string_clip_rects (s, rects, n)
1778 struct glyph_string *s; 1779 struct glyph_string *s;
1779 NativeRectangle *nr; 1780 NativeRectangle *rects;
1781 int n;
1780{ 1782{
1781 XRectangle r; 1783 XRectangle r;
1782 1784
1785 if (n <= 0)
1786 return 0;
1787
1783 if (s->row->full_width_p) 1788 if (s->row->full_width_p)
1784 { 1789 {
1785 /* Draw full-width. X coordinates are relative to S->w->left_col. */ 1790 /* Draw full-width. X coordinates are relative to S->w->left_col. */
@@ -1822,10 +1827,27 @@ get_glyph_string_clip_rect (s, nr)
1822 /* If S draws overlapping rows, it's sufficient to use the top and 1827 /* If S draws overlapping rows, it's sufficient to use the top and
1823 bottom of the window for clipping because this glyph string 1828 bottom of the window for clipping because this glyph string
1824 intentionally draws over other lines. */ 1829 intentionally draws over other lines. */
1825 if (s->for_overlaps_p) 1830 if (s->for_overlaps)
1826 { 1831 {
1827 r.y = WINDOW_HEADER_LINE_HEIGHT (s->w); 1832 r.y = WINDOW_HEADER_LINE_HEIGHT (s->w);
1828 r.height = window_text_bottom_y (s->w) - r.y; 1833 r.height = window_text_bottom_y (s->w) - r.y;
1834
1835 /* Alas, the above simple strategy does not work for the
1836 environments with anti-aliased text: if the same text is
1837 drawn onto the same place multiple times, it gets thicker.
1838 If the overlap we are processing is for the erased cursor, we
1839 take the intersection with the rectagle of the cursor. */
1840 if (s->for_overlaps & OVERLAPS_ERASED_CURSOR)
1841 {
1842 XRectangle rc, r_save = r;
1843
1844 rc.x = WINDOW_TEXT_TO_FRAME_PIXEL_X (s->w, s->w->phys_cursor.x);
1845 rc.y = s->w->phys_cursor.y;
1846 rc.width = s->w->phys_cursor_width;
1847 rc.height = s->w->phys_cursor_height;
1848
1849 x_intersect_rectangles (&r_save, &rc, &r);
1850 }
1829 } 1851 }
1830 else 1852 else
1831 { 1853 {
@@ -1884,11 +1906,71 @@ get_glyph_string_clip_rect (s, nr)
1884 } 1906 }
1885 } 1907 }
1886 1908
1909 if ((s->for_overlaps & OVERLAPS_BOTH) == 0
1910 || (s->for_overlaps & OVERLAPS_BOTH) == OVERLAPS_BOTH && n == 1)
1911 {
1887#ifdef CONVERT_FROM_XRECT 1912#ifdef CONVERT_FROM_XRECT
1888 CONVERT_FROM_XRECT (r, *nr); 1913 CONVERT_FROM_XRECT (r, *rects);
1889#else 1914#else
1890 *nr = r; 1915 *rects = r;
1891#endif 1916#endif
1917 return 1;
1918 }
1919 else
1920 {
1921 /* If we are processing overlapping and allowed to return
1922 multiple clipping rectangles, we exclude the row of the glyph
1923 string from the clipping rectangle. This is to avoid drawing
1924 the same text on the environment with anti-aliasing. */
1925#ifdef CONVERT_FROM_XRECT
1926 XRectangle rs[2];
1927#else
1928 XRectangle *rs = rects;
1929#endif
1930 int i = 0, row_y = WINDOW_TO_FRAME_PIXEL_Y (s->w, s->row->y);
1931
1932 if (s->for_overlaps & OVERLAPS_PRED)
1933 {
1934 rs[i] = r;
1935 if (r.y + r.height > row_y)
1936 if (r.y < row_y)
1937 rs[i].height = row_y - r.y;
1938 else
1939 rs[i].height = 0;
1940 i++;
1941 }
1942 if (s->for_overlaps & OVERLAPS_SUCC)
1943 {
1944 rs[i] = r;
1945 if (r.y < row_y + s->row->visible_height)
1946 if (r.y + r.height > row_y + s->row->visible_height)
1947 {
1948 rs[i].y = row_y + s->row->visible_height;
1949 rs[i].height = r.y + r.height - rs[i].y;
1950 }
1951 else
1952 rs[i].height = 0;
1953 i++;
1954 }
1955
1956 n = i;
1957#ifdef CONVERT_FROM_XRECT
1958 for (i = 0; i < n; i++)
1959 CONVERT_FROM_XRECT (rs[i], rects[i]);
1960#endif
1961 return n;
1962 }
1963}
1964
1965/* EXPORT:
1966 Return in *NR the clipping rectangle for glyph string S. */
1967
1968void
1969get_glyph_string_clip_rect (s, nr)
1970 struct glyph_string *s;
1971 NativeRectangle *nr;
1972{
1973 get_glyph_string_clip_rects (s, nr, 1);
1892} 1974}
1893 1975
1894 1976
@@ -1948,6 +2030,198 @@ get_phys_cursor_geometry (w, row, glyph, heightp)
1948 return WINDOW_TO_FRAME_PIXEL_Y (w, y); 2030 return WINDOW_TO_FRAME_PIXEL_Y (w, y);
1949} 2031}
1950 2032
2033/*
2034 * Remember which glyph the mouse is over.
2035 */
2036
2037void
2038remember_mouse_glyph (f, gx, gy, rect)
2039 struct frame *f;
2040 int gx, gy;
2041 NativeRectangle *rect;
2042{
2043 Lisp_Object window;
2044 struct window *w;
2045 struct glyph_row *r, *gr, *end_row;
2046 enum window_part part;
2047 enum glyph_row_area area;
2048 int x, y, width, height;
2049
2050 /* Try to determine frame pixel position and size of the glyph under
2051 frame pixel coordinates X/Y on frame F. */
2052
2053 window = window_from_coordinates (f, gx, gy, &part, &x, &y, 0);
2054 if (NILP (window))
2055 {
2056 width = FRAME_SMALLEST_CHAR_WIDTH (f);
2057 height = FRAME_SMALLEST_FONT_HEIGHT (f);
2058 goto virtual_glyph;
2059 }
2060
2061 w = XWINDOW (window);
2062 width = WINDOW_FRAME_COLUMN_WIDTH (w);
2063 height = WINDOW_FRAME_LINE_HEIGHT (w);
2064
2065 r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
2066 end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
2067
2068 if (w->pseudo_window_p)
2069 {
2070 area = TEXT_AREA;
2071 part = ON_MODE_LINE; /* Don't adjust margin. */
2072 goto text_glyph;
2073 }
2074
2075 switch (part)
2076 {
2077 case ON_LEFT_MARGIN:
2078 area = LEFT_MARGIN_AREA;
2079 goto text_glyph;
2080
2081 case ON_RIGHT_MARGIN:
2082 area = RIGHT_MARGIN_AREA;
2083 goto text_glyph;
2084
2085 case ON_HEADER_LINE:
2086 case ON_MODE_LINE:
2087 gr = (part == ON_HEADER_LINE
2088 ? MATRIX_HEADER_LINE_ROW (w->current_matrix)
2089 : MATRIX_MODE_LINE_ROW (w->current_matrix));
2090 gy = gr->y;
2091 area = TEXT_AREA;
2092 goto text_glyph_row_found;
2093
2094 case ON_TEXT:
2095 area = TEXT_AREA;
2096
2097 text_glyph:
2098 gr = 0; gy = 0;
2099 for (; r <= end_row && r->enabled_p; ++r)
2100 if (r->y + r->height > y)
2101 {
2102 gr = r; gy = r->y;
2103 break;
2104 }
2105
2106 text_glyph_row_found:
2107 if (gr && gy <= y)
2108 {
2109 struct glyph *g = gr->glyphs[area];
2110 struct glyph *end = g + gr->used[area];
2111
2112 height = gr->height;
2113 for (gx = gr->x; g < end; gx += g->pixel_width, ++g)
2114 if (gx + g->pixel_width > x)
2115 break;
2116
2117 if (g < end)
2118 {
2119 if (g->type == IMAGE_GLYPH)
2120 {
2121 /* Don't remember when mouse is over image, as
2122 image may have hot-spots. */
2123 STORE_NATIVE_RECT (*rect, 0, 0, 0, 0);
2124 return;
2125 }
2126 width = g->pixel_width;
2127 }
2128 else
2129 {
2130 /* Use nominal char spacing at end of line. */
2131 x -= gx;
2132 gx += (x / width) * width;
2133 }
2134
2135 if (part != ON_MODE_LINE && part != ON_HEADER_LINE)
2136 gx += window_box_left_offset (w, area);
2137 }
2138 else
2139 {
2140 /* Use nominal line height at end of window. */
2141 gx = (x / width) * width;
2142 y -= gy;
2143 gy += (y / height) * height;
2144 }
2145 break;
2146
2147 case ON_LEFT_FRINGE:
2148 gx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
2149 ? WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w)
2150 : window_box_right_offset (w, LEFT_MARGIN_AREA));
2151 width = WINDOW_LEFT_FRINGE_WIDTH (w);
2152 goto row_glyph;
2153
2154 case ON_RIGHT_FRINGE:
2155 gx = (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
2156 ? window_box_right_offset (w, RIGHT_MARGIN_AREA)
2157 : window_box_right_offset (w, TEXT_AREA));
2158 width = WINDOW_RIGHT_FRINGE_WIDTH (w);
2159 goto row_glyph;
2160
2161 case ON_SCROLL_BAR:
2162 gx = (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)
2163 ? 0
2164 : (window_box_right_offset (w, RIGHT_MARGIN_AREA)
2165 + (WINDOW_HAS_FRINGES_OUTSIDE_MARGINS (w)
2166 ? WINDOW_RIGHT_FRINGE_WIDTH (w)
2167 : 0)));
2168 width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
2169
2170 row_glyph:
2171 gr = 0, gy = 0;
2172 for (; r <= end_row && r->enabled_p; ++r)
2173 if (r->y + r->height > y)
2174 {
2175 gr = r; gy = r->y;
2176 break;
2177 }
2178
2179 if (gr && gy <= y)
2180 height = gr->height;
2181 else
2182 {
2183 /* Use nominal line height at end of window. */
2184 y -= gy;
2185 gy += (y / height) * height;
2186 }
2187 break;
2188
2189 default:
2190 ;
2191 virtual_glyph:
2192 /* If there is no glyph under the mouse, then we divide the screen
2193 into a grid of the smallest glyph in the frame, and use that
2194 as our "glyph". */
2195
2196 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
2197 round down even for negative values. */
2198 if (gx < 0)
2199 gx -= width - 1;
2200 if (gy < 0)
2201 gy -= height - 1;
2202
2203 gx = (gx / width) * width;
2204 gy = (gy / height) * height;
2205
2206 goto store_rect;
2207 }
2208
2209 gx += WINDOW_LEFT_EDGE_X (w);
2210 gy += WINDOW_TOP_EDGE_Y (w);
2211
2212 store_rect:
2213 STORE_NATIVE_RECT (*rect, gx, gy, width, height);
2214
2215 /* Visible feedback for debugging. */
2216#if 0
2217#if HAVE_X_WINDOWS
2218 XDrawRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2219 f->output_data.x->normal_gc,
2220 gx, gy, width, height);
2221#endif
2222#endif
2223}
2224
1951 2225
1952#endif /* HAVE_WINDOW_SYSTEM */ 2226#endif /* HAVE_WINDOW_SYSTEM */
1953 2227
@@ -18122,22 +18396,23 @@ get_glyph_face_and_encoding (f, glyph, char2b, two_byte_p)
18122 18396
18123 FACES is an array of faces for all components of this composition. 18397 FACES is an array of faces for all components of this composition.
18124 S->gidx is the index of the first component for S. 18398 S->gidx is the index of the first component for S.
18125 OVERLAPS_P non-zero means S should draw the foreground only, and 18399
18126 use its physical height for clipping. 18400 OVERLAPS non-zero means S should draw the foreground only, and use
18401 its physical height for clipping. See also draw_glyphs.
18127 18402
18128 Value is the index of a component not in S. */ 18403 Value is the index of a component not in S. */
18129 18404
18130static int 18405static int
18131fill_composite_glyph_string (s, faces, overlaps_p) 18406fill_composite_glyph_string (s, faces, overlaps)
18132 struct glyph_string *s; 18407 struct glyph_string *s;
18133 struct face **faces; 18408 struct face **faces;
18134 int overlaps_p; 18409 int overlaps;
18135{ 18410{
18136 int i; 18411 int i;
18137 18412
18138 xassert (s); 18413 xassert (s);
18139 18414
18140 s->for_overlaps_p = overlaps_p; 18415 s->for_overlaps = overlaps;
18141 18416
18142 s->face = faces[s->gidx]; 18417 s->face = faces[s->gidx];
18143 s->font = s->face->font; 18418 s->font = s->face->font;
@@ -18181,16 +18456,16 @@ fill_composite_glyph_string (s, faces, overlaps_p)
18181 18456
18182 FACE_ID is the face id of the string. START is the index of the 18457 FACE_ID is the face id of the string. START is the index of the
18183 first glyph to consider, END is the index of the last + 1. 18458 first glyph to consider, END is the index of the last + 1.
18184 OVERLAPS_P non-zero means S should draw the foreground only, and 18459 OVERLAPS non-zero means S should draw the foreground only, and use
18185 use its physical height for clipping. 18460 its physical height for clipping. See also draw_glyphs.
18186 18461
18187 Value is the index of the first glyph not in S. */ 18462 Value is the index of the first glyph not in S. */
18188 18463
18189static int 18464static int
18190fill_glyph_string (s, face_id, start, end, overlaps_p) 18465fill_glyph_string (s, face_id, start, end, overlaps)
18191 struct glyph_string *s; 18466 struct glyph_string *s;
18192 int face_id; 18467 int face_id;
18193 int start, end, overlaps_p; 18468 int start, end, overlaps;
18194{ 18469{
18195 struct glyph *glyph, *last; 18470 struct glyph *glyph, *last;
18196 int voffset; 18471 int voffset;
@@ -18200,7 +18475,7 @@ fill_glyph_string (s, face_id, start, end, overlaps_p)
18200 xassert (s->nchars == 0); 18475 xassert (s->nchars == 0);
18201 xassert (start >= 0 && end > start); 18476 xassert (start >= 0 && end > start);
18202 18477
18203 s->for_overlaps_p = overlaps_p, 18478 s->for_overlaps = overlaps,
18204 glyph = s->row->glyphs[s->area] + start; 18479 glyph = s->row->glyphs[s->area] + start;
18205 last = s->row->glyphs[s->area] + end; 18480 last = s->row->glyphs[s->area] + end;
18206 voffset = glyph->voffset; 18481 voffset = glyph->voffset;
@@ -18676,7 +18951,7 @@ compute_overhangs_and_x (s, x, backward_p)
18676 INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \ 18951 INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL); \
18677 append_glyph_string (&HEAD, &TAIL, s); \ 18952 append_glyph_string (&HEAD, &TAIL, s); \
18678 s->x = (X); \ 18953 s->x = (X); \
18679 START = fill_glyph_string (s, face_id, START, END, overlaps_p); \ 18954 START = fill_glyph_string (s, face_id, START, END, overlaps); \
18680 } \ 18955 } \
18681 while (0) 18956 while (0)
18682 18957
@@ -18729,7 +19004,7 @@ compute_overhangs_and_x (s, x, backward_p)
18729 if (n == 0) \ 19004 if (n == 0) \
18730 first_s = s; \ 19005 first_s = s; \
18731 \ 19006 \
18732 n = fill_composite_glyph_string (s, faces, overlaps_p); \ 19007 n = fill_composite_glyph_string (s, faces, overlaps); \
18733 } \ 19008 } \
18734 \ 19009 \
18735 ++START; \ 19010 ++START; \
@@ -18801,20 +19076,26 @@ compute_overhangs_and_x (s, x, backward_p)
18801 DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it 19076 DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it
18802 DRAW_IMAGE_RAISED draw an image with a raised relief around it 19077 DRAW_IMAGE_RAISED draw an image with a raised relief around it
18803 19078
18804 If OVERLAPS_P is non-zero, draw only the foreground of characters 19079 If OVERLAPS is non-zero, draw only the foreground of characters and
18805 and clip to the physical height of ROW. 19080 clip to the physical height of ROW. Non-zero value also defines
19081 the overlapping part to be drawn:
19082
19083 OVERLAPS_PRED overlap with preceding rows
19084 OVERLAPS_SUCC overlap with succeeding rows
19085 OVERLAPS_BOTH overlap with both preceding/succeeding rows
19086 OVERLAPS_ERASED_CURSOR overlap with erased cursor area
18806 19087
18807 Value is the x-position reached, relative to AREA of W. */ 19088 Value is the x-position reached, relative to AREA of W. */
18808 19089
18809static int 19090static int
18810draw_glyphs (w, x, row, area, start, end, hl, overlaps_p) 19091draw_glyphs (w, x, row, area, start, end, hl, overlaps)
18811 struct window *w; 19092 struct window *w;
18812 int x; 19093 int x;
18813 struct glyph_row *row; 19094 struct glyph_row *row;
18814 enum glyph_row_area area; 19095 enum glyph_row_area area;
18815 EMACS_INT start, end; 19096 EMACS_INT start, end;
18816 enum draw_glyphs_face hl; 19097 enum draw_glyphs_face hl;
18817 int overlaps_p; 19098 int overlaps;
18818{ 19099{
18819 struct glyph_string *head, *tail; 19100 struct glyph_string *head, *tail;
18820 struct glyph_string *s; 19101 struct glyph_string *s;
@@ -18863,7 +19144,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
18863 /* If there are any glyphs with lbearing < 0 or rbearing > width in 19144 /* If there are any glyphs with lbearing < 0 or rbearing > width in
18864 the row, redraw some glyphs in front or following the glyph 19145 the row, redraw some glyphs in front or following the glyph
18865 strings built above. */ 19146 strings built above. */
18866 if (head && !overlaps_p && row->contains_overlapping_glyphs_p) 19147 if (head && !overlaps && row->contains_overlapping_glyphs_p)
18867 { 19148 {
18868 int dummy_x = 0; 19149 int dummy_x = 0;
18869 struct glyph_string *h, *t; 19150 struct glyph_string *h, *t;
@@ -18956,7 +19237,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
18956 /* When drawing overlapping rows, only the glyph strings' 19237 /* When drawing overlapping rows, only the glyph strings'
18957 foreground is drawn, which doesn't erase a cursor 19238 foreground is drawn, which doesn't erase a cursor
18958 completely. */ 19239 completely. */
18959 && !overlaps_p) 19240 && !overlaps)
18960 { 19241 {
18961 int x0 = clip_head ? clip_head->x : (head ? head->x : x); 19242 int x0 = clip_head ? clip_head->x : (head ? head->x : x);
18962 int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width 19243 int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width
@@ -20729,13 +21010,15 @@ notice_overwritten_cursor (w, area, x0, x1, y0, y1)
20729#ifdef HAVE_WINDOW_SYSTEM 21010#ifdef HAVE_WINDOW_SYSTEM
20730 21011
20731/* EXPORT for RIF: 21012/* EXPORT for RIF:
20732 Fix the display of area AREA of overlapping row ROW in window W. */ 21013 Fix the display of area AREA of overlapping row ROW in window W
21014 with respect to the overlapping part OVERLAPS. */
20733 21015
20734void 21016void
20735x_fix_overlapping_area (w, row, area) 21017x_fix_overlapping_area (w, row, area, overlaps)
20736 struct window *w; 21018 struct window *w;
20737 struct glyph_row *row; 21019 struct glyph_row *row;
20738 enum glyph_row_area area; 21020 enum glyph_row_area area;
21021 int overlaps;
20739{ 21022{
20740 int i, x; 21023 int i, x;
20741 21024
@@ -20758,7 +21041,7 @@ x_fix_overlapping_area (w, row, area)
20758 21041
20759 draw_glyphs (w, start_x, row, area, 21042 draw_glyphs (w, start_x, row, area,
20760 start, i, 21043 start, i,
20761 DRAW_NORMAL_TEXT, 1); 21044 DRAW_NORMAL_TEXT, overlaps);
20762 } 21045 }
20763 else 21046 else
20764 { 21047 {
@@ -20800,13 +21083,17 @@ draw_phys_cursor_glyph (w, row, hl)
20800 are redrawn. */ 21083 are redrawn. */
20801 else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p) 21084 else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p)
20802 { 21085 {
21086 w->phys_cursor_width = x1 - w->phys_cursor.x;
21087
20803 if (row > w->current_matrix->rows 21088 if (row > w->current_matrix->rows
20804 && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1)) 21089 && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1))
20805 x_fix_overlapping_area (w, row - 1, TEXT_AREA); 21090 x_fix_overlapping_area (w, row - 1, TEXT_AREA,
21091 OVERLAPS_ERASED_CURSOR);
20806 21092
20807 if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w) 21093 if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w)
20808 && MATRIX_ROW_OVERLAPS_PRED_P (row + 1)) 21094 && MATRIX_ROW_OVERLAPS_PRED_P (row + 1))
20809 x_fix_overlapping_area (w, row + 1, TEXT_AREA); 21095 x_fix_overlapping_area (w, row + 1, TEXT_AREA,
21096 OVERLAPS_ERASED_CURSOR);
20810 } 21097 }
20811 } 21098 }
20812} 21099}
@@ -22597,13 +22884,13 @@ expose_overlaps (w, first_overlapping_row, last_overlapping_row)
22597 xassert (row->enabled_p && !row->mode_line_p); 22884 xassert (row->enabled_p && !row->mode_line_p);
22598 22885
22599 if (row->used[LEFT_MARGIN_AREA]) 22886 if (row->used[LEFT_MARGIN_AREA])
22600 x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA); 22887 x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA, OVERLAPS_BOTH);
22601 22888
22602 if (row->used[TEXT_AREA]) 22889 if (row->used[TEXT_AREA])
22603 x_fix_overlapping_area (w, row, TEXT_AREA); 22890 x_fix_overlapping_area (w, row, TEXT_AREA, OVERLAPS_BOTH);
22604 22891
22605 if (row->used[RIGHT_MARGIN_AREA]) 22892 if (row->used[RIGHT_MARGIN_AREA])
22606 x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA); 22893 x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, OVERLAPS_BOTH);
22607 } 22894 }
22608} 22895}
22609 22896
diff --git a/src/xfaces.c b/src/xfaces.c
index df8dc15f022..2c5f729f6c5 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -790,7 +790,10 @@ x_create_gc (f, mask, xgcv)
790 XGCValues *xgcv; 790 XGCValues *xgcv;
791{ 791{
792 GC gc; 792 GC gc;
793 BLOCK_INPUT;
793 gc = XCreateGC (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), mask, xgcv); 794 gc = XCreateGC (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), mask, xgcv);
795 UNBLOCK_INPUT;
796 IF_DEBUG (++ngcs);
794 return gc; 797 return gc;
795} 798}
796 799
@@ -799,7 +802,10 @@ x_free_gc (f, gc)
799 struct frame *f; 802 struct frame *f;
800 GC gc; 803 GC gc;
801{ 804{
805 BLOCK_INPUT;
806 IF_DEBUG (xassert (--ngcs >= 0));
802 XFreeGC (FRAME_MAC_DISPLAY (f), gc); 807 XFreeGC (FRAME_MAC_DISPLAY (f), gc);
808 UNBLOCK_INPUT;
803} 809}
804 810
805#endif /* MAC_OS */ 811#endif /* MAC_OS */
diff --git a/src/xfns.c b/src/xfns.c
index 027a1464503..a8640d72986 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3261,7 +3261,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3261 3261
3262 /* We need to do this after creating the X window, so that the 3262 /* We need to do this after creating the X window, so that the
3263 icon-creation functions can say whose icon they're describing. */ 3263 icon-creation functions can say whose icon they're describing. */
3264 x_default_parameter (f, parms, Qicon_type, Qnil, 3264 x_default_parameter (f, parms, Qicon_type, Qt,
3265 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL); 3265 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
3266 3266
3267 x_default_parameter (f, parms, Qauto_raise, Qnil, 3267 x_default_parameter (f, parms, Qauto_raise, Qnil,
diff --git a/src/xterm.c b/src/xterm.c
index 5b7d45fe228..ce46bd16f42 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1305,7 +1305,7 @@ x_draw_glyph_string_foreground (s)
1305 XDrawImageString is usually faster than XDrawString.) Always 1305 XDrawImageString is usually faster than XDrawString.) Always
1306 use XDrawImageString when drawing the cursor so that there is 1306 use XDrawImageString when drawing the cursor so that there is
1307 no chance that characters under a box cursor are invisible. */ 1307 no chance that characters under a box cursor are invisible. */
1308 if (s->for_overlaps_p 1308 if (s->for_overlaps
1309 || (s->background_filled_p && s->hl != DRAW_CURSOR)) 1309 || (s->background_filled_p && s->hl != DRAW_CURSOR))
1310 { 1310 {
1311 /* Draw characters with 16-bit or 8-bit functions. */ 1311 /* Draw characters with 16-bit or 8-bit functions. */
@@ -2610,7 +2610,7 @@ x_draw_glyph_string (s)
2610 /* If S draws into the background of its successor, draw the 2610 /* If S draws into the background of its successor, draw the
2611 background of the successor first so that S can draw into it. 2611 background of the successor first so that S can draw into it.
2612 This makes S->next use XDrawString instead of XDrawImageString. */ 2612 This makes S->next use XDrawString instead of XDrawImageString. */
2613 if (s->next && s->right_overhang && !s->for_overlaps_p) 2613 if (s->next && s->right_overhang && !s->for_overlaps)
2614 { 2614 {
2615 xassert (s->next->img == NULL); 2615 xassert (s->next->img == NULL);
2616 x_set_glyph_string_gc (s->next); 2616 x_set_glyph_string_gc (s->next);
@@ -2623,7 +2623,7 @@ x_draw_glyph_string (s)
2623 2623
2624 /* Draw relief (if any) in advance for char/composition so that the 2624 /* Draw relief (if any) in advance for char/composition so that the
2625 glyph string can be drawn over it. */ 2625 glyph string can be drawn over it. */
2626 if (!s->for_overlaps_p 2626 if (!s->for_overlaps
2627 && s->face->box != FACE_NO_BOX 2627 && s->face->box != FACE_NO_BOX
2628 && (s->first_glyph->type == CHAR_GLYPH 2628 && (s->first_glyph->type == CHAR_GLYPH
2629 || s->first_glyph->type == COMPOSITE_GLYPH)) 2629 || s->first_glyph->type == COMPOSITE_GLYPH))
@@ -2649,7 +2649,7 @@ x_draw_glyph_string (s)
2649 break; 2649 break;
2650 2650
2651 case CHAR_GLYPH: 2651 case CHAR_GLYPH:
2652 if (s->for_overlaps_p) 2652 if (s->for_overlaps)
2653 s->background_filled_p = 1; 2653 s->background_filled_p = 1;
2654 else 2654 else
2655 x_draw_glyph_string_background (s, 0); 2655 x_draw_glyph_string_background (s, 0);
@@ -2657,7 +2657,7 @@ x_draw_glyph_string (s)
2657 break; 2657 break;
2658 2658
2659 case COMPOSITE_GLYPH: 2659 case COMPOSITE_GLYPH:
2660 if (s->for_overlaps_p || s->gidx > 0) 2660 if (s->for_overlaps || s->gidx > 0)
2661 s->background_filled_p = 1; 2661 s->background_filled_p = 1;
2662 else 2662 else
2663 x_draw_glyph_string_background (s, 1); 2663 x_draw_glyph_string_background (s, 1);
@@ -2668,7 +2668,7 @@ x_draw_glyph_string (s)
2668 abort (); 2668 abort ();
2669 } 2669 }
2670 2670
2671 if (!s->for_overlaps_p) 2671 if (!s->for_overlaps)
2672 { 2672 {
2673 /* Draw underline. */ 2673 /* Draw underline. */
2674 if (s->face->underline_p) 2674 if (s->face->underline_p)
@@ -3588,7 +3588,7 @@ construct_mouse_click (result, event, f)
3588static XMotionEvent last_mouse_motion_event; 3588static XMotionEvent last_mouse_motion_event;
3589static Lisp_Object last_mouse_motion_frame; 3589static Lisp_Object last_mouse_motion_frame;
3590 3590
3591static void 3591static int
3592note_mouse_movement (frame, event) 3592note_mouse_movement (frame, event)
3593 FRAME_PTR frame; 3593 FRAME_PTR frame;
3594 XMotionEvent *event; 3594 XMotionEvent *event;
@@ -3602,10 +3602,11 @@ note_mouse_movement (frame, event)
3602 frame->mouse_moved = 1; 3602 frame->mouse_moved = 1;
3603 last_mouse_scroll_bar = Qnil; 3603 last_mouse_scroll_bar = Qnil;
3604 note_mouse_highlight (frame, -1, -1); 3604 note_mouse_highlight (frame, -1, -1);
3605 return 1;
3605 } 3606 }
3606 3607
3607 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3608 /* Has the mouse moved off the glyph it was on at the last sighting? */
3608 else if (event->x < last_mouse_glyph.x 3609 if (event->x < last_mouse_glyph.x
3609 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width 3610 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width
3610 || event->y < last_mouse_glyph.y 3611 || event->y < last_mouse_glyph.y
3611 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height) 3612 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height)
@@ -3613,7 +3614,12 @@ note_mouse_movement (frame, event)
3613 frame->mouse_moved = 1; 3614 frame->mouse_moved = 1;
3614 last_mouse_scroll_bar = Qnil; 3615 last_mouse_scroll_bar = Qnil;
3615 note_mouse_highlight (frame, event->x, event->y); 3616 note_mouse_highlight (frame, event->x, event->y);
3617 /* Remember which glyph we're now on. */
3618 remember_mouse_glyph (frame, event->x, event->y, &last_mouse_glyph);
3619 return 1;
3616 } 3620 }
3621
3622 return 0;
3617} 3623}
3618 3624
3619 3625
@@ -3632,56 +3638,6 @@ redo_mouse_highlight ()
3632} 3638}
3633 3639
3634 3640
3635static int glyph_rect P_ ((struct frame *f, int, int, XRectangle *));
3636
3637
3638/* Try to determine frame pixel position and size of the glyph under
3639 frame pixel coordinates X/Y on frame F . Return the position and
3640 size in *RECT. Value is non-zero if we could compute these
3641 values. */
3642
3643static int
3644glyph_rect (f, x, y, rect)
3645 struct frame *f;
3646 int x, y;
3647 XRectangle *rect;
3648{
3649 Lisp_Object window;
3650 struct window *w;
3651 struct glyph_row *r, *end_row;
3652
3653 window = window_from_coordinates (f, x, y, 0, &x, &y, 0);
3654 if (NILP (window))
3655 return 0;
3656
3657 w = XWINDOW (window);
3658 r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
3659 end_row = r + w->current_matrix->nrows - 1;
3660
3661 for (; r < end_row && r->enabled_p; ++r)
3662 {
3663 if (r->y >= y)
3664 {
3665 struct glyph *g = r->glyphs[TEXT_AREA];
3666 struct glyph *end = g + r->used[TEXT_AREA];
3667 int gx = r->x;
3668 while (g < end && gx < x)
3669 gx += g->pixel_width, ++g;
3670 if (g < end)
3671 {
3672 rect->width = g->pixel_width;
3673 rect->height = r->height;
3674 rect->x = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3675 rect->y = WINDOW_TO_FRAME_PIXEL_Y (w, r->y);
3676 return 1;
3677 }
3678 break;
3679 }
3680 }
3681
3682 return 0;
3683}
3684
3685 3641
3686/* Return the current position of the mouse. 3642/* Return the current position of the mouse.
3687 *FP should be a frame which indicates which display to ask about. 3643 *FP should be a frame which indicates which display to ask about.
@@ -3869,32 +3825,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
3869 on it, i.e. into the same rectangles that matrices on 3825 on it, i.e. into the same rectangles that matrices on
3870 the frame are divided into. */ 3826 the frame are divided into. */
3871 3827
3872 int width, height, gx, gy; 3828 remember_mouse_glyph (f1, win_x, win_y, &last_mouse_glyph);
3873 XRectangle rect;
3874
3875 if (glyph_rect (f1, win_x, win_y, &rect))
3876 last_mouse_glyph = rect;
3877 else
3878 {
3879 width = FRAME_SMALLEST_CHAR_WIDTH (f1);
3880 height = FRAME_SMALLEST_FONT_HEIGHT (f1);
3881 gx = win_x;
3882 gy = win_y;
3883
3884 /* Arrange for the division in FRAME_PIXEL_X_TO_COL etc. to
3885 round down even for negative values. */
3886 if (gx < 0)
3887 gx -= width - 1;
3888 if (gy < 0)
3889 gy -= height - 1;
3890 gx = (gx + width - 1) / width * width;
3891 gy = (gy + height - 1) / height * height;
3892
3893 last_mouse_glyph.width = width;
3894 last_mouse_glyph.height = height;
3895 last_mouse_glyph.x = gx;
3896 last_mouse_glyph.y = gy;
3897 }
3898 3829
3899 *bar_window = Qnil; 3830 *bar_window = Qnil;
3900 *part = 0; 3831 *part = 0;
@@ -6571,8 +6502,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6571 case MotionNotify: 6502 case MotionNotify:
6572 { 6503 {
6573 previous_help_echo_string = help_echo_string; 6504 previous_help_echo_string = help_echo_string;
6574 help_echo_string = help_echo_object = help_echo_window = Qnil; 6505 help_echo_string = Qnil;
6575 help_echo_pos = -1;
6576 6506
6577 if (dpyinfo->grabbed && last_mouse_frame 6507 if (dpyinfo->grabbed && last_mouse_frame
6578 && FRAME_LIVE_P (last_mouse_frame)) 6508 && FRAME_LIVE_P (last_mouse_frame))
@@ -6611,7 +6541,8 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6611 6541
6612 last_window=window; 6542 last_window=window;
6613 } 6543 }
6614 note_mouse_movement (f, &event.xmotion); 6544 if (!note_mouse_movement (f, &event.xmotion))
6545 help_echo_string = previous_help_echo_string;
6615 } 6546 }
6616 else 6547 else
6617 { 6548 {
@@ -6720,6 +6651,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6720 int tool_bar_p = 0; 6651 int tool_bar_p = 0;
6721 6652
6722 bzero (&compose_status, sizeof (compose_status)); 6653 bzero (&compose_status, sizeof (compose_status));
6654 bzero (&last_mouse_glyph, sizeof (last_mouse_glyph));
6723 6655
6724 if (dpyinfo->grabbed 6656 if (dpyinfo->grabbed
6725 && last_mouse_frame 6657 && last_mouse_frame