aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2013-09-10 23:52:26 +0200
committerJoakim Verona2013-09-10 23:52:26 +0200
commit63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c (patch)
treee5078c5545c777e21944a9ee4199a6f2c6d25ca9 /src
parent92aeabcc8a007f521a664e3aee092eb80ad0f49a (diff)
downloademacs-63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c.tar.gz
emacs-63dae8e97d343fd4ebfe3dc08f0e8dc932630a4c.zip
merge upstream
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog459
-rw-r--r--src/Makefile.in16
-rw-r--r--src/alloc.c6
-rw-r--r--src/buffer.c40
-rw-r--r--src/buffer.h1
-rw-r--r--src/callint.c4
-rw-r--r--src/cmds.c20
-rw-r--r--src/coding.h2
-rw-r--r--src/composite.h6
-rw-r--r--src/dispextern.h106
-rw-r--r--src/dispnew.c100
-rw-r--r--src/editfns.c26
-rw-r--r--src/emacsgtkfixed.c5
-rw-r--r--src/eval.c28
-rw-r--r--src/fileio.c2
-rw-r--r--src/font.c8
-rw-r--r--src/font.h11
-rw-r--r--src/fontset.c26
-rw-r--r--src/fontset.h3
-rw-r--r--src/frame.c27
-rw-r--r--src/frame.h56
-rw-r--r--src/gfilenotify.c2
-rw-r--r--src/gtkutil.c51
-rw-r--r--src/gtkutil.h2
-rw-r--r--src/image.c5
-rw-r--r--src/indent.c38
-rw-r--r--src/intervals.c12
-rw-r--r--src/keyboard.c180
-rw-r--r--src/keyboard.h4
-rw-r--r--src/lisp.h26
-rw-r--r--src/minibuf.c7
-rw-r--r--src/msdos.c21
-rw-r--r--src/nsfns.m9
-rw-r--r--src/nsfont.m9
-rw-r--r--src/nsterm.m95
-rw-r--r--src/print.c9
-rw-r--r--src/process.c63
-rw-r--r--src/regex.c31
-rw-r--r--src/search.c86
-rw-r--r--src/sysdep.c4
-rw-r--r--src/sysselect.h11
-rw-r--r--src/term.c19
-rw-r--r--src/termhooks.h28
-rw-r--r--src/w32.c8
-rw-r--r--src/w32.h1
-rw-r--r--src/w32console.c8
-rw-r--r--src/w32fns.c8
-rw-r--r--src/w32proc.c12
-rw-r--r--src/w32term.c96
-rw-r--r--src/w32term.h1
-rw-r--r--src/w32xfns.c6
-rw-r--r--src/window.c63
-rw-r--r--src/window.h33
-rw-r--r--src/xdisp.c445
-rw-r--r--src/xfaces.c39
-rw-r--r--src/xfns.c20
-rw-r--r--src/xgselect.c4
-rw-r--r--src/xgselect.h4
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xterm.c304
-rw-r--r--src/xterm.h36
61 files changed, 1360 insertions, 1394 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5d5a811b3c4..4e08178989e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,464 @@
12013-09-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * eval.c (Feval): Document the new use of `lexical'.
4
52013-09-09 Dmitry Antipov <dmantipov@yandex.ru>
6
7 Review and drop old frame resize hack.
8 * frame.h (struct frame): Remove force_flush_display_p.
9 * dispnew.c (update_frame): Adjust user and don't call
10 flush_frame here. The comment has said that there was an issues
11 with redisplaying fringes, but I don't see any differences with
12 and without this hack. Hopefully we can continue without it.
13 * xdisp.c (clear_garbaged_frames): Adjust user and do not clear
14 current frame matrices twice if resized_p is set.
15
162013-09-09 Dmitry Antipov <dmantipov@yandex.ru>
17
18 Do not populate pure Xism x_sync to other ports.
19 * frame.h (x_sync): Move under HAVE_X_WINDOWS.
20 * frame.c (other_visible_frames) [HAVE_X_WINDOWS]: Use as such.
21 * nsfns.m, w32xfns.c (x_sync): Remove no-op.
22 * w32term.h (x_sync): Remove prototype.
23
242013-09-09 Dmitry Antipov <dmantipov@yandex.ru>
25
26 Cleanup frame flushing.
27 * dispextern.h (struct redisplay_interface):
28 Drop flush_display_optional because flush_display is enough
29 for X and flushing via RIF is just a no-op for others.
30 * frame.h (flush_frame): New function.
31 * dispnew.c (update_frame):
32 * minibuf.c (read_minibuf):
33 * xdisp.c (echo_area_display, redisplay_preserve_echo_area):
34 Use it.
35 * keyboard.c (detect_input_pending_run_timers): Do not flush
36 all frames but selected one in redisplay_preserve_echo_area.
37 * nsterm.m (ns_flush): Remove no-op.
38 (ns_redisplay_interface): Adjust user.
39 * w32term.h (x_flush): Remove no-op.
40 (w32_redisplay_interface): Adjust user.
41 * xterm.c (x_flush): Simplify because we do not flush all
42 frames at once any more. Adjust comment.
43 (x_redisplay_interface): Adjust user.
44
452013-09-07 Paul Eggert <eggert@cs.ucla.edu>
46
47 Port --without-x --enable-gcc-warnings to Fedora 19.
48 * gfilenotify.c (globals_of_gfilenotify):
49 Call g_type_init only if using an older glib version that needs it.
50
512013-09-06 Dmitry Antipov <dmantipov@yandex.ru>
52
53 * lisp.h (last_glyphless_glyph_frame, last_glyphless_glyph_face_id)
54 (last_glyphless_glyph_merged_face_id): Remove declarations.
55 * dispextern.h (merge_glyphless_glyph_face): Add prototype.
56 * xdisp.c (last_glyphless_glyph_frame, last_glyphless_glyph_face_id)
57 (last_glyphless_glyph_merged_face_id): Now static.
58 (merge_escape_glyph_face): New function, refactored from...
59 (get_next_display_element): ...here.
60 (merge_glyphless_glyph_face): New function, refactored from...
61 (produce_glyphless_glyph): ...here...
62 * term.c (produce_glyphless_glyph): ...and here.
63
642013-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
65
66 * eval.c (eval_sub): Only call Ffunction if necessary.
67
682013-09-06 Dmitry Antipov <dmantipov@yandex.ru>
69
70 Attempt to make redisplay more selective when changing cursor type.
71 * frame.h (struct frame): New bitfield cursor_type_changed.
72 * xdisp.c (cursor_type_changed): Remove.
73 (try_cursor_movement, redisplay_window, try_window_id)
74 (set_frame_cursor_types, try_window_reusing_current_matrix):
75 Adjust to use per-frame bitfield.
76 (redisplay_internal): Look for cursor type change on each visible
77 frame and consider all frames if cursor type has been changed on
78 the frame other than selected. If cursor type has been changed on
79 selected frame only, do not use fast update.
80
812013-09-06 Dmitry Antipov <dmantipov@yandex.ru>
82
83 Attempt to make redisplay more selective when changing fonts.
84 * frame.h (struct frame): New bitfield fonts_changed.
85 * dispextern.h (fonts_changed_p, adjust_glyphs): Remove declaration.
86 (adjust_frame_glyphs): Add prototype.
87 * dispnew.c (fonts_changed_p): Remove.
88 (adjust_glyphs): Remove because we do not
89 adjust matrices on all frames at once any more.
90 (adjust_frame_glyphs): Block and unblock input here.
91 (adjust_glyph_matrix): Use fonts_changed.
92 (change_frame_size_1): Use adjust_frame_glyphs.
93 * font.c (font_open_entity): Use fonts_changed.
94 * frame.c (set_menu_bar_lines, Fmake_terminal_frame):
95 * w32fns.c (x_set_menu_bar_lines, x_set_tool_bar_lines, Fx_show_tip):
96 * window.c (Fdelete_other_windows_internal, Fwindow_resize_apply)
97 (Fsplit_window_internal, Fdelete_window_internal, grow_mini_window)
98 (shrink_mini_window, Fresize_mini_window_internal)
99 (window_scroll_pixel_based, Fset_window_configuration)
100 (apply_window_adjustment, Fset_window_vscroll):
101 * xfns.c (x_set_menu_bar_lines, x_set_tool_bar_lines, Fx_show_tip):
102 Use adjust_frame_glyphs.
103 * xdisp.c (redisplay_tool_bar, redisplay_window, try_window)
104 (try_window_reusing_current_matrix, try_window_id, display_line)
105 (IT_EXPAND_MATRIX_WIDTH): Use fonts_changed.
106 (redisplay_internal): Consider fonts_changed and adjust frame
107 matrices for each frame only if the frame is visible. If font
108 has been changed on some frame during full redisplay, retry
109 only visible frames where the font has been actually changed.
110
1112013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
112
113 Cache current header and mode line height for each window.
114 * window.h (struct window): New fields mode_line_height
115 and header_line_height.
116 * window.c (make_window): Initialize them.
117 * dispextern.h (CURRENT_MODE_LINE_HEIGHT)
118 (CURRENT_HEADER_LINE_HEIGHT): Use them. Adjust comment.
119 (current_mode_line_height, current_header_line_height):
120 Remove declaration.
121 * xdisp.c (current_mode_line_height, current_header_line_height):
122 Remove.
123 (pos_visible_p, init_xdisp): Adjust user.
124 (redisplay_window): Invalidate mode_line_height and
125 header_line_height if current and desired matrices do not agree.
126
1272013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
128
129 * fontset.c, window.c, xdisp.c (toplevel): Use TERM_HEADER.
130 * xfaces.c (toplevel) [HAVE_X_WINDOWS]: Do not include xterm.h twice.
131
1322013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
133
134 Make --without-x compatible with --enable-gcc-warnings.
135 * font.c (register_font_driver): Move check under HAVE_WINDOW_SYSTEM.
136 * font.h (struct font_driver): Move draw, get_bitmap and free_bitmap
137 members under HAVE_WINDOW_SYSTEM.
138 * keyboard.c (make_lispy_focus_out): Likewise.
139 (record_menu_key): Move under HAVE_MENUS.
140 * xdisp.c (toplevel): Move hourglass_shown_p, hourglass_atimer and
141 THIN_SPACE_WIDTH under HAVE_WINDOW_SYSTEM.
142 (syms_of_xdisp): Adjust user.
143 (window_box_edges): Define only if HAVE_WINDOW_SYSTEM.
144 (start_hourglass, cancel_hourglass):
145 * xfaces.c (toplevel): Likewise with PT_PER_INCH,
146 clear_font_table_count, CLEAR_FONT_TABLE_COUNT
147 and CLEAR_FONT_TABLE_NFONTS.
148 (set_font_frame_param, clear_face_gcs, realize_non_ascii_face):
149 Declare only if HAVE_WINDOW_SYSTEM.
150 (lface_same_font_attributes_p, clear_face_gcs): Define only
151 if HAVE_WINDOW_SYSTEM.
152
1532013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
154
155 * frame.c (check_minibuf_window): Update 'frame' with frame pointer.
156 * xterm.c (x_scroll_bar_handle_click) [!USE_TOOLKIT_SCROLL_BARS]:
157 Don't pass C integer to XINT (tiny fix for 2013-09-03 change).
158
1592013-09-05 Stefan Monnier <monnier@iro.umontreal.ca>
160
161 * cmds.c (Fself_insert_command): Don't pass a non-integer to XINT.
162
1632013-09-04 Paul Eggert <eggert@cs.ucla.edu>
164
165 * alloc.c (make_event_array): First arg is now ptrdiff_t, not int.
166 This fixes a type error on hosts where ptrdiff_t is wider than int.
167
1682013-09-04 Stefan Monnier <monnier@iro.umontreal.ca>
169
170 * keyboard.c (read_key_sequence_vs): New function.
171 (Fread_key_sequence_vector, Fread_key_sequence): Use it to factor out
172 common code.
173
174 * callint.c (Fcall_interactively): Always return a vector for 'K'.
175
1762013-09-04 Paul Eggert <eggert@cs.ucla.edu>
177
178 Makefile improvements.
179 * Makefile.in (config.status): Don't use double-colon rules, as
180 they are not portable according to POSIX. Fix shell typo with `;
181 I guess this rule has never been tested?
182 (VCSWITNESS): New macro, to override any environment var.
183
1842013-09-04 Dmitry Antipov <dmantipov@yandex.ru>
185
186 * xterm.h (struct x_display_info): Do not track X connection
187 fd separately because it is always available from Display.
188 * xterm.c (x_term_init, x_delete_terminal, x_delete_display):
189 Adjust users.
190
1912013-09-03 Dmitry Antipov <dmantipov@yandex.ru>
192
193 * buffer.c (drop_overlay):
194 * fileio.c (restore_point_unwind): Prefer unchain_marker to
195 Fset_marker (X, Qnil, ...) (which is the same but a bit slower).
196
1972013-09-03 Dmitry Antipov <dmantipov@yandex.ru>
198
199 * buffer.c (Fmake_overlay, Fmove_overlay):
200 * intervals.c (set_point_from_marker):
201 * print.c (PRINTPREPARE): Prefer signal_error
202 to plain error and report unsuitable marker too.
203
2042013-09-03 Dmitry Antipov <dmantipov@yandex.ru>
205
206 * xterm.h (struct scroll_bar): Prefer int to Lisp_Object
207 for 'dragging' member.
208 (struct x_output): Remove set-but-unused leftovers
209 'left_before_move' and 'top_before_move'.
210 * gtkutil.c (xg_set_toolkit_scroll_bar_thumb):
211 * xterm.c (xt_action_hook, xm_scroll_callback, xg_scroll_callback)
212 (xg_end_scroll_callback, xaw_jump_callback, xaw_scroll_callback)
213 (x_set_toolkit_scroll_bar_thumb, x_scroll_bar_create)
214 (x_scroll_bar_set_handle, XTset_vertical_scroll_bar)
215 (x_scroll_bar_handle_click, x_scroll_bar_note_movement)
216 (x_scroll_bar_report_motion, x_set_offset): Related users changed.
217 * xfns.c, image.c (XLIB_ILLEGAL_ACCESS): No longer needed.
218
2192013-09-03 Jan Djärv <jan.h.d@swipnet.se>
220
221 * nsfont.m (INVALID_GLYPH): New define.
222 (nsfont_encode_char): Use INVALID_GLYPH.
223 (ns_uni_to_glyphs): Ditto, check for NSNullGlyph (Bug#15138).
224
2252013-09-02 Dmitry Antipov <dmantipov@yandex.ru>
226
227 * xterm.c (x_last_mouse_movement_time): Revert last change.
228 This code should use XDisplayMotionBufferSize to check display's
229 motion history first, and there are few other issues as well.
230 (x_scroll_bar_note_movement): Pass XMotionEvent rather than XEvent.
231 (handle_one_xevent): Adjust user.
232
2332013-09-02 Martin Rudalics <rudalics@gmx.at>
234
235 * dispnew.c (Flast_nonminibuf_frame): Move from here ...
236 * frame.c (Flast_nonminibuf_frame): ... to here.
237 (check_minibuf_window): Don't abort if no window was found
238 (Bug#15247).
239
2402013-09-02 Dmitry Antipov <dmantipov@yandex.ru>
241
242 Use XGetMotionEvents to ask the last mouse motion time from X server.
243 * xterm.c (X_MOTION_HISTORY): Default to 1.
244 (x_last_mouse_movement_time) [X_MOTION_HISTORY]: New function.
245 (x_last_mouse_movement_time) [!X_MOTION_HISTORY]: Legacy version.
246 (note_mouse_movement, x_scroll_bar_note_movement) [!X_MOTION_HISTORY]:
247 Ifdef away legacy code.
248 (XTmouse_position, x_scroll_bar_report_motion):
249 Use x_last_mouse_movement_time.
250 (handle_one_xevent): Use event.xunmap and not event.xmap when handling
251 UnmapNotify event.
252
2532013-09-02 Dmitry Antipov <dmantipov@yandex.ru>
254
255 * msdos.c (last_mouse_window): Move to...
256 (dos_rawgetc): ...this function and adjust comment.
257 * nsterm.m (last_window): Rename to last_mouse_window, move to...
258 (mouseMoved): ...this function and adjust comment.
259 * w32term.c (last_window): Likewise with...
260 (w32_read_socket): ...this function.
261 * xterm.c (last_window): Likewise with...
262 (handle_one_xevent): ...this function.
263
2642013-09-02 Dmitry Antipov <dmantipov@yandex.ru>
265
266 * window.h (Vmouse_window, Vmouse_event): Remove the leftovers.
267 * xterm.c (toplevel): Drop obsolete comment and move compose_status...
268 (handle_one_xevent): ...to here.
269 (STORE_KEYSYM_FOR_DEBUG): Move under ENABLE_CHECKING and make no-op
270 otherwise.
271
2722013-09-02 Dmitry Antipov <dmantipov@yandex.ru>
273
274 * msdos.c (IT_set_terminal_window): Remove no-op.
275 (initialize_msdos_display): Adjust terminal setup.
276 * w32console.c (w32con_set_terminal_window): Remove no-op.
277 (initialize_w32_display): Adjust terminal setup.
278 * w32term.c (w32_set_terminal_window): Remove no-op.
279 (w32_create_terminal): Adjust terminal setup.
280 * xterm.c (XTset_terminal_window): Remove no-op.
281 (x_create_terminal): Adjust terminal setup.
282
2832013-09-01 Dmitry Antipov <dmantipov@yandex.ru>
284
285 * nsterm.m (ns_set_terminal_modes, ns_reset_terminal_modes):
286 Remove no-ops.
287 (ns_create_terminal): Adjust terminal setup.
288 * w32term.c (w32_set_terminal_modes, w32_reset_terminal_modes):
289 Remove no-ops.
290 (w32_create_terminal): Adjust terminal setup.
291 * xterm.c (XTset_terminal_modes, XTreset_terminal_modes):
292 Remove no-ops.
293 (x_create_terminal): Adjust terminal setup.
294
2952013-09-01 Dmitry Antipov <dmantipov@yandex.ru>
296
297 * dispextern.h (SET_TEXT_POS_FROM_MARKER): Indent.
298 (CLIP_TEXT_POS_FROM_MARKER): New macro.
299 * dispnew.c (buffer_posn_from_coords):
300 * window.c (Fwindow_end, displayed_window_lines):
301 * xdisp.c (redisplay_mode_lines): Use it.
302
3032013-09-01 Jan Djärv <jan.h.d@swipnet.se>
304
305 * fontset.c (face_for_char): Check char in the current face font first
306 if HAVE_NS (Bug#15138).
307
3082013-08-31 Martin Rudalics <rudalics@gmx.at>
309
310 * window.c (temp_output_buffer_show): Make sure window returned
311 by display_buffer is live (Bug#15213).
312
3132013-08-30 Dmitry Antipov <dmantipov@yandex.ru>
314
315 Minor cleanup to avoid forward declarations.
316 * coding.h (struct ccl_spec): Remove forward declaration.
317 * composite.h (toplevel): Include font.h.
318 (struct composition_it, struct face, struct font_metrics):
319 Remove forward declaration.
320 * dispextern.h (struct image, struct atimer): Likewise.
321 * emacsgtkfixed.h (struct frame): Likewise.
322 * emacsgtkfixed.c (toplevel): Reorder headers and drop stdio.h.
323 * font.h (struct font_driver, struct font, struct glyph_string)
324 (struct face): Remove forward declaration.
325 * fontset.h (struct face, struct font): Likewise.
326 * frame.h (toplevel): Style cleanup.
327 (enum output_method): Move to...
328 * termhooks.h (enum output_method): ...here.
329 (struct glyph, struct frame, struct ns_display_info)
330 (struct x_display_info, struct w32_display_info):
331 Remove forward declaration.
332 * xterm.h (toplevel): Include termhooks.h.
333 (struct font, struct window, struct glyph_matrix, struct frame)
334 (struct input_event, struct face, struct image): Remove forward
335 declaration.
336 * gtkutil.h (struct _widget_value): Likewise.
337 * keyboard.h (toplevel): Include termhooks.h.
338 (struct input_event): Remove forward declaration.
339
3402013-08-29 Dmitry Antipov <dmantipov@yandex.ru>
341
342 * intervals.c (set_point_from_marker): New function.
343 * editfns.c (Fgoto_char):
344 * process.c (Finternal_default_process_filter):
345 * window.c (select_window_1): Use it.
346 * buffer.h (set_point_from_marker): Add prototype.
347
3482013-08-29 Eli Zaretskii <eliz@gnu.org>
349
350 * w32.c (term_winsock): Call release_listen_threads before calling
351 WSACleanup.
352 (_sys_wait_accept): Wait for accept event in a loop with a finite
353 timeout, instead of waiting indefinitely. Will hopefully avoid
354 hanging during exit because WSACleanup deadlocks waiting for the
355 event object to be released. (Bug#14333)
356
357 * w32proc.c (release_listen_threads): New function, signals all
358 the reader threads that listen for connections to stop waiting.
359
360 * w32.h (release_listen_threads): Add prototype.
361
3622013-08-29 Dmitry Antipov <dmantipov@yandex.ru>
363
364 * alloc.c (Fmake_marker, build_marker): Zero need_adjustment
365 field of new marker (for sanity and safety).
366 * lisp.h (XSETMARKER): Remove unused macro (it doesn't work
367 anyway because XMISCTYPE is a function and can't be an lvalue).
368
3692013-08-29 Dmitry Antipov <dmantipov@yandex.ru>
370
371 * xterm.c (x_clear_area): Lost 7th arg because it is always False.
372 (x_after_update_window_line, x_scroll_bar_create):
373 (x_scroll_bar_set_handle, XTset_vertical_scroll_bar):
374 (handle_one_xevent, x_clear_frame_area):
375 * gtkutil.c (xg_clear_under_internal_border, xg_update_scrollbar_pos):
376 * xfns.c (x_set_menu_bar_lines, x_set_tool_bar_lines): Adjust users.
377 * xterm.h (x_clear_area): Adjust prototype.
378
3792013-08-29 Dmitry Antipov <dmantipov@yandex.ru>
380
381 Hook scanning and indentation functions to find_newline. This helps
382 to avoid duplicated code and renders more respect to newline cache.
383 * lisp.h (scan_newline): Prefer ptrdiff_t to EMACS_INT.
384 * cmds.c (Fforward_line):
385 * indent.c (scan_for_column, Fcurrent_indentation, indented_beyond_p):
386 Use find_newline and avoid unnecessary point movements.
387 * search.c (scan_newline): Implement on top of find_newline.
388
3892013-08-28 Stefan Monnier <monnier@iro.umontreal.ca>
390
391 * eval.c (Ffuncall): Fix handling of ((lambda ..) ..) in lexically
392 scoped code (bug#11258).
393
3942013-08-28 Davor Cubranic <cubranic@stat.ubc.ca> (tiny change)
395
396 * nsterm.m (last_window): New variable.
397 (EV_TRAILER2): New macro.
398 (EV_TRAILER): Call EV_TRAILER2.
399 (mouseMoved:): Add support for mouse-autoselect-window
400 on nextstep (Bug#6888).
401
4022013-08-28 Andreas Schwab <schwab@suse.de>
403
404 * regex.c (CHAR_CHARSET, CHARSET_LEADING_CODE_BASE, CHAR_HEAD_P)
405 (SINGLE_BYTE_CHAR_P, SAME_CHARSET_P, MAKE_CHAR, BYTE8_TO_CHAR):
406 Remove unused macro definitions.
407 (CHARSET_RANGE_TABLE_BITS, EXTEND_RANGE_TABLE)
408 (SET_RANGE_TABLE_WORK_AREA_BIT, SET_RANGE_TABLE_WORK_AREA):
409 Only define if emacs.
410
4112013-08-28 Dmitry Antipov <dmantipov@yandex.ru>
412
413 Prefer enum glyph_row_area to int where appropriate.
414 * dispextern.h (enum glyph_row_area): Add ANY_AREA member.
415 Fix comment.
416 (window_box, window_box_width, window_box_left, window_box_left_offset)
417 (window_box_right, window_box_right_offset): Adjust prototypes.
418 * xdisp.c (window_box, window_box_width, window_box_left)
419 (window_box_left_offset, window_box_right, window_box_right_offset):
420 Use enum glyph_row_area. Adjust users and tweak comment where needed.
421 (window_box_edges): Likewise. Lost 2nd arg since it is always ANY_AREA.
422 * nsterm.m (ns_clip_to_row):
423 * w32term.c (w32_clip_to_row):
424 * xterm.c (x_clip_to_row): Likewise.
425
4262013-08-28 Dmitry Antipov <dmantipov@yandex.ru>
427
428 * buffer.c (Foverlays_at, Foverlays_in, Fnext_overlay_change)
429 (Fprevious_overlay_change): Fast path for buffer with no overlays.
430
4312013-08-28 Paul Eggert <eggert@cs.ucla.edu>
432
433 * Makefile.in (SHELL): Now @SHELL@, not /bin/sh,
434 for portability to hosts where /bin/sh has problems.
435
4362013-08-28 Dmitry Antipov <dmantipov@yandex.ru>
437
438 Redesign redisplay interface to drop global output_cursor.
439 * dispextern.h (struct redisplay_interface): Remove cursor_to member.
440 (toplevel): Remove declaration of output_cursor.
441 (set_output_cursor, x_cursor_to): Remove prototype.
442 * window.h (struct window): New member output_cursor.
443 (output_cursor_to): New function to replace RIF member.
444 * dispnew.c (redraw_overlapped_rows, update_marginal_area)
445 (update_text_area, set_window_cursor_after_update): Use it.
446 * xdisp.c (output_cursor, set_output_cursor, x_cursor_to): Remove.
447 (x_write_glyphs, x_insert_glyphs, x_clear_end_of_line):
448 * nsterm.m (ns_update_window_begin, ns_update_window_end):
449 * w32term.c (x_update_window_begin, x_update_window_end):
450 * xterm.c (x_update_window_begin, x_update_window_end):
451 Adjust to use per-window output cursor.
452
12013-08-27 Paul Eggert <eggert@cs.ucla.edu> 4532013-08-27 Paul Eggert <eggert@cs.ucla.edu>
2 454
455 Simplify SELECT_TYPE-related code.
456 Like EMACS_TIME, this portability layer is no longer needed, since
457 Emacs has been using fd_set as a portability layer for some time.
458 * sysselect.h (FD_SETSIZE): Rename from MAXDESC. All uses changed.
459 (SELECT_TYPE): Remove. All uses changed to fd_set.
460 (fd_set) [!FD_SET]: New typedef.
461
3 Simplify EMACS_TIME-related code. 462 Simplify EMACS_TIME-related code.
4 This portability layer is no longer needed, since Emacs has been 463 This portability layer is no longer needed, since Emacs has been
5 using struct timespec as a portability layer for some time. 464 using struct timespec as a portability layer for some time.
diff --git a/src/Makefile.in b/src/Makefile.in
index 76a4e0c5703..aa51108ffc2 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -23,7 +23,7 @@
23# script may need modifying in sync with changes made here. Try to 23# script may need modifying in sync with changes made here. Try to
24# avoid shell-ism because the DOS build has to use the DOS shell. 24# avoid shell-ism because the DOS build has to use the DOS shell.
25 25
26SHELL = /bin/sh 26SHELL = @SHELL@
27 27
28# Here are the things that we expect ../configure to edit. 28# Here are the things that we expect ../configure to edit.
29# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH. 29# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
@@ -548,14 +548,9 @@ stamp-oldxmenu: $(OLDXMENU_DEPS)
548 548
549$(OLDXMENU): $(OLDXMENU_TARGET) 549$(OLDXMENU): $(OLDXMENU_TARGET)
550 550
551../config.status:: epaths.in 551../config.status: config.in epaths.in
552 @echo "The file epaths.h needs to be set up from epaths.in." 552 @echo "The file ${?:.in=.h} needs to be set up from $?."
553 @echo "Please run the `configure' script again." 553 @echo "Please run the 'configure' script again."
554 exit 1
555
556../config.status:: config.in
557 @echo "The file config.h needs to be set up from config.in."
558 @echo "Please run the `configure' script again."
559 exit 1 554 exit 1
560 555
561doc.o: buildobj.h 556doc.o: buildobj.h
@@ -668,6 +663,9 @@ $(lisp): $(BOOTSTRAPEMACS)
668 663
669## VCSWITNESS points to the file that holds info about the current checkout. 664## VCSWITNESS points to the file that holds info about the current checkout.
670## We use it as a heuristic to decide when to rebuild loaddefs.el. 665## We use it as a heuristic to decide when to rebuild loaddefs.el.
666## If empty it is ignored; the parent makefile can set it to some other value.
667VCSWITNESS =
668
671$(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS) 669$(lispsource)/loaddefs.el: $(BOOTSTRAPEMACS) $(VCSWITNESS)
672 cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=$(bootstrap_exe) 670 cd ../lisp; $(MAKE) $(MFLAGS) autoloads EMACS=$(bootstrap_exe)
673 671
diff --git a/src/alloc.c b/src/alloc.c
index ebb8ef58991..0989e63664f 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3479,6 +3479,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
3479 p->charpos = 0; 3479 p->charpos = 0;
3480 p->next = NULL; 3480 p->next = NULL;
3481 p->insertion_type = 0; 3481 p->insertion_type = 0;
3482 p->need_adjustment = 0;
3482 return val; 3483 return val;
3483} 3484}
3484 3485
@@ -3503,6 +3504,7 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, ptrdiff_t bytepos)
3503 m->charpos = charpos; 3504 m->charpos = charpos;
3504 m->bytepos = bytepos; 3505 m->bytepos = bytepos;
3505 m->insertion_type = 0; 3506 m->insertion_type = 0;
3507 m->need_adjustment = 0;
3506 m->next = BUF_MARKERS (buf); 3508 m->next = BUF_MARKERS (buf);
3507 BUF_MARKERS (buf) = m; 3509 BUF_MARKERS (buf) = m;
3508 return obj; 3510 return obj;
@@ -3525,9 +3527,9 @@ free_marker (Lisp_Object marker)
3525 Any number of arguments, even zero arguments, are allowed. */ 3527 Any number of arguments, even zero arguments, are allowed. */
3526 3528
3527Lisp_Object 3529Lisp_Object
3528make_event_array (register int nargs, Lisp_Object *args) 3530make_event_array (ptrdiff_t nargs, Lisp_Object *args)
3529{ 3531{
3530 int i; 3532 ptrdiff_t i;
3531 3533
3532 for (i = 0; i < nargs; i++) 3534 for (i = 0; i < nargs; i++)
3533 /* The things that fit in a string 3535 /* The things that fit in a string
diff --git a/src/buffer.c b/src/buffer.c
index e42dbb2befd..ff05da6d0d9 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -892,8 +892,8 @@ drop_overlay (struct buffer *b, struct Lisp_Overlay *ov)
892 eassert (b == XBUFFER (Fmarker_buffer (ov->start))); 892 eassert (b == XBUFFER (Fmarker_buffer (ov->start)));
893 modify_overlay (b, marker_position (ov->start), 893 modify_overlay (b, marker_position (ov->start),
894 marker_position (ov->end)); 894 marker_position (ov->end));
895 Fset_marker (ov->start, Qnil, Qnil); 895 unchain_marker (XMARKER (ov->start));
896 Fset_marker (ov->end, Qnil, Qnil); 896 unchain_marker (XMARKER (ov->end));
897 897
898} 898}
899 899
@@ -3843,7 +3843,8 @@ for the front of the overlay advance when text is inserted there
3843The fifth arg REAR-ADVANCE, if non-nil, makes the marker 3843The fifth arg REAR-ADVANCE, if non-nil, makes the marker
3844for the rear of the overlay advance when text is inserted there 3844for the rear of the overlay advance when text is inserted there
3845\(which means the text *is* included in the overlay). */) 3845\(which means the text *is* included in the overlay). */)
3846 (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer, Lisp_Object front_advance, Lisp_Object rear_advance) 3846 (Lisp_Object beg, Lisp_Object end, Lisp_Object buffer,
3847 Lisp_Object front_advance, Lisp_Object rear_advance)
3847{ 3848{
3848 Lisp_Object overlay; 3849 Lisp_Object overlay;
3849 struct buffer *b; 3850 struct buffer *b;
@@ -3852,12 +3853,11 @@ for the rear of the overlay advance when text is inserted there
3852 XSETBUFFER (buffer, current_buffer); 3853 XSETBUFFER (buffer, current_buffer);
3853 else 3854 else
3854 CHECK_BUFFER (buffer); 3855 CHECK_BUFFER (buffer);
3855 if (MARKERP (beg) 3856
3856 && ! EQ (Fmarker_buffer (beg), buffer)) 3857 if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer))
3857 error ("Marker points into wrong buffer"); 3858 signal_error ("Marker points into wrong buffer", beg);
3858 if (MARKERP (end) 3859 if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer))
3859 && ! EQ (Fmarker_buffer (end), buffer)) 3860 signal_error ("Marker points into wrong buffer", end);
3860 error ("Marker points into wrong buffer");
3861 3861
3862 CHECK_NUMBER_COERCE_MARKER (beg); 3862 CHECK_NUMBER_COERCE_MARKER (beg);
3863 CHECK_NUMBER_COERCE_MARKER (end); 3863 CHECK_NUMBER_COERCE_MARKER (end);
@@ -3983,12 +3983,10 @@ buffer. */)
3983 if (NILP (Fbuffer_live_p (buffer))) 3983 if (NILP (Fbuffer_live_p (buffer)))
3984 error ("Attempt to move overlay to a dead buffer"); 3984 error ("Attempt to move overlay to a dead buffer");
3985 3985
3986 if (MARKERP (beg) 3986 if (MARKERP (beg) && !EQ (Fmarker_buffer (beg), buffer))
3987 && ! EQ (Fmarker_buffer (beg), buffer)) 3987 signal_error ("Marker points into wrong buffer", beg);
3988 error ("Marker points into wrong buffer"); 3988 if (MARKERP (end) && !EQ (Fmarker_buffer (end), buffer))
3989 if (MARKERP (end) 3989 signal_error ("Marker points into wrong buffer", end);
3990 && ! EQ (Fmarker_buffer (end), buffer))
3991 error ("Marker points into wrong buffer");
3992 3990
3993 CHECK_NUMBER_COERCE_MARKER (beg); 3991 CHECK_NUMBER_COERCE_MARKER (beg);
3994 CHECK_NUMBER_COERCE_MARKER (end); 3992 CHECK_NUMBER_COERCE_MARKER (end);
@@ -4170,6 +4168,9 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
4170 4168
4171 CHECK_NUMBER_COERCE_MARKER (pos); 4169 CHECK_NUMBER_COERCE_MARKER (pos);
4172 4170
4171 if (!buffer_has_overlays ())
4172 return Qnil;
4173
4173 len = 10; 4174 len = 10;
4174 /* We can't use alloca here because overlays_at can call xrealloc. */ 4175 /* We can't use alloca here because overlays_at can call xrealloc. */
4175 overlay_vec = xmalloc (len * sizeof *overlay_vec); 4176 overlay_vec = xmalloc (len * sizeof *overlay_vec);
@@ -4202,6 +4203,9 @@ end of the buffer. */)
4202 CHECK_NUMBER_COERCE_MARKER (beg); 4203 CHECK_NUMBER_COERCE_MARKER (beg);
4203 CHECK_NUMBER_COERCE_MARKER (end); 4204 CHECK_NUMBER_COERCE_MARKER (end);
4204 4205
4206 if (!buffer_has_overlays ())
4207 return Qnil;
4208
4205 len = 10; 4209 len = 10;
4206 overlay_vec = xmalloc (len * sizeof *overlay_vec); 4210 overlay_vec = xmalloc (len * sizeof *overlay_vec);
4207 4211
@@ -4230,6 +4234,9 @@ the value is (point-max). */)
4230 4234
4231 CHECK_NUMBER_COERCE_MARKER (pos); 4235 CHECK_NUMBER_COERCE_MARKER (pos);
4232 4236
4237 if (!buffer_has_overlays ())
4238 return make_number (ZV);
4239
4233 len = 10; 4240 len = 10;
4234 overlay_vec = xmalloc (len * sizeof *overlay_vec); 4241 overlay_vec = xmalloc (len * sizeof *overlay_vec);
4235 4242
@@ -4269,6 +4276,9 @@ the value is (point-min). */)
4269 4276
4270 CHECK_NUMBER_COERCE_MARKER (pos); 4277 CHECK_NUMBER_COERCE_MARKER (pos);
4271 4278
4279 if (!buffer_has_overlays ())
4280 return make_number (BEGV);
4281
4272 /* At beginning of buffer, we know the answer; 4282 /* At beginning of buffer, we know the answer;
4273 avoid bug subtracting 1 below. */ 4283 avoid bug subtracting 1 below. */
4274 if (XINT (pos) == BEGV) 4284 if (XINT (pos) == BEGV)
diff --git a/src/buffer.h b/src/buffer.h
index bedb7890939..169a15c7d0f 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -249,6 +249,7 @@ extern void temp_set_point (struct buffer *, ptrdiff_t);
249extern void set_point_both (ptrdiff_t, ptrdiff_t); 249extern void set_point_both (ptrdiff_t, ptrdiff_t);
250extern void temp_set_point_both (struct buffer *, 250extern void temp_set_point_both (struct buffer *,
251 ptrdiff_t, ptrdiff_t); 251 ptrdiff_t, ptrdiff_t);
252extern void set_point_from_marker (Lisp_Object);
252extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); 253extern void enlarge_buffer_text (struct buffer *, ptrdiff_t);
253 254
254 255
diff --git a/src/callint.c b/src/callint.c
index 25096af5068..d31604b070e 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -616,8 +616,8 @@ invoke it. If KEYS is omitted or nil, the return value of
616 Fput_text_property (make_number (0), 616 Fput_text_property (make_number (0),
617 make_number (SCHARS (callint_message)), 617 make_number (SCHARS (callint_message)),
618 Qface, Qminibuffer_prompt, callint_message); 618 Qface, Qminibuffer_prompt, callint_message);
619 args[i] = Fread_key_sequence (callint_message, 619 args[i] = Fread_key_sequence_vector (callint_message,
620 Qnil, Qt, Qnil, Qnil); 620 Qnil, Qt, Qnil, Qnil);
621 teml = args[i]; 621 teml = args[i];
622 visargs[i] = Fkey_description (teml, Qnil); 622 visargs[i] = Fkey_description (teml, Qnil);
623 unbind_to (speccount1, Qnil); 623 unbind_to (speccount1, Qnil);
diff --git a/src/cmds.c b/src/cmds.c
index ce91877f85e..aeedb152f62 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -121,9 +121,7 @@ With positive N, a non-empty line at the end counts as one line
121successfully moved (for the return value). */) 121successfully moved (for the return value). */)
122 (Lisp_Object n) 122 (Lisp_Object n)
123{ 123{
124 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 124 ptrdiff_t opoint = PT, pos, pos_byte, shortage, count;
125 ptrdiff_t pos, pos_byte;
126 EMACS_INT count, shortage;
127 125
128 if (NILP (n)) 126 if (NILP (n))
129 count = 1; 127 count = 1;
@@ -134,16 +132,12 @@ successfully moved (for the return value). */)
134 } 132 }
135 133
136 if (count <= 0) 134 if (count <= 0)
137 shortage = scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1, 1); 135 pos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
136 &shortage, &pos_byte, 1);
138 else 137 else
139 shortage = scan_newline (PT, PT_BYTE, ZV, ZV_BYTE, count, 1); 138 pos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
140 139 &shortage, &pos_byte, 1);
141 /* Since scan_newline does TEMP_SET_PT_BOTH, 140
142 and we want to set PT "for real",
143 go back to the old point and then come back here. */
144 pos = PT;
145 pos_byte = PT_BYTE;
146 TEMP_SET_PT_BOTH (opoint, opoint_byte);
147 SET_PT_BOTH (pos, pos_byte); 141 SET_PT_BOTH (pos, pos_byte);
148 142
149 if (shortage > 0 143 if (shortage > 0
@@ -310,7 +304,7 @@ At the end, it runs `post-self-insert-hook'. */)
310 /* Barf if the key that invoked this was not a character. */ 304 /* Barf if the key that invoked this was not a character. */
311 if (!CHARACTERP (last_command_event)) 305 if (!CHARACTERP (last_command_event))
312 bitch_at_user (); 306 bitch_at_user ();
313 { 307 else {
314 int character = translate_char (Vtranslation_table_for_input, 308 int character = translate_char (Vtranslation_table_for_input,
315 XINT (last_command_event)); 309 XINT (last_command_event));
316 int val = internal_self_insert (character, XFASTINT (n)); 310 int val = internal_self_insert (character, XFASTINT (n));
diff --git a/src/coding.h b/src/coding.h
index 7b7078e06fa..2c01a05d197 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -378,8 +378,6 @@ struct emacs_mule_spec
378 struct composition_status cmp_status; 378 struct composition_status cmp_status;
379}; 379};
380 380
381struct ccl_spec;
382
383struct undecided_spec 381struct undecided_spec
384{ 382{
385 /* Inhibit null byte detection. 1 means always inhibit, 383 /* Inhibit null byte detection. 1 means always inhibit,
diff --git a/src/composite.h b/src/composite.h
index 53665b36bd1..df170093797 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -25,6 +25,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#ifndef EMACS_COMPOSITE_H 25#ifndef EMACS_COMPOSITE_H
26#define EMACS_COMPOSITE_H 26#define EMACS_COMPOSITE_H
27 27
28#include "font.h"
29
28INLINE_HEADER_BEGIN 30INLINE_HEADER_BEGIN
29#ifndef COMPOSITE_INLINE 31#ifndef COMPOSITE_INLINE
30# define COMPOSITE_INLINE INLINE 32# define COMPOSITE_INLINE INLINE
@@ -312,10 +314,6 @@ enum lglyph_indices
312#define LGLYPH_WADJUST(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \ 314#define LGLYPH_WADJUST(g) (VECTORP (LGLYPH_ADJUSTMENT (g)) \
313 ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 2)) : 0) 315 ? XINT (AREF (LGLYPH_ADJUSTMENT (g), 2)) : 0)
314 316
315struct composition_it;
316struct face;
317struct font_metrics;
318
319extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t); 317extern Lisp_Object composition_gstring_put_cache (Lisp_Object, ptrdiff_t);
320extern Lisp_Object composition_gstring_from_id (ptrdiff_t); 318extern Lisp_Object composition_gstring_from_id (ptrdiff_t);
321extern bool composition_gstring_p (Lisp_Object); 319extern bool composition_gstring_p (Lisp_Object);
diff --git a/src/dispextern.h b/src/dispextern.h
index c32577c41dc..e9f57d9fa22 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -223,8 +223,16 @@ struct text_pos
223/* Set text position POS from marker MARKER. */ 223/* Set text position POS from marker MARKER. */
224 224
225#define SET_TEXT_POS_FROM_MARKER(POS, MARKER) \ 225#define SET_TEXT_POS_FROM_MARKER(POS, MARKER) \
226 (CHARPOS (POS) = marker_position ((MARKER)), \ 226 (CHARPOS (POS) = marker_position (MARKER), \
227 BYTEPOS (POS) = marker_byte_position ((MARKER))) 227 BYTEPOS (POS) = marker_byte_position (MARKER))
228
229/* Like above, but clip POS within accessible range. */
230
231#define CLIP_TEXT_POS_FROM_MARKER(POS, MARKER) \
232 (CHARPOS (POS) = clip_to_bounds \
233 (BEGV, marker_position (MARKER), ZV), \
234 BYTEPOS (POS) = clip_to_bounds \
235 (BEGV_BYTE, marker_byte_position (MARKER), ZV_BYTE))
228 236
229/* Set marker MARKER from text position POS. */ 237/* Set marker MARKER from text position POS. */
230 238
@@ -758,11 +766,12 @@ void check_matrix_pointer_lossage (struct glyph_matrix *);
758 Glyph Rows 766 Glyph Rows
759 ***********************************************************************/ 767 ***********************************************************************/
760 768
761/* Area in window glyph matrix. If values are added or removed, the 769/* Area in window glyph matrix. If values are added or removed,
762 function mark_object in alloc.c has to be changed. */ 770 the function mark_glyph_matrix in alloc.c may need to be changed. */
763 771
764enum glyph_row_area 772enum glyph_row_area
765{ 773{
774 ANY_AREA = -1,
766 LEFT_MARGIN_AREA, 775 LEFT_MARGIN_AREA,
767 TEXT_AREA, 776 TEXT_AREA,
768 RIGHT_MARGIN_AREA, 777 RIGHT_MARGIN_AREA,
@@ -1193,12 +1202,6 @@ struct glyph_row *matrix_row (struct glyph_matrix *, int);
1193 ((ROW)->phys_height - (ROW)->phys_ascent \ 1202 ((ROW)->phys_height - (ROW)->phys_ascent \
1194 > (ROW)->height - (ROW)->ascent) 1203 > (ROW)->height - (ROW)->ascent)
1195 1204
1196/* True means that fonts have been loaded since the last glyph
1197 matrix adjustments. The function redisplay_internal adjusts glyph
1198 matrices when this flag is true. */
1199
1200extern bool fonts_changed_p;
1201
1202/* A glyph for a space. */ 1205/* A glyph for a space. */
1203 1206
1204extern struct glyph space_glyph; 1207extern struct glyph space_glyph;
@@ -1429,31 +1432,31 @@ struct glyph_string
1429#define CURRENT_MODE_LINE_FACE_ID(W) \ 1432#define CURRENT_MODE_LINE_FACE_ID(W) \
1430 (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W))) 1433 (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W)))
1431 1434
1432/* Return the current height of the mode line of window W. If not 1435/* Return the current height of the mode line of window W. If not known
1433 known from current_mode_line_height, look at W's current glyph 1436 from W->mode_line_height, look at W's current glyph matrix, or return
1434 matrix, or return a default based on the height of the font of the 1437 a default based on the height of the font of the face `mode-line'. */
1435 face `mode-line'. */
1436 1438
1437#define CURRENT_MODE_LINE_HEIGHT(W) \ 1439#define CURRENT_MODE_LINE_HEIGHT(W) \
1438 (current_mode_line_height >= 0 \ 1440 (W->mode_line_height >= 0 \
1439 ? current_mode_line_height \ 1441 ? W->mode_line_height \
1440 : (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ 1442 : (W->mode_line_height \
1441 ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ 1443 = (MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \
1442 : estimate_mode_line_height (XFRAME ((W)->frame), \ 1444 ? MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \
1443 CURRENT_MODE_LINE_FACE_ID (W)))) 1445 : estimate_mode_line_height \
1446 (XFRAME (W->frame), CURRENT_MODE_LINE_FACE_ID (W)))))
1444 1447
1445/* Return the current height of the header line of window W. If not 1448/* Return the current height of the header line of window W. If not known
1446 known from current_header_line_height, look at W's current glyph 1449 from W->header_line_height, look at W's current glyph matrix, or return
1447 matrix, or return an estimation based on the height of the font of 1450 an estimation based on the height of the font of the face `header-line'. */
1448 the face `header-line'. */
1449 1451
1450#define CURRENT_HEADER_LINE_HEIGHT(W) \ 1452#define CURRENT_HEADER_LINE_HEIGHT(W) \
1451 (current_header_line_height >= 0 \ 1453 (W->header_line_height >= 0 \
1452 ? current_header_line_height \ 1454 ? W->header_line_height \
1453 : (MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \ 1455 : (W->header_line_height \
1454 ? MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \ 1456 = (MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \
1455 : estimate_mode_line_height (XFRAME ((W)->frame), \ 1457 ? MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \
1456 HEADER_LINE_FACE_ID))) 1458 : estimate_mode_line_height \
1459 (XFRAME (W->frame), HEADER_LINE_FACE_ID))))
1457 1460
1458/* Return the height of the desired mode line of window W. */ 1461/* Return the height of the desired mode line of window W. */
1459 1462
@@ -2818,19 +2821,9 @@ struct redisplay_interface
2818 void (*update_window_end_hook) (struct window *w, bool cursor_on_p, 2821 void (*update_window_end_hook) (struct window *w, bool cursor_on_p,
2819 bool mouse_face_overwritten_p); 2822 bool mouse_face_overwritten_p);
2820 2823
2821 /* Move cursor to row/column position VPOS/HPOS, pixel coordinates
2822 Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
2823 are window-relative pixel positions. */
2824 void (*cursor_to) (struct window *w, int vpos, int hpos, int y, int x);
2825
2826 /* Flush the display of frame F. For X, this is XFlush. */ 2824 /* Flush the display of frame F. For X, this is XFlush. */
2827 void (*flush_display) (struct frame *f); 2825 void (*flush_display) (struct frame *f);
2828 2826
2829 /* Flush the display of frame F if non-NULL. This is called
2830 during redisplay, and should be NULL on systems which flush
2831 automatically before reading input. */
2832 void (*flush_display_optional) (struct frame *f);
2833
2834 /* Clear the mouse highlight in window W, if there is any. */ 2827 /* Clear the mouse highlight in window W, if there is any. */
2835 void (*clear_window_mouse_face) (struct window *w); 2828 void (*clear_window_mouse_face) (struct window *w);
2836 2829
@@ -2901,11 +2894,6 @@ struct redisplay_interface
2901 2894
2902#ifdef HAVE_WINDOW_SYSTEM 2895#ifdef HAVE_WINDOW_SYSTEM
2903 2896
2904/* Structure forward declarations. */
2905
2906struct image;
2907
2908
2909/* Each image format (JPEG, TIFF, ...) supported is described by 2897/* Each image format (JPEG, TIFF, ...) supported is described by
2910 a structure of the type below. */ 2898 a structure of the type below. */
2911 2899
@@ -3196,14 +3184,15 @@ int resize_mini_window (struct window *, int);
3196void set_vertical_scroll_bar (struct window *); 3184void set_vertical_scroll_bar (struct window *);
3197#endif 3185#endif
3198int try_window (Lisp_Object, struct text_pos, int); 3186int try_window (Lisp_Object, struct text_pos, int);
3199void window_box (struct window *, int, int *, int *, int *, int *); 3187void window_box (struct window *, enum glyph_row_area,
3188 int *, int *, int *, int *);
3200int window_box_height (struct window *); 3189int window_box_height (struct window *);
3201int window_text_bottom_y (struct window *); 3190int window_text_bottom_y (struct window *);
3202int window_box_width (struct window *, int); 3191int window_box_width (struct window *, enum glyph_row_area);
3203int window_box_left (struct window *, int); 3192int window_box_left (struct window *, enum glyph_row_area);
3204int window_box_left_offset (struct window *, int); 3193int window_box_left_offset (struct window *, enum glyph_row_area);
3205int window_box_right (struct window *, int); 3194int window_box_right (struct window *, enum glyph_row_area);
3206int window_box_right_offset (struct window *, int); 3195int window_box_right_offset (struct window *, enum glyph_row_area);
3207int estimate_mode_line_height (struct frame *, enum face_id); 3196int estimate_mode_line_height (struct frame *, enum face_id);
3208void pixel_to_glyph_coords (struct frame *, int, int, int *, int *, 3197void pixel_to_glyph_coords (struct frame *, int, int, int *, int *,
3209 NativeRectangle *, int); 3198 NativeRectangle *, int);
@@ -3229,7 +3218,6 @@ int frame_mode_line_height (struct frame *);
3229extern Lisp_Object Qtool_bar; 3218extern Lisp_Object Qtool_bar;
3230extern bool redisplaying_p; 3219extern bool redisplaying_p;
3231extern int help_echo_showing_p; 3220extern int help_echo_showing_p;
3232extern int current_mode_line_height, current_header_line_height;
3233extern Lisp_Object help_echo_string, help_echo_window; 3221extern Lisp_Object help_echo_string, help_echo_window;
3234extern Lisp_Object help_echo_object, previous_help_echo_string; 3222extern Lisp_Object help_echo_object, previous_help_echo_string;
3235extern ptrdiff_t help_echo_pos; 3223extern ptrdiff_t help_echo_pos;
@@ -3243,6 +3231,7 @@ extern ptrdiff_t compute_display_string_pos (struct text_pos *,
3243extern ptrdiff_t compute_display_string_end (ptrdiff_t, 3231extern ptrdiff_t compute_display_string_end (ptrdiff_t,
3244 struct bidi_string_data *); 3232 struct bidi_string_data *);
3245extern void produce_stretch_glyph (struct it *); 3233extern void produce_stretch_glyph (struct it *);
3234extern int merge_glyphless_glyph_face (struct it *);
3246 3235
3247#ifdef HAVE_WINDOW_SYSTEM 3236#ifdef HAVE_WINDOW_SYSTEM
3248 3237
@@ -3260,9 +3249,6 @@ extern void x_insert_glyphs (struct window *, struct glyph_row *,
3260 struct glyph *, enum glyph_row_area, int); 3249 struct glyph *, enum glyph_row_area, int);
3261extern void x_clear_end_of_line (struct window *, struct glyph_row *, 3250extern void x_clear_end_of_line (struct window *, struct glyph_row *,
3262 enum glyph_row_area, int); 3251 enum glyph_row_area, int);
3263
3264extern struct cursor_pos output_cursor;
3265
3266extern void x_fix_overlapping_area (struct window *, struct glyph_row *, 3252extern void x_fix_overlapping_area (struct window *, struct glyph_row *,
3267 enum glyph_row_area, int); 3253 enum glyph_row_area, int);
3268extern void draw_phys_cursor_glyph (struct window *, 3254extern void draw_phys_cursor_glyph (struct window *,
@@ -3272,10 +3258,6 @@ extern void get_phys_cursor_geometry (struct window *, struct glyph_row *,
3272 struct glyph *, int *, int *, int *); 3258 struct glyph *, int *, int *, int *);
3273extern void erase_phys_cursor (struct window *); 3259extern void erase_phys_cursor (struct window *);
3274extern void display_and_set_cursor (struct window *, bool, int, int, int, int); 3260extern void display_and_set_cursor (struct window *, bool, int, int, int, int);
3275
3276extern void set_output_cursor (struct cursor_pos *);
3277extern void x_cursor_to (struct window *, int, int, int, int);
3278
3279extern void x_update_cursor (struct frame *, bool); 3261extern void x_update_cursor (struct frame *, bool);
3280extern void x_clear_cursor (struct window *); 3262extern void x_clear_cursor (struct window *);
3281extern void x_draw_vertical_border (struct window *w); 3263extern void x_draw_vertical_border (struct window *w);
@@ -3439,8 +3421,6 @@ extern frame_parm_handler x_frame_parm_handlers[];
3439extern void start_hourglass (void); 3421extern void start_hourglass (void);
3440extern void cancel_hourglass (void); 3422extern void cancel_hourglass (void);
3441extern int hourglass_shown_p; 3423extern int hourglass_shown_p;
3442
3443struct atimer; /* Defined in atimer.h. */
3444/* If non-null, an asynchronous timer that, when it expires, displays 3424/* If non-null, an asynchronous timer that, when it expires, displays
3445 an hourglass cursor on all frames. */ 3425 an hourglass cursor on all frames. */
3446extern struct atimer *hourglass_atimer; 3426extern struct atimer *hourglass_atimer;
@@ -3492,7 +3472,7 @@ extern void cancel_line (int, struct frame *);
3492extern void init_desired_glyphs (struct frame *); 3472extern void init_desired_glyphs (struct frame *);
3493extern bool update_frame (struct frame *, bool, bool); 3473extern bool update_frame (struct frame *, bool, bool);
3494extern void bitch_at_user (void); 3474extern void bitch_at_user (void);
3495void adjust_glyphs (struct frame *); 3475extern void adjust_frame_glyphs (struct frame *);
3496void free_glyphs (struct frame *); 3476void free_glyphs (struct frame *);
3497void free_window_matrices (struct window *); 3477void free_window_matrices (struct window *);
3498void check_glyph_memory (void); 3478void check_glyph_memory (void);
diff --git a/src/dispnew.c b/src/dispnew.c
index 096416db56e..c239d7ab745 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -80,7 +80,6 @@ struct dim
80static void update_frame_line (struct frame *, int); 80static void update_frame_line (struct frame *, int);
81static int required_matrix_height (struct window *); 81static int required_matrix_height (struct window *);
82static int required_matrix_width (struct window *); 82static int required_matrix_width (struct window *);
83static void adjust_frame_glyphs (struct frame *);
84static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool); 83static void change_frame_size_1 (struct frame *, int, int, bool, bool, bool);
85static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t); 84static void increment_row_positions (struct glyph_row *, ptrdiff_t, ptrdiff_t);
86static void fill_up_frame_row_with_spaces (struct glyph_row *, int); 85static void fill_up_frame_row_with_spaces (struct glyph_row *, int);
@@ -155,16 +154,6 @@ static int glyph_pool_count;
155 154
156static struct frame *frame_matrix_frame; 155static struct frame *frame_matrix_frame;
157 156
158/* True means that fonts have been loaded since the last glyph
159 matrix adjustments. Redisplay must stop, and glyph matrices must
160 be adjusted when this flag becomes true during display. The
161 reason fonts can be loaded so late is that fonts of fontsets are
162 loaded on demand. Another reason is that a line contains many
163 characters displayed by zero width or very narrow glyphs of
164 variable-width fonts. */
165
166bool fonts_changed_p;
167
168/* Convert vpos and hpos from frame to window and vice versa. 157/* Convert vpos and hpos from frame to window and vice versa.
169 This may only be used for terminal frames. */ 158 This may only be used for terminal frames. */
170 159
@@ -415,7 +404,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
415 Get W's size. */ 404 Get W's size. */
416 if (w) 405 if (w)
417 { 406 {
418 window_box (w, -1, 0, 0, &window_width, &window_height); 407 window_box (w, ANY_AREA, 0, 0, &window_width, &window_height);
419 408
420 header_line_p = WINDOW_WANTS_HEADER_LINE_P (w); 409 header_line_p = WINDOW_WANTS_HEADER_LINE_P (w);
421 header_line_changed_p = header_line_p != matrix->header_line_p; 410 header_line_changed_p = header_line_p != matrix->header_line_p;
@@ -435,7 +424,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
435 || right != matrix->right_margin_glyphs); 424 || right != matrix->right_margin_glyphs);
436 425
437 if (!marginal_areas_changed_p 426 if (!marginal_areas_changed_p
438 && !fonts_changed_p 427 && !XFRAME (w->frame)->fonts_changed
439 && !header_line_changed_p 428 && !header_line_changed_p
440 && matrix->window_left_col == WINDOW_LEFT_EDGE_COL (w) 429 && matrix->window_left_col == WINDOW_LEFT_EDGE_COL (w)
441 && matrix->window_top_line == WINDOW_TOP_EDGE_LINE (w) 430 && matrix->window_top_line == WINDOW_TOP_EDGE_LINE (w)
@@ -1801,37 +1790,17 @@ allocate_matrices_for_window_redisplay (struct window *w)
1801 } 1790 }
1802} 1791}
1803 1792
1804 1793/* Allocate/reallocate glyph matrices of a single frame F.
1805/* Re-allocate/ re-compute glyph matrices on frame F. If F is null, 1794 This function must be called when a new frame is created,
1806 do it for all frames; otherwise do it just for the given frame. 1795 its size changes, or its window configuration changes. */
1807 This function must be called when a new frame is created, its size
1808 changes, or its window configuration changes. */
1809 1796
1810void 1797void
1811adjust_glyphs (struct frame *f) 1798adjust_frame_glyphs (struct frame *f)
1812{ 1799{
1813 /* Block input so that expose events and other events that access 1800 /* Block input so that expose events and other events that access
1814 glyph matrices are not processed while we are changing them. */ 1801 glyph matrices are not processed while we are changing them. */
1815 block_input (); 1802 block_input ();
1816 1803
1817 if (f)
1818 adjust_frame_glyphs (f);
1819 else
1820 {
1821 Lisp_Object tail, lisp_frame;
1822
1823 FOR_EACH_FRAME (tail, lisp_frame)
1824 adjust_frame_glyphs (XFRAME (lisp_frame));
1825 }
1826
1827 unblock_input ();
1828}
1829
1830/* Allocate/reallocate glyph matrices of a single frame F. */
1831
1832static void
1833adjust_frame_glyphs (struct frame *f)
1834{
1835 if (FRAME_WINDOW_P (f)) 1804 if (FRAME_WINDOW_P (f))
1836 adjust_frame_glyphs_for_window_redisplay (f); 1805 adjust_frame_glyphs_for_window_redisplay (f);
1837 else 1806 else
@@ -1841,6 +1810,8 @@ adjust_frame_glyphs (struct frame *f)
1841 adjust_decode_mode_spec_buffer (f); 1810 adjust_decode_mode_spec_buffer (f);
1842 1811
1843 f->glyphs_initialized_p = 1; 1812 f->glyphs_initialized_p = 1;
1813
1814 unblock_input ();
1844} 1815}
1845 1816
1846/* Return true if any window in the tree has nonzero window margins. See 1817/* Return true if any window in the tree has nonzero window margins. See
@@ -3092,16 +3063,6 @@ update_frame (struct frame *f, bool force_p, bool inhibit_hairy_id_p)
3092 /* Update windows. */ 3063 /* Update windows. */
3093 paused_p = update_window_tree (root_window, force_p); 3064 paused_p = update_window_tree (root_window, force_p);
3094 update_end (f); 3065 update_end (f);
3095
3096 /* This flush is a performance bottleneck under X,
3097 and it doesn't seem to be necessary anyway (in general).
3098 It is necessary when resizing the window with the mouse, or
3099 at least the fringes are not redrawn in a timely manner. ++kfs */
3100 if (f->force_flush_display_p)
3101 {
3102 FRAME_RIF (f)->flush_display (f);
3103 f->force_flush_display_p = 0;
3104 }
3105 } 3066 }
3106 else 3067 else
3107 { 3068 {
@@ -3225,8 +3186,8 @@ redraw_overlapped_rows (struct window *w, int yb)
3225 3186
3226 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) 3187 for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
3227 { 3188 {
3228 FRAME_RIF (f)->cursor_to (w, i, 0, row->y, 3189 output_cursor_to (w, i, 0, row->y,
3229 area == TEXT_AREA ? row->x : 0); 3190 area == TEXT_AREA ? row->x : 0);
3230 if (row->used[area]) 3191 if (row->used[area])
3231 FRAME_RIF (f)->write_glyphs (w, row, row->glyphs[area], 3192 FRAME_RIF (f)->write_glyphs (w, row, row->glyphs[area],
3232 area, row->used[area]); 3193 area, row->used[area]);
@@ -3483,7 +3444,7 @@ update_window (struct window *w, bool force_p)
3483 /* End the update of window W. Don't set the cursor if we 3444 /* End the update of window W. Don't set the cursor if we
3484 paused updating the display because in this case, 3445 paused updating the display because in this case,
3485 set_window_cursor_after_update hasn't been called, and 3446 set_window_cursor_after_update hasn't been called, and
3486 output_cursor doesn't contain the cursor location. */ 3447 W->output_cursor doesn't contain the cursor location. */
3487 rif->update_window_end_hook (w, !paused_p, mouse_face_overwritten_p); 3448 rif->update_window_end_hook (w, !paused_p, mouse_face_overwritten_p);
3488 } 3449 }
3489 else 3450 else
@@ -3516,7 +3477,7 @@ update_marginal_area (struct window *w, struct glyph_row *updated_row,
3516 /* Set cursor to start of glyphs, write them, and clear to the end 3477 /* Set cursor to start of glyphs, write them, and clear to the end
3517 of the area. I don't think that something more sophisticated is 3478 of the area. I don't think that something more sophisticated is
3518 necessary here, since marginal areas will not be the default. */ 3479 necessary here, since marginal areas will not be the default. */
3519 rif->cursor_to (w, vpos, 0, desired_row->y, 0); 3480 output_cursor_to (w, vpos, 0, desired_row->y, 0);
3520 if (desired_row->used[area]) 3481 if (desired_row->used[area])
3521 rif->write_glyphs (w, updated_row, desired_row->glyphs[area], 3482 rif->write_glyphs (w, updated_row, desired_row->glyphs[area],
3522 area, desired_row->used[area]); 3483 area, desired_row->used[area]);
@@ -3554,7 +3515,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos)
3554 && !(current_row->mode_line_p && vpos > 0)) 3515 && !(current_row->mode_line_p && vpos > 0))
3555 || current_row->x != desired_row->x) 3516 || current_row->x != desired_row->x)
3556 { 3517 {
3557 rif->cursor_to (w, vpos, 0, desired_row->y, desired_row->x); 3518 output_cursor_to (w, vpos, 0, desired_row->y, desired_row->x);
3558 3519
3559 if (desired_row->used[TEXT_AREA]) 3520 if (desired_row->used[TEXT_AREA])
3560 rif->write_glyphs (w, updated_row, desired_row->glyphs[TEXT_AREA], 3521 rif->write_glyphs (w, updated_row, desired_row->glyphs[TEXT_AREA],
@@ -3697,7 +3658,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos)
3697 break; 3658 break;
3698 } 3659 }
3699 3660
3700 rif->cursor_to (w, vpos, start_hpos, desired_row->y, start_x); 3661 output_cursor_to (w, vpos, start_hpos, desired_row->y, start_x);
3701 rif->write_glyphs (w, updated_row, start, 3662 rif->write_glyphs (w, updated_row, start,
3702 TEXT_AREA, i - start_hpos); 3663 TEXT_AREA, i - start_hpos);
3703 changed_p = 1; 3664 changed_p = 1;
@@ -3707,7 +3668,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos)
3707 /* Write the rest. */ 3668 /* Write the rest. */
3708 if (i < desired_row->used[TEXT_AREA]) 3669 if (i < desired_row->used[TEXT_AREA])
3709 { 3670 {
3710 rif->cursor_to (w, vpos, i, desired_row->y, x); 3671 output_cursor_to (w, vpos, i, desired_row->y, x);
3711 rif->write_glyphs (w, updated_row, desired_glyph, 3672 rif->write_glyphs (w, updated_row, desired_glyph,
3712 TEXT_AREA, desired_row->used[TEXT_AREA] - i); 3673 TEXT_AREA, desired_row->used[TEXT_AREA] - i);
3713 changed_p = 1; 3674 changed_p = 1;
@@ -3729,8 +3690,8 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos)
3729 { 3690 {
3730 /* If old row extends to the end of the text area, clear. */ 3691 /* If old row extends to the end of the text area, clear. */
3731 if (i >= desired_row->used[TEXT_AREA]) 3692 if (i >= desired_row->used[TEXT_AREA])
3732 rif->cursor_to (w, vpos, i, desired_row->y, 3693 output_cursor_to (w, vpos, i, desired_row->y,
3733 desired_row->pixel_width); 3694 desired_row->pixel_width);
3734 rif->clear_end_of_line (w, updated_row, TEXT_AREA, -1); 3695 rif->clear_end_of_line (w, updated_row, TEXT_AREA, -1);
3735 changed_p = 1; 3696 changed_p = 1;
3736 } 3697 }
@@ -3741,8 +3702,8 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos)
3741 int xlim; 3702 int xlim;
3742 3703
3743 if (i >= desired_row->used[TEXT_AREA]) 3704 if (i >= desired_row->used[TEXT_AREA])
3744 rif->cursor_to (w, vpos, i, desired_row->y, 3705 output_cursor_to (w, vpos, i, desired_row->y,
3745 desired_row->pixel_width); 3706 desired_row->pixel_width);
3746 3707
3747 /* If cursor is displayed at the end of the line, make sure 3708 /* If cursor is displayed at the end of the line, make sure
3748 it's cleared. Nowadays we don't have a phys_cursor_glyph 3709 it's cleared. Nowadays we don't have a phys_cursor_glyph
@@ -3841,7 +3802,6 @@ static void
3841set_window_cursor_after_update (struct window *w) 3802set_window_cursor_after_update (struct window *w)
3842{ 3803{
3843 struct frame *f = XFRAME (w->frame); 3804 struct frame *f = XFRAME (w->frame);
3844 struct redisplay_interface *rif = FRAME_RIF (f);
3845 int cx, cy, vpos, hpos; 3805 int cx, cy, vpos, hpos;
3846 3806
3847 /* Not intended for frame matrix updates. */ 3807 /* Not intended for frame matrix updates. */
@@ -3913,7 +3873,7 @@ set_window_cursor_after_update (struct window *w)
3913 Horizontal position is -1 when cursor is on the left fringe. */ 3873 Horizontal position is -1 when cursor is on the left fringe. */
3914 hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1); 3874 hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1);
3915 vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1); 3875 vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1);
3916 rif->cursor_to (w, vpos, hpos, cy, cx); 3876 output_cursor_to (w, vpos, hpos, cy, cx);
3917} 3877}
3918 3878
3919 3879
@@ -5078,9 +5038,7 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
5078 wrong thing with `face-remapping-alist' (bug#2044). */ 5038 wrong thing with `face-remapping-alist' (bug#2044). */
5079 Fset_buffer (w->contents); 5039 Fset_buffer (w->contents);
5080 itdata = bidi_shelve_cache (); 5040 itdata = bidi_shelve_cache ();
5081 SET_TEXT_POS_FROM_MARKER (startp, w->start); 5041 CLIP_TEXT_POS_FROM_MARKER (startp, w->start);
5082 CHARPOS (startp) = min (ZV, max (BEGV, CHARPOS (startp)));
5083 BYTEPOS (startp) = min (ZV_BYTE, max (BEGV_BYTE, BYTEPOS (startp)));
5084 start_display (&it, w, startp); 5042 start_display (&it, w, startp);
5085 /* start_display takes into account the header-line row, but IT's 5043 /* start_display takes into account the header-line row, but IT's
5086 vpos still counts from the glyph row that includes the window's 5044 vpos still counts from the glyph row that includes the window's
@@ -5560,7 +5518,7 @@ change_frame_size_1 (struct frame *f, int newheight, int newwidth,
5560 w->cursor.vpos = w->cursor.y = 0; 5518 w->cursor.vpos = w->cursor.y = 0;
5561 } 5519 }
5562 5520
5563 adjust_glyphs (f); 5521 adjust_frame_glyphs (f);
5564 calculate_costs (f); 5522 calculate_costs (f);
5565 SET_FRAME_GARBAGED (f); 5523 SET_FRAME_GARBAGED (f);
5566 f->resized_p = 1; 5524 f->resized_p = 1;
@@ -6186,19 +6144,6 @@ WINDOW nil or omitted means report on the selected window. */)
6186{ 6144{
6187 return decode_any_window (window)->cursor_off_p ? Qnil : Qt; 6145 return decode_any_window (window)->cursor_off_p ? Qnil : Qt;
6188} 6146}
6189
6190DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
6191 Slast_nonminibuf_frame, 0, 0, 0,
6192 doc: /* Value is last nonminibuffer frame. */)
6193 (void)
6194{
6195 Lisp_Object frame = Qnil;
6196
6197 if (last_nonminibuf_frame)
6198 XSETFRAME (frame, last_nonminibuf_frame);
6199
6200 return frame;
6201}
6202 6147
6203/*********************************************************************** 6148/***********************************************************************
6204 Initialization 6149 Initialization
@@ -6217,7 +6162,6 @@ syms_of_display (void)
6217 defsubr (&Ssend_string_to_terminal); 6162 defsubr (&Ssend_string_to_terminal);
6218 defsubr (&Sinternal_show_cursor); 6163 defsubr (&Sinternal_show_cursor);
6219 defsubr (&Sinternal_show_cursor_p); 6164 defsubr (&Sinternal_show_cursor_p);
6220 defsubr (&Slast_nonminibuf_frame);
6221 6165
6222#ifdef GLYPH_DEBUG 6166#ifdef GLYPH_DEBUG
6223 defsubr (&Sdump_redisplay_history); 6167 defsubr (&Sdump_redisplay_history);
diff --git a/src/editfns.c b/src/editfns.c
index 9e36655f3d3..84a5c8395fc 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -233,26 +233,12 @@ Beginning of buffer is position (point-min), end is (point-max).
233The return value is POSITION. */) 233The return value is POSITION. */)
234 (register Lisp_Object position) 234 (register Lisp_Object position)
235{ 235{
236 ptrdiff_t pos; 236 if (MARKERP (position))
237 237 set_point_from_marker (position);
238 if (MARKERP (position) 238 else if (INTEGERP (position))
239 && current_buffer == XMARKER (position)->buffer) 239 SET_PT (clip_to_bounds (BEGV, XINT (position), ZV));
240 { 240 else
241 pos = marker_position (position); 241 wrong_type_argument (Qinteger_or_marker_p, position);
242 if (pos < BEGV)
243 SET_PT_BOTH (BEGV, BEGV_BYTE);
244 else if (pos > ZV)
245 SET_PT_BOTH (ZV, ZV_BYTE);
246 else
247 SET_PT_BOTH (pos, marker_byte_position (position));
248
249 return position;
250 }
251
252 CHECK_NUMBER_COERCE_MARKER (position);
253
254 pos = clip_to_bounds (BEGV, XINT (position), ZV);
255 SET_PT (pos);
256 return position; 242 return position;
257} 243}
258 244
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index 8635ab652ac..1e57eeb57c4 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -20,15 +20,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#include "emacsgtkfixed.h"
24#include <stdio.h>
25
26#include "lisp.h" 23#include "lisp.h"
27#include "frame.h" 24#include "frame.h"
28#include "xterm.h" 25#include "xterm.h"
29#ifdef HAVE_XWIDGETS 26#ifdef HAVE_XWIDGETS
30#include "xwidget.h" 27#include "xwidget.h"
31#endif 28#endif
29#include "emacsgtkfixed.h"
30
32/* Silence a bogus diagnostic; see GNOME bug 683906. */ 31/* Silence a bogus diagnostic; see GNOME bug 683906. */
33#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__) 32#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
34# pragma GCC diagnostic push 33# pragma GCC diagnostic push
diff --git a/src/eval.c b/src/eval.c
index 566be0c2a83..6e964f6604b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2033,7 +2033,9 @@ it is defines a macro. */)
2033 2033
2034DEFUN ("eval", Feval, Seval, 1, 2, 0, 2034DEFUN ("eval", Feval, Seval, 1, 2, 0,
2035 doc: /* Evaluate FORM and return its value. 2035 doc: /* Evaluate FORM and return its value.
2036If LEXICAL is t, evaluate using lexical scoping. */) 2036If LEXICAL is t, evaluate using lexical scoping.
2037LEXICAL can also be an actual lexical environment, in the form of an
2038alist mapping symbols to their value. */)
2037 (Lisp_Object form, Lisp_Object lexical) 2039 (Lisp_Object form, Lisp_Object lexical)
2038{ 2040{
2039 ptrdiff_t count = SPECPDL_INDEX (); 2041 ptrdiff_t count = SPECPDL_INDEX ();
@@ -2146,8 +2148,9 @@ eval_sub (Lisp_Object form)
2146 2148
2147 /* Optimize for no indirection. */ 2149 /* Optimize for no indirection. */
2148 fun = original_fun; 2150 fun = original_fun;
2149 if (SYMBOLP (fun) && !NILP (fun) 2151 if (!SYMBOLP (fun))
2150 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) 2152 fun = Ffunction (Fcons (fun, Qnil));
2153 else if (!NILP (fun) && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
2151 fun = indirect_function (fun); 2154 fun = indirect_function (fun);
2152 2155
2153 if (SUBRP (fun)) 2156 if (SUBRP (fun))
@@ -3151,20 +3154,17 @@ let_shadows_global_binding_p (Lisp_Object symbol)
3151 return 0; 3154 return 0;
3152} 3155}
3153 3156
3154/* `specpdl_ptr->symbol' is a field which describes which variable is 3157/* `specpdl_ptr' describes which variable is
3155 let-bound, so it can be properly undone when we unbind_to. 3158 let-bound, so it can be properly undone when we unbind_to.
3156 It can have the following two shapes: 3159 It can be either a plain SPECPDL_LET or a SPECPDL_LET_LOCAL/DEFAULT.
3157 - SYMBOL : if it's a plain symbol, it means that we have let-bound 3160 - SYMBOL is the variable being bound. Note that it should not be
3158 a symbol that is not buffer-local (at least at the time
3159 the let binding started). Note also that it should not be
3160 aliased (i.e. when let-binding V1 that's aliased to V2, we want 3161 aliased (i.e. when let-binding V1 that's aliased to V2, we want
3161 to record V2 here). 3162 to record V2 here).
3162 - (SYMBOL WHERE . BUFFER) : this means that it is a let-binding for 3163 - WHERE tells us in which buffer the binding took place.
3163 variable SYMBOL which can be buffer-local. WHERE tells us 3164 This is used for SPECPDL_LET_LOCAL bindings (i.e. bindings to a
3164 which buffer is affected (or nil if the let-binding affects the 3165 buffer-local variable) as well as for SPECPDL_LET_DEFAULT bindings,
3165 global value of the variable) and BUFFER tells us which buffer was 3166 i.e. bindings to the default value of a variable which can be
3166 current (i.e. if WHERE is non-nil, then BUFFER==WHERE, otherwise 3167 buffer-local. */
3167 BUFFER did not yet have a buffer-local value). */
3168 3168
3169void 3169void
3170specbind (Lisp_Object symbol, Lisp_Object value) 3170specbind (Lisp_Object symbol, Lisp_Object value)
diff --git a/src/fileio.c b/src/fileio.c
index a751a73ae50..0e6113f349d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -233,7 +233,7 @@ void
233restore_point_unwind (Lisp_Object location) 233restore_point_unwind (Lisp_Object location)
234{ 234{
235 Fgoto_char (location); 235 Fgoto_char (location);
236 Fset_marker (location, Qnil, Qnil); 236 unchain_marker (XMARKER (location));
237} 237}
238 238
239 239
diff --git a/src/font.c b/src/font.c
index 6a8262623dc..2606a25dff8 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2866,14 +2866,14 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
2866 { 2866 {
2867 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width; 2867 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width;
2868 FRAME_SMALLEST_FONT_HEIGHT (f) = height; 2868 FRAME_SMALLEST_FONT_HEIGHT (f) = height;
2869 fonts_changed_p = 1; 2869 f->fonts_changed = 1;
2870 } 2870 }
2871 else 2871 else
2872 { 2872 {
2873 if (FRAME_SMALLEST_CHAR_WIDTH (f) > min_width) 2873 if (FRAME_SMALLEST_CHAR_WIDTH (f) > min_width)
2874 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width, fonts_changed_p = 1; 2874 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width, f->fonts_changed = 1;
2875 if (FRAME_SMALLEST_FONT_HEIGHT (f) > height) 2875 if (FRAME_SMALLEST_FONT_HEIGHT (f) > height)
2876 FRAME_SMALLEST_FONT_HEIGHT (f) = height, fonts_changed_p = 1; 2876 FRAME_SMALLEST_FONT_HEIGHT (f) = height, f->fonts_changed = 1;
2877 } 2877 }
2878#endif 2878#endif
2879 2879
@@ -3379,9 +3379,11 @@ register_font_driver (struct font_driver *driver, struct frame *f)
3379 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; 3379 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list;
3380 struct font_driver_list *prev, *list; 3380 struct font_driver_list *prev, *list;
3381 3381
3382#ifdef HAVE_WINDOW_SYSTEM
3382 if (f && ! driver->draw) 3383 if (f && ! driver->draw)
3383 error ("Unusable font driver for a frame: %s", 3384 error ("Unusable font driver for a frame: %s",
3384 SDATA (SYMBOL_NAME (driver->type))); 3385 SDATA (SYMBOL_NAME (driver->type)));
3386#endif /* HAVE_WINDOW_SYSTEM */
3385 3387
3386 for (prev = NULL, list = root; list; prev = list, list = list->next) 3388 for (prev = NULL, list = root; list; prev = list, list = list->next)
3387 if (EQ (list->driver->type, driver->type)) 3389 if (EQ (list->driver->type, driver->type))
diff --git a/src/font.h b/src/font.h
index adb4a582fd8..3e0d97baaac 100644
--- a/src/font.h
+++ b/src/font.h
@@ -56,11 +56,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56 56
57extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; 57extern Lisp_Object Qfont_spec, Qfont_entity, Qfont_object;
58 58
59
60struct font_driver;
61struct font;
62struct glyph_string;
63
64/* An enumerator for each font property. This is used as an index to 59/* An enumerator for each font property. This is used as an index to
65 the vector of FONT-SPEC and FONT-ENTITY. 60 the vector of FONT-SPEC and FONT-ENTITY.
66 61
@@ -487,8 +482,6 @@ struct font_bitmap
487 this value. */ 482 this value. */
488#define FONT_PIXEL_SIZE_QUANTUM 1 483#define FONT_PIXEL_SIZE_QUANTUM 1
489 484
490struct face;
491
492#define FONT_INVALID_CODE 0xFFFFFFFF 485#define FONT_INVALID_CODE 0xFFFFFFFF
493 486
494/* Font driver. Members specified as "optional" can be NULL. */ 487/* Font driver. Members specified as "optional" can be NULL. */
@@ -582,6 +575,8 @@ struct font_driver
582 unsigned *code, int nglyphs, 575 unsigned *code, int nglyphs,
583 struct font_metrics *metrics); 576 struct font_metrics *metrics);
584 577
578#ifdef HAVE_WINDOW_SYSTEM
579
585 /* Optional. 580 /* Optional.
586 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel 581 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
587 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND, 582 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
@@ -602,6 +597,8 @@ struct font_driver
602 Free bitmap data in BITMAP. */ 597 Free bitmap data in BITMAP. */
603 void (*free_bitmap) (struct font *font, struct font_bitmap *bitmap); 598 void (*free_bitmap) (struct font *font, struct font_bitmap *bitmap);
604 599
600#endif /* HAVE_WINDOW_SYSTEM */
601
605 /* Optional. 602 /* Optional.
606 Return an outline data for glyph-code CODE of FONT. The format 603 Return an outline data for glyph-code CODE of FONT. The format
607 of the outline data depends on the font-driver. */ 604 of the outline data depends on the font-driver. */
diff --git a/src/fontset.c b/src/fontset.c
index 0bf716bf1b2..797d51ac0a7 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -39,17 +39,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include "intervals.h" 39#include "intervals.h"
40#include "fontset.h" 40#include "fontset.h"
41#include "window.h" 41#include "window.h"
42#ifdef HAVE_X_WINDOWS 42#ifdef HAVE_WINDOW_SYSTEM
43#include "xterm.h" 43#include TERM_HEADER
44#endif 44#endif /* HAVE_WINDOW_SYSTEM */
45#ifdef HAVE_NTGUI
46#include "w32term.h"
47#endif
48#ifdef HAVE_NS
49#include "nsterm.h"
50#endif
51#include "termhooks.h" 45#include "termhooks.h"
52
53#include "font.h" 46#include "font.h"
54 47
55/* FONTSET 48/* FONTSET
@@ -944,6 +937,19 @@ face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object o
944 if (ASCII_CHAR_P (c) || face->fontset < 0) 937 if (ASCII_CHAR_P (c) || face->fontset < 0)
945 return face->ascii_face->id; 938 return face->ascii_face->id;
946 939
940#ifdef HAVE_NS
941 if (face->font)
942 {
943 /* Fonts often have characters in other scripts, like symbol, even if they
944 don't match script: symbol. So check if the character is present
945 in the current face first. Only enable for NS for now, but should
946 perhaps be general? */
947 Lisp_Object font_object;
948 XSETFONT (font_object, face->font);
949 if (font_has_char (f, font_object, c)) return face->id;
950 }
951#endif
952
947 eassert (fontset_id_valid_p (face->fontset)); 953 eassert (fontset_id_valid_p (face->fontset));
948 fontset = FONTSET_FROM_ID (face->fontset); 954 fontset = FONTSET_FROM_ID (face->fontset);
949 eassert (!BASE_FONTSET_P (fontset)); 955 eassert (!BASE_FONTSET_P (fontset));
diff --git a/src/fontset.h b/src/fontset.h
index fd16c7178f5..b8ef4789e71 100644
--- a/src/fontset.h
+++ b/src/fontset.h
@@ -26,8 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#ifndef EMACS_FONTSET_H 26#ifndef EMACS_FONTSET_H
27#define EMACS_FONTSET_H 27#define EMACS_FONTSET_H
28 28
29struct face;
30
31extern void free_face_fontset (struct frame *, struct face *); 29extern void free_face_fontset (struct frame *, struct face *);
32extern int face_for_char (struct frame *, struct face *, int, 30extern int face_for_char (struct frame *, struct face *, int,
33 int, Lisp_Object); 31 int, Lisp_Object);
@@ -42,7 +40,6 @@ extern Lisp_Object Qlatin;
42extern Lisp_Object fontset_name (int); 40extern Lisp_Object fontset_name (int);
43extern Lisp_Object fontset_ascii (int); 41extern Lisp_Object fontset_ascii (int);
44 42
45struct font;
46extern int face_for_font (struct frame *, Lisp_Object, struct face *); 43extern int face_for_font (struct frame *, Lisp_Object, struct face *);
47 44
48#endif /* EMACS_FONTSET_H */ 45#endif /* EMACS_FONTSET_H */
diff --git a/src/frame.c b/src/frame.c
index 5ee421bb9bf..692d224866c 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -224,7 +224,7 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
224 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 224 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
225 FRAME_MENU_BAR_LINES (f) = nlines; 225 FRAME_MENU_BAR_LINES (f) = nlines;
226 set_menu_bar_lines_1 (f->root_window, nlines - olines); 226 set_menu_bar_lines_1 (f->root_window, nlines - olines);
227 adjust_glyphs (f); 227 adjust_frame_glyphs (f);
228 } 228 }
229} 229}
230 230
@@ -712,7 +712,7 @@ affects all frames on the same terminal device. */)
712 change_frame_size (f, height, width, 0, 0, 0); 712 change_frame_size (f, height, width, 0, 0, 0);
713 } 713 }
714 714
715 adjust_glyphs (f); 715 adjust_frame_glyphs (f);
716 calculate_costs (f); 716 calculate_costs (f);
717 XSETFRAME (frame, f); 717 XSETFRAME (frame, f);
718 718
@@ -1078,6 +1078,19 @@ Otherwise, include all frames. */)
1078 CHECK_LIVE_FRAME (frame); 1078 CHECK_LIVE_FRAME (frame);
1079 return prev_frame (frame, miniframe); 1079 return prev_frame (frame, miniframe);
1080} 1080}
1081
1082DEFUN ("last-nonminibuffer-frame", Flast_nonminibuf_frame,
1083 Slast_nonminibuf_frame, 0, 0, 0,
1084 doc: /* Return last non-minibuffer frame selected. */)
1085 (void)
1086{
1087 Lisp_Object frame = Qnil;
1088
1089 if (last_nonminibuf_frame)
1090 XSETFRAME (frame, last_nonminibuf_frame);
1091
1092 return frame;
1093}
1081 1094
1082/* Return 1 if it is ok to delete frame F; 1095/* Return 1 if it is ok to delete frame F;
1083 0 if all frames aside from F are invisible. 1096 0 if all frames aside from F are invisible.
@@ -1095,7 +1108,7 @@ other_visible_frames (struct frame *f)
1095 1108
1096 /* Verify that we can still talk to the frame's X window, 1109 /* Verify that we can still talk to the frame's X window,
1097 and note any recent change in visibility. */ 1110 and note any recent change in visibility. */
1098#ifdef HAVE_WINDOW_SYSTEM 1111#ifdef HAVE_X_WINDOWS
1099 if (FRAME_WINDOW_P (XFRAME (this))) 1112 if (FRAME_WINDOW_P (XFRAME (this)))
1100 x_sync (XFRAME (this)); 1113 x_sync (XFRAME (this));
1101#endif 1114#endif
@@ -1120,6 +1133,8 @@ check_minibuf_window (Lisp_Object frame, int select)
1120{ 1133{
1121 struct frame *f = decode_live_frame (frame); 1134 struct frame *f = decode_live_frame (frame);
1122 1135
1136 XSETFRAME (frame, f);
1137
1123 if (WINDOWP (minibuf_window) && EQ (f->minibuffer_window, minibuf_window)) 1138 if (WINDOWP (minibuf_window) && EQ (f->minibuffer_window, minibuf_window))
1124 { 1139 {
1125 Lisp_Object frames, this, window = make_number (0); 1140 Lisp_Object frames, this, window = make_number (0);
@@ -1137,9 +1152,8 @@ check_minibuf_window (Lisp_Object frame, int select)
1137 } 1152 }
1138 } 1153 }
1139 1154
1140 if (!WINDOWP (window)) 1155 /* Don't abort if no window was found (Bug#15247). */
1141 emacs_abort (); 1156 if (WINDOWP (window))
1142 else
1143 { 1157 {
1144 /* Use set_window_buffer instead of Fset_window_buffer (see 1158 /* Use set_window_buffer instead of Fset_window_buffer (see
1145 discussion of bug#11984, bug#12025, bug#12026). */ 1159 discussion of bug#11984, bug#12025, bug#12026). */
@@ -4493,6 +4507,7 @@ automatically. See also `mouse-autoselect-window'. */);
4493 defsubr (&Sframe_list); 4507 defsubr (&Sframe_list);
4494 defsubr (&Snext_frame); 4508 defsubr (&Snext_frame);
4495 defsubr (&Sprevious_frame); 4509 defsubr (&Sprevious_frame);
4510 defsubr (&Slast_nonminibuf_frame);
4496 defsubr (&Sdelete_frame); 4511 defsubr (&Sdelete_frame);
4497 defsubr (&Smouse_position); 4512 defsubr (&Smouse_position);
4498 defsubr (&Smouse_pixel_position); 4513 defsubr (&Smouse_pixel_position);
diff --git a/src/frame.h b/src/frame.h
index 2dcb7562524..87e218ee938 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -24,31 +24,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24#define EMACS_FRAME_H 24#define EMACS_FRAME_H
25 25
26#include "dispextern.h" 26#include "dispextern.h"
27#include "termhooks.h"
27 28
28INLINE_HEADER_BEGIN 29INLINE_HEADER_BEGIN
29#ifndef FRAME_INLINE 30#ifndef FRAME_INLINE
30# define FRAME_INLINE INLINE 31# define FRAME_INLINE INLINE
31#endif 32#endif
32 33
33
34/* Miscellanea. */
35
36/* Nonzero means there is at least one garbaged frame. */
37extern bool frame_garbaged;
38
39
40/* The structure representing a frame. */
41
42enum output_method
43{
44 output_initial,
45 output_termcap,
46 output_x_window,
47 output_msdos_raw,
48 output_w32,
49 output_ns
50};
51
52enum vertical_scroll_bar_type 34enum vertical_scroll_bar_type
53{ 35{
54 vertical_scroll_bar_none, 36 vertical_scroll_bar_none,
@@ -66,10 +48,7 @@ enum fullscreen_type
66 FULLSCREEN_WAIT = 0x100 48 FULLSCREEN_WAIT = 0x100
67}; 49};
68 50
69 51/* The structure representing a frame. */
70#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
71#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
72
73 52
74struct frame 53struct frame
75{ 54{
@@ -206,10 +185,6 @@ struct frame
206 Clear the frame in clear_garbaged_frames if set. */ 185 Clear the frame in clear_garbaged_frames if set. */
207 unsigned resized_p : 1; 186 unsigned resized_p : 1;
208 187
209 /* Set to non-zero in when we want for force a flush_display in
210 update_frame, usually after resizing the frame. */
211 unsigned force_flush_display_p : 1;
212
213 /* Set to non-zero if the default face for the frame has been 188 /* Set to non-zero if the default face for the frame has been
214 realized. Reset to zero whenever the default face changes. 189 realized. Reset to zero whenever the default face changes.
215 Used to see the difference between a font change and face change. */ 190 Used to see the difference between a font change and face change. */
@@ -231,6 +206,13 @@ struct frame
231 unsigned external_tool_bar : 1; 206 unsigned external_tool_bar : 1;
232#endif 207#endif
233 208
209 /* Nonzero means that fonts have been loaded since the last glyph
210 matrix adjustments. */
211 unsigned fonts_changed : 1;
212
213 /* Nonzero means that cursor type has been changed. */
214 unsigned cursor_type_changed : 1;
215
234 /* Margin at the top of the frame. Used to display the tool-bar. */ 216 /* Margin at the top of the frame. Used to display the tool-bar. */
235 int tool_bar_lines; 217 int tool_bar_lines;
236 218
@@ -884,6 +866,9 @@ default_pixels_per_inch_y (void)
884#define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width) 866#define FRAME_CURSOR_WIDTH(f) ((f)->cursor_width)
885#define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width) 867#define FRAME_BLINK_OFF_CURSOR_WIDTH(f) ((f)->blink_off_cursor_width)
886 868
869#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
870#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
871
887/* Return a pointer to the face cache of frame F. */ 872/* Return a pointer to the face cache of frame F. */
888 873
889#define FRAME_FACE_CACHE(F) (F)->face_cache 874#define FRAME_FACE_CACHE(F) (F)->face_cache
@@ -950,6 +935,9 @@ extern Lisp_Object Qtty_color_mode;
950extern Lisp_Object Qterminal; 935extern Lisp_Object Qterminal;
951extern Lisp_Object Qnoelisp; 936extern Lisp_Object Qnoelisp;
952 937
938/* Nonzero means there is at least one garbaged frame. */
939extern bool frame_garbaged;
940
953extern struct frame *last_nonminibuf_frame; 941extern struct frame *last_nonminibuf_frame;
954 942
955extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object); 943extern void set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
@@ -1251,7 +1239,6 @@ extern Lisp_Object display_x_get_resource (Display_Info *,
1251extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p); 1239extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
1252extern void x_set_window_size (struct frame *f, int change_grav, 1240extern void x_set_window_size (struct frame *f, int change_grav,
1253 int cols, int rows); 1241 int cols, int rows);
1254extern void x_sync (struct frame *);
1255extern Lisp_Object x_get_focus_frame (struct frame *); 1242extern Lisp_Object x_get_focus_frame (struct frame *);
1256extern void x_set_mouse_position (struct frame *f, int h, int v); 1243extern void x_set_mouse_position (struct frame *f, int h, int v);
1257extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); 1244extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
@@ -1277,13 +1264,24 @@ extern void x_wm_set_icon_position (struct frame *, int, int);
1277#if !defined USE_X_TOOLKIT 1264#if !defined USE_X_TOOLKIT
1278extern char *x_get_resource_string (const char *, const char *); 1265extern char *x_get_resource_string (const char *, const char *);
1279#endif 1266#endif
1280#endif 1267extern void x_sync (struct frame *);
1268#endif /* HAVE_X_WINDOWS */
1281 1269
1282extern void x_query_colors (struct frame *f, XColor *, int); 1270extern void x_query_colors (struct frame *f, XColor *, int);
1283extern void x_query_color (struct frame *f, XColor *); 1271extern void x_query_color (struct frame *f, XColor *);
1284 1272
1285#endif /* HAVE_WINDOW_SYSTEM */ 1273#endif /* HAVE_WINDOW_SYSTEM */
1286 1274
1275
1276FRAME_INLINE void
1277flush_frame (struct frame *f)
1278{
1279 struct redisplay_interface *rif = FRAME_RIF (f);
1280
1281 if (rif && rif->flush_display)
1282 rif->flush_display (f);
1283}
1284
1287/*********************************************************************** 1285/***********************************************************************
1288 Multimonitor data 1286 Multimonitor data
1289 ***********************************************************************/ 1287 ***********************************************************************/
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 8f13c72df81..7415c3a2413 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -249,7 +249,9 @@ WATCH-DESCRIPTOR should be an object returned by `gfile-add-watch'. */)
249void 249void
250globals_of_gfilenotify (void) 250globals_of_gfilenotify (void)
251{ 251{
252#if ! GLIB_CHECK_VERSION (2, 36, 0)
252 g_type_init (); 253 g_type_init ();
254#endif
253 watch_list = Qnil; 255 watch_list = Qnil;
254} 256}
255 257
diff --git a/src/gtkutil.c b/src/gtkutil.c
index f03ca592834..6228f2150f5 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -872,29 +872,23 @@ xg_clear_under_internal_border (struct frame *f)
872 if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) 872 if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0)
873 { 873 {
874 GtkWidget *wfixed = f->output_data.x->edit_widget; 874 GtkWidget *wfixed = f->output_data.x->edit_widget;
875
875 gtk_widget_queue_draw (wfixed); 876 gtk_widget_queue_draw (wfixed);
876 gdk_window_process_all_updates (); 877 gdk_window_process_all_updates ();
877 x_clear_area (FRAME_X_DISPLAY (f), 878
878 FRAME_X_WINDOW (f), 879 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 0, 0,
879 0, 0, 880 FRAME_PIXEL_WIDTH (f), FRAME_INTERNAL_BORDER_WIDTH (f));
880 FRAME_PIXEL_WIDTH (f), 881
881 FRAME_INTERNAL_BORDER_WIDTH (f), 0); 882 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 0, 0,
882 x_clear_area (FRAME_X_DISPLAY (f), 883 FRAME_INTERNAL_BORDER_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
883 FRAME_X_WINDOW (f), 884
884 0, 0, 885 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 0,
885 FRAME_INTERNAL_BORDER_WIDTH (f), 886 FRAME_PIXEL_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f),
886 FRAME_PIXEL_HEIGHT (f), 0); 887 FRAME_PIXEL_WIDTH (f), FRAME_INTERNAL_BORDER_WIDTH (f));
887 x_clear_area (FRAME_X_DISPLAY (f), 888
888 FRAME_X_WINDOW (f), 889 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
889 0, FRAME_PIXEL_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f), 890 FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f),
890 FRAME_PIXEL_WIDTH (f), 891 0, FRAME_INTERNAL_BORDER_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
891 FRAME_INTERNAL_BORDER_WIDTH (f), 0);
892 x_clear_area (FRAME_X_DISPLAY (f),
893 FRAME_X_WINDOW (f),
894 FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f),
895 0,
896 FRAME_INTERNAL_BORDER_WIDTH (f),
897 FRAME_PIXEL_HEIGHT (f), 0);
898 } 892 }
899} 893}
900 894
@@ -3751,14 +3745,11 @@ xg_update_scrollbar_pos (struct frame *f,
3751 gtk_widget_queue_draw (wfixed); 3745 gtk_widget_queue_draw (wfixed);
3752 gdk_window_process_all_updates (); 3746 gdk_window_process_all_updates ();
3753 if (oldx != -1 && oldw > 0 && oldh > 0) 3747 if (oldx != -1 && oldw > 0 && oldh > 0)
3754 { 3748 /* Clear under old scroll bar position. This must be done after
3755 /* Clear under old scroll bar position. This must be done after 3749 the gtk_widget_queue_draw and gdk_window_process_all_updates
3756 the gtk_widget_queue_draw and gdk_window_process_all_updates 3750 above. */
3757 above. */ 3751 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3758 x_clear_area (FRAME_X_DISPLAY (f), 3752 oldx, oldy, oldw, oldh);
3759 FRAME_X_WINDOW (f),
3760 oldx, oldy, oldw, oldh, 0);
3761 }
3762 3753
3763 /* GTK does not redraw until the main loop is entered again, but 3754 /* GTK does not redraw until the main loop is entered again, but
3764 if there are no X events pending we will not enter it. So we sync 3755 if there are no X events pending we will not enter it. So we sync
@@ -3792,7 +3783,7 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
3792 3783
3793 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 3784 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
3794 3785
3795 if (wscroll && NILP (bar->dragging)) 3786 if (wscroll && bar->dragging == -1)
3796 { 3787 {
3797 GtkAdjustment *adj; 3788 GtkAdjustment *adj;
3798 gdouble shown; 3789 gdouble shown;
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 482331a8934..fc959862fd3 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -74,8 +74,6 @@ typedef struct xg_menu_item_cb_data_
74 74
75} xg_menu_item_cb_data; 75} xg_menu_item_cb_data;
76 76
77struct _widget_value;
78
79extern struct _widget_value *malloc_widget_value (void); 77extern struct _widget_value *malloc_widget_value (void);
80extern void free_widget_value (struct _widget_value *); 78extern void free_widget_value (struct _widget_value *);
81 79
diff --git a/src/image.c b/src/image.c
index bcc0fcd78a3..1271376bcab 100644
--- a/src/image.c
+++ b/src/image.c
@@ -30,13 +30,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
30#endif 30#endif
31 31
32#include <setjmp.h> 32#include <setjmp.h>
33
34#include <c-ctype.h> 33#include <c-ctype.h>
35 34
36/* This makes the fields of a Display accessible, in Xlib header files. */
37
38#define XLIB_ILLEGAL_ACCESS
39
40#include "lisp.h" 35#include "lisp.h"
41#include "frame.h" 36#include "frame.h"
42#include "window.h" 37#include "window.h"
diff --git a/src/indent.c b/src/indent.c
index 6aaf86579d7..891b42788ed 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -510,15 +510,10 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol, ptrdiff_t *prevcol)
510 register ptrdiff_t col = 0, prev_col = 0; 510 register ptrdiff_t col = 0, prev_col = 0;
511 EMACS_INT goal = goalcol ? *goalcol : MOST_POSITIVE_FIXNUM; 511 EMACS_INT goal = goalcol ? *goalcol : MOST_POSITIVE_FIXNUM;
512 ptrdiff_t end = endpos ? *endpos : PT; 512 ptrdiff_t end = endpos ? *endpos : PT;
513 ptrdiff_t scan, scan_byte; 513 ptrdiff_t scan, scan_byte, next_boundary;
514 ptrdiff_t next_boundary; 514
515 { 515 scan = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, NULL, &scan_byte, 1);
516 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
517 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
518 scan = PT, scan_byte = PT_BYTE;
519 SET_PT_BOTH (opoint, opoint_byte);
520 next_boundary = scan; 516 next_boundary = scan;
521 }
522 517
523 window = Fget_buffer_window (Fcurrent_buffer (), Qnil); 518 window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
524 w = ! NILP (window) ? XWINDOW (window) : NULL; 519 w = ! NILP (window) ? XWINDOW (window) : NULL;
@@ -835,14 +830,10 @@ This is the horizontal position of the character
835following any initial whitespace. */) 830following any initial whitespace. */)
836 (void) 831 (void)
837{ 832{
838 Lisp_Object val; 833 ptrdiff_t posbyte;
839 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE;
840
841 scan_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, 1);
842 834
843 XSETFASTINT (val, position_indentation (PT_BYTE)); 835 find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, -1, NULL, &posbyte, 1);
844 SET_PT_BOTH (opoint, opoint_byte); 836 return make_number (position_indentation (posbyte));
845 return val;
846} 837}
847 838
848static ptrdiff_t 839static ptrdiff_t
@@ -935,16 +926,13 @@ position_indentation (ptrdiff_t pos_byte)
935bool 926bool
936indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column) 927indented_beyond_p (ptrdiff_t pos, ptrdiff_t pos_byte, EMACS_INT column)
937{ 928{
938 ptrdiff_t val; 929 while (pos > BEGV && FETCH_BYTE (pos_byte) == '\n')
939 ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; 930 {
940 931 DEC_BOTH (pos, pos_byte);
941 SET_PT_BOTH (pos, pos_byte); 932 pos = find_newline (pos, pos_byte, BEGV, BEGV_BYTE,
942 while (PT > BEGV && FETCH_BYTE (PT_BYTE) == '\n') 933 -1, NULL, &pos_byte, 0);
943 scan_newline (PT - 1, PT_BYTE - 1, BEGV, BEGV_BYTE, -1, 0); 934 }
944 935 return position_indentation (pos_byte) >= column;
945 val = position_indentation (PT_BYTE);
946 SET_PT_BOTH (opoint, opoint_byte);
947 return val >= column;
948} 936}
949 937
950DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2, 938DEFUN ("move-to-column", Fmove_to_column, Smove_to_column, 1, 2,
diff --git a/src/intervals.c b/src/intervals.c
index f2ddcd01507..ded536ca3c8 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1821,6 +1821,18 @@ set_point (ptrdiff_t charpos)
1821 set_point_both (charpos, buf_charpos_to_bytepos (current_buffer, charpos)); 1821 set_point_both (charpos, buf_charpos_to_bytepos (current_buffer, charpos));
1822} 1822}
1823 1823
1824/* Set PT from MARKER's clipped position. */
1825
1826void
1827set_point_from_marker (Lisp_Object marker)
1828{
1829 if (XMARKER (marker)->buffer != current_buffer)
1830 signal_error ("Marker points into wrong buffer", marker);
1831 set_point_both
1832 (clip_to_bounds (BEGV, marker_position (marker), ZV),
1833 clip_to_bounds (BEGV_BYTE, marker_byte_position (marker), ZV_BYTE));
1834}
1835
1824/* If there's an invisible character at position POS + TEST_OFFS in the 1836/* If there's an invisible character at position POS + TEST_OFFS in the
1825 current buffer, and the invisible property has a `stickiness' such that 1837 current buffer, and the invisible property has a `stickiness' such that
1826 inserting a character at position POS would inherit the property it, 1838 inserting a character at position POS would inherit the property it,
diff --git a/src/keyboard.c b/src/keyboard.c
index a2f772dea8a..5996986bfb4 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -425,7 +425,9 @@ static Lisp_Object modify_event_symbol (ptrdiff_t, int, Lisp_Object,
425 Lisp_Object *, ptrdiff_t); 425 Lisp_Object *, ptrdiff_t);
426static Lisp_Object make_lispy_switch_frame (Lisp_Object); 426static Lisp_Object make_lispy_switch_frame (Lisp_Object);
427static Lisp_Object make_lispy_focus_in (Lisp_Object); 427static Lisp_Object make_lispy_focus_in (Lisp_Object);
428#ifdef HAVE_WINDOW_SYSTEM
428static Lisp_Object make_lispy_focus_out (Lisp_Object); 429static Lisp_Object make_lispy_focus_out (Lisp_Object);
430#endif /* HAVE_WINDOW_SYSTEM */
429static bool help_char_p (Lisp_Object); 431static bool help_char_p (Lisp_Object);
430static void save_getcjmp (sys_jmp_buf); 432static void save_getcjmp (sys_jmp_buf);
431static void restore_getcjmp (sys_jmp_buf); 433static void restore_getcjmp (sys_jmp_buf);
@@ -3213,6 +3215,8 @@ read_char (int commandflag, Lisp_Object map,
3213 RETURN_UNGCPRO (c); 3215 RETURN_UNGCPRO (c);
3214} 3216}
3215 3217
3218#ifdef HAVE_MENUS
3219
3216/* Record a key that came from a mouse menu. 3220/* Record a key that came from a mouse menu.
3217 Record it for echoing, for this-command-keys, and so on. */ 3221 Record it for echoing, for this-command-keys, and so on. */
3218 3222
@@ -3248,6 +3252,8 @@ record_menu_key (Lisp_Object c)
3248 num_input_events++; 3252 num_input_events++;
3249} 3253}
3250 3254
3255#endif /* HAVE_MENUS */
3256
3251/* Return true if should recognize C as "the help character". */ 3257/* Return true if should recognize C as "the help character". */
3252 3258
3253static bool 3259static bool
@@ -6095,12 +6101,17 @@ make_lispy_focus_in (Lisp_Object frame)
6095{ 6101{
6096 return list2 (Qfocus_in, frame); 6102 return list2 (Qfocus_in, frame);
6097} 6103}
6104
6105#ifdef HAVE_WINDOW_SYSTEM
6106
6098static Lisp_Object 6107static Lisp_Object
6099make_lispy_focus_out (Lisp_Object frame) 6108make_lispy_focus_out (Lisp_Object frame)
6100{ 6109{
6101 return list2 (Qfocus_out, frame); 6110 return list2 (Qfocus_out, frame);
6102} 6111}
6103 6112
6113#endif /* HAVE_WINDOW_SYSTEM */
6114
6104/* Manipulating modifiers. */ 6115/* Manipulating modifiers. */
6105 6116
6106/* Parse the name of SYMBOL, and return the set of modifiers it contains. 6117/* Parse the name of SYMBOL, and return the set of modifiers it contains.
@@ -9738,54 +9749,11 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
9738 return t; 9749 return t;
9739} 9750}
9740 9751
9741DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0, 9752static Lisp_Object
9742 doc: /* Read a sequence of keystrokes and return as a string or vector. 9753read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
9743The sequence is sufficient to specify a non-prefix command in the 9754 Lisp_Object dont_downcase_last,
9744current local and global maps. 9755 Lisp_Object can_return_switch_frame,
9745 9756 Lisp_Object cmd_loop, bool allow_string)
9746First arg PROMPT is a prompt string. If nil, do not prompt specially.
9747Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos
9748as a continuation of the previous key.
9749
9750The third (optional) arg DONT-DOWNCASE-LAST, if non-nil, means do not
9751convert the last event to lower case. (Normally any upper case event
9752is converted to lower case if the original event is undefined and the lower
9753case equivalent is defined.) A non-nil value is appropriate for reading
9754a key sequence to be defined.
9755
9756A C-g typed while in this function is treated like any other character,
9757and `quit-flag' is not set.
9758
9759If the key sequence starts with a mouse click, then the sequence is read
9760using the keymaps of the buffer of the window clicked in, not the buffer
9761of the selected window as normal.
9762
9763`read-key-sequence' drops unbound button-down events, since you normally
9764only care about the click or drag events which follow them. If a drag
9765or multi-click event is unbound, but the corresponding click event would
9766be bound, `read-key-sequence' turns the event into a click event at the
9767drag's starting position. This means that you don't have to distinguish
9768between click and drag, double, or triple events unless you want to.
9769
9770`read-key-sequence' prefixes mouse events on mode lines, the vertical
9771lines separating windows, and scroll bars with imaginary keys
9772`mode-line', `vertical-line', and `vertical-scroll-bar'.
9773
9774Optional fourth argument CAN-RETURN-SWITCH-FRAME non-nil means that this
9775function will process a switch-frame event if the user switches frames
9776before typing anything. If the user switches frames in the middle of a
9777key sequence, or at the start of the sequence but CAN-RETURN-SWITCH-FRAME
9778is nil, then the event will be put off until after the current key sequence.
9779
9780`read-key-sequence' checks `function-key-map' for function key
9781sequences, where they wouldn't conflict with ordinary bindings. See
9782`function-key-map' for more details.
9783
9784The optional fifth argument CMD-LOOP, if non-nil, means
9785that this key sequence is being read by something that will
9786read commands one after another. It should be nil if the caller
9787will read just one key sequence. */)
9788 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9789{ 9757{
9790 Lisp_Object keybuf[30]; 9758 Lisp_Object keybuf[30];
9791 register int i; 9759 register int i;
@@ -9836,60 +9804,71 @@ will read just one key sequence. */)
9836 QUIT; 9804 QUIT;
9837 } 9805 }
9838 UNGCPRO; 9806 UNGCPRO;
9839 return unbind_to (count, make_event_array (i, keybuf)); 9807 return unbind_to (count,
9808 ((allow_string ? make_event_array : Fvector)
9809 (i, keybuf)));
9840} 9810}
9841 9811
9842DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector, 9812DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 5, 0,
9843 Sread_key_sequence_vector, 1, 5, 0, 9813 doc: /* Read a sequence of keystrokes and return as a string or vector.
9844 doc: /* Like `read-key-sequence' but always return a vector. */) 9814The sequence is sufficient to specify a non-prefix command in the
9845 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop) 9815current local and global maps.
9846{
9847 Lisp_Object keybuf[30];
9848 register int i;
9849 struct gcpro gcpro1;
9850 ptrdiff_t count = SPECPDL_INDEX ();
9851 9816
9852 if (!NILP (prompt)) 9817First arg PROMPT is a prompt string. If nil, do not prompt specially.
9853 CHECK_STRING (prompt); 9818Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos
9854 QUIT; 9819as a continuation of the previous key.
9855 9820
9856 specbind (Qinput_method_exit_on_first_char, 9821The third (optional) arg DONT-DOWNCASE-LAST, if non-nil, means do not
9857 (NILP (cmd_loop) ? Qt : Qnil)); 9822convert the last event to lower case. (Normally any upper case event
9858 specbind (Qinput_method_use_echo_area, 9823is converted to lower case if the original event is undefined and the lower
9859 (NILP (cmd_loop) ? Qt : Qnil)); 9824case equivalent is defined.) A non-nil value is appropriate for reading
9825a key sequence to be defined.
9860 9826
9861 memset (keybuf, 0, sizeof keybuf); 9827A C-g typed while in this function is treated like any other character,
9862 GCPRO1 (keybuf[0]); 9828and `quit-flag' is not set.
9863 gcpro1.nvars = (sizeof keybuf / sizeof (keybuf[0]));
9864 9829
9865 if (NILP (continue_echo)) 9830If the key sequence starts with a mouse click, then the sequence is read
9866 { 9831using the keymaps of the buffer of the window clicked in, not the buffer
9867 this_command_key_count = 0; 9832of the selected window as normal.
9868 this_command_key_count_reset = 0;
9869 this_single_command_key_start = 0;
9870 }
9871 9833
9872#ifdef HAVE_WINDOW_SYSTEM 9834`read-key-sequence' drops unbound button-down events, since you normally
9873 if (display_hourglass_p) 9835only care about the click or drag events which follow them. If a drag
9874 cancel_hourglass (); 9836or multi-click event is unbound, but the corresponding click event would
9875#endif 9837be bound, `read-key-sequence' turns the event into a click event at the
9838drag's starting position. This means that you don't have to distinguish
9839between click and drag, double, or triple events unless you want to.
9876 9840
9877 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 9841`read-key-sequence' prefixes mouse events on mode lines, the vertical
9878 prompt, ! NILP (dont_downcase_last), 9842lines separating windows, and scroll bars with imaginary keys
9879 ! NILP (can_return_switch_frame), 0); 9843`mode-line', `vertical-line', and `vertical-scroll-bar'.
9880 9844
9881#ifdef HAVE_WINDOW_SYSTEM 9845Optional fourth argument CAN-RETURN-SWITCH-FRAME non-nil means that this
9882 if (display_hourglass_p) 9846function will process a switch-frame event if the user switches frames
9883 start_hourglass (); 9847before typing anything. If the user switches frames in the middle of a
9884#endif 9848key sequence, or at the start of the sequence but CAN-RETURN-SWITCH-FRAME
9849is nil, then the event will be put off until after the current key sequence.
9885 9850
9886 if (i == -1) 9851`read-key-sequence' checks `function-key-map' for function key
9887 { 9852sequences, where they wouldn't conflict with ordinary bindings. See
9888 Vquit_flag = Qt; 9853`function-key-map' for more details.
9889 QUIT; 9854
9890 } 9855The optional fifth argument CMD-LOOP, if non-nil, means
9891 UNGCPRO; 9856that this key sequence is being read by something that will
9892 return unbind_to (count, Fvector (i, keybuf)); 9857read commands one after another. It should be nil if the caller
9858will read just one key sequence. */)
9859 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9860{
9861 return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
9862 can_return_switch_frame, cmd_loop, true);
9863}
9864
9865DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
9866 Sread_key_sequence_vector, 1, 5, 0,
9867 doc: /* Like `read-key-sequence' but always return a vector. */)
9868 (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcase_last, Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop)
9869{
9870 return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
9871 can_return_switch_frame, cmd_loop, false);
9893} 9872}
9894 9873
9895/* Return true if input events are pending. */ 9874/* Return true if input events are pending. */
@@ -9920,20 +9899,7 @@ detect_input_pending_run_timers (bool do_display)
9920 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW); 9899 get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW);
9921 9900
9922 if (old_timers_run != timers_run && do_display) 9901 if (old_timers_run != timers_run && do_display)
9923 { 9902 redisplay_preserve_echo_area (8);
9924 redisplay_preserve_echo_area (8);
9925 /* The following fixes a bug when using lazy-lock with
9926 lazy-lock-defer-on-the-fly set to t, i.e. when fontifying
9927 from an idle timer function. The symptom of the bug is that
9928 the cursor sometimes doesn't become visible until the next X
9929 event is processed. --gerd. */
9930 {
9931 Lisp_Object tail, frame;
9932 FOR_EACH_FRAME (tail, frame)
9933 if (FRAME_RIF (XFRAME (frame)))
9934 FRAME_RIF (XFRAME (frame))->flush_display (XFRAME (frame));
9935 }
9936 }
9937 9903
9938 return input_pending; 9904 return input_pending;
9939} 9905}
diff --git a/src/keyboard.h b/src/keyboard.h
index 0953f1b7cfd..1ee4a97c5c5 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -19,6 +19,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include "systime.h" /* for struct timespec, Time */ 20#include "systime.h" /* for struct timespec, Time */
21#include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */ 21#include "coding.h" /* for ENCODE_UTF_8 and ENCODE_SYSTEM */
22#include "termhooks.h"
22 23
23INLINE_HEADER_BEGIN 24INLINE_HEADER_BEGIN
24#ifndef KEYBOARD_INLINE 25#ifndef KEYBOARD_INLINE
@@ -477,9 +478,6 @@ extern bool ignore_mouse_drag_p;
477/* The primary selection. */ 478/* The primary selection. */
478extern Lisp_Object QPRIMARY; 479extern Lisp_Object QPRIMARY;
479 480
480/* Forward declaration for prototypes. */
481struct input_event;
482
483extern Lisp_Object parse_modifiers (Lisp_Object); 481extern Lisp_Object parse_modifiers (Lisp_Object);
484extern Lisp_Object reorder_modifiers (Lisp_Object); 482extern Lisp_Object reorder_modifiers (Lisp_Object);
485extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object, 483extern Lisp_Object read_char (int, Lisp_Object, Lisp_Object,
diff --git a/src/lisp.h b/src/lisp.h
index ef5e54d8cb6..dce1b17146b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -871,11 +871,7 @@ make_lisp_proc (struct Lisp_Process *p)
871#define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String)) 871#define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String))
872#define XSETSYMBOL(a, b) ((a) = make_lisp_ptr (b, Lisp_Symbol)) 872#define XSETSYMBOL(a, b) ((a) = make_lisp_ptr (b, Lisp_Symbol))
873#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float)) 873#define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float))
874
875/* Misc types. */
876
877#define XSETMISC(a, b) ((a) = make_lisp_ptr (b, Lisp_Misc)) 874#define XSETMISC(a, b) ((a) = make_lisp_ptr (b, Lisp_Misc))
878#define XSETMARKER(a, b) (XSETMISC (a, b), XMISCTYPE (a) = Lisp_Misc_Marker)
879 875
880/* Pseudovector types. */ 876/* Pseudovector types. */
881 877
@@ -2639,19 +2635,6 @@ typedef jmp_buf sys_jmp_buf;
2639 they are bound by a function application or a let form, stores the 2635 they are bound by a function application or a let form, stores the
2640 code to be executed for unwind-protect forms. 2636 code to be executed for unwind-protect forms.
2641 2637
2642 If func is non-zero, undoing this binding applies func to old_value;
2643 This implements record_unwind_protect.
2644
2645 Otherwise, the element is a variable binding.
2646
2647 If the symbol field is a symbol, it is an ordinary variable binding.
2648
2649 Otherwise, it should be a structure (SYMBOL WHERE . CURRENT-BUFFER),
2650 which means having bound a local value while CURRENT-BUFFER was active.
2651 If WHERE is nil this means we saw the default value when binding SYMBOL.
2652 WHERE being a buffer or frame means we saw a buffer-local or frame-local
2653 value. Other values of WHERE mean an internal error.
2654
2655 NOTE: The specbinding union is defined here, because SPECPDL_INDEX is 2638 NOTE: The specbinding union is defined here, because SPECPDL_INDEX is
2656 used all over the place, needs to be fast, and needs to know the size of 2639 used all over the place, needs to be fast, and needs to know the size of
2657 union specbinding. But only eval.c should access it. */ 2640 union specbinding. But only eval.c should access it. */
@@ -3381,9 +3364,6 @@ extern Lisp_Object Qglyphless_char;
3381extern Lisp_Object QCdata, QCfile; 3364extern Lisp_Object QCdata, QCfile;
3382extern Lisp_Object QCmap; 3365extern Lisp_Object QCmap;
3383extern Lisp_Object Qrisky_local_variable; 3366extern Lisp_Object Qrisky_local_variable;
3384extern struct frame *last_glyphless_glyph_frame;
3385extern int last_glyphless_glyph_face_id;
3386extern int last_glyphless_glyph_merged_face_id;
3387extern int noninteractive_need_newline; 3367extern int noninteractive_need_newline;
3388extern Lisp_Object echo_area_buffer[2]; 3368extern Lisp_Object echo_area_buffer[2];
3389extern void add_to_log (const char *, Lisp_Object, Lisp_Object); 3369extern void add_to_log (const char *, Lisp_Object, Lisp_Object);
@@ -3485,7 +3465,7 @@ build_unibyte_string (const char *str)
3485} 3465}
3486 3466
3487extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t); 3467extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t);
3488extern Lisp_Object make_event_array (int, Lisp_Object *); 3468extern Lisp_Object make_event_array (ptrdiff_t, Lisp_Object *);
3489extern Lisp_Object make_uninit_string (EMACS_INT); 3469extern Lisp_Object make_uninit_string (EMACS_INT);
3490extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT); 3470extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
3491extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t); 3471extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t);
@@ -3839,8 +3819,8 @@ extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
3839 ptrdiff_t, ptrdiff_t, Lisp_Object); 3819 ptrdiff_t, ptrdiff_t, Lisp_Object);
3840extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3820extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3841 ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool); 3821 ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool);
3842extern EMACS_INT scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, 3822extern ptrdiff_t scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
3843 EMACS_INT, bool); 3823 ptrdiff_t, bool);
3844extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t, 3824extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t,
3845 ptrdiff_t, ptrdiff_t *); 3825 ptrdiff_t, ptrdiff_t *);
3846extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t, 3826extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t,
diff --git a/src/minibuf.c b/src/minibuf.c
index 7403fc6c32d..cc6f234f7da 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -672,12 +672,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
672 XWINDOW (minibuf_window)->cursor.x = 0; 672 XWINDOW (minibuf_window)->cursor.x = 0;
673 XWINDOW (minibuf_window)->must_be_updated_p = 1; 673 XWINDOW (minibuf_window)->must_be_updated_p = 1;
674 update_frame (XFRAME (selected_frame), 1, 1); 674 update_frame (XFRAME (selected_frame), 1, 1);
675 { 675 flush_frame (XFRAME (XWINDOW (minibuf_window)->frame));
676 struct frame *f = XFRAME (XWINDOW (minibuf_window)->frame);
677 struct redisplay_interface *rif = FRAME_RIF (f);
678 if (rif && rif->flush_display)
679 rif->flush_display (f);
680 }
681 } 676 }
682 677
683 /* Make minibuffer contents into a string. */ 678 /* Make minibuffer contents into a string. */
diff --git a/src/msdos.c b/src/msdos.c
index 3c78efbc47b..7142c3ada77 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -946,9 +946,6 @@ IT_write_glyphs (struct frame *f, struct glyph *str, int str_len)
946 Mouse Highlight (and friends..) 946 Mouse Highlight (and friends..)
947 ************************************************************************/ 947 ************************************************************************/
948 948
949/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
950static Lisp_Object last_mouse_window;
951
952static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */ 949static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */
953 950
954int 951int
@@ -1546,11 +1543,6 @@ IT_reset_terminal_modes (struct terminal *term)
1546 term_setup_done = 0; 1543 term_setup_done = 0;
1547} 1544}
1548 1545
1549static void
1550IT_set_terminal_window (struct frame *f, int foo)
1551{
1552}
1553
1554/* Remember the screen colors of the current frame, to serve as the 1546/* Remember the screen colors of the current frame, to serve as the
1555 default colors for newly-created frames. */ 1547 default colors for newly-created frames. */
1556DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors, 1548DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors,
@@ -1871,7 +1863,7 @@ initialize_msdos_display (struct terminal *term)
1871 term->ring_bell_hook = IT_ring_bell; 1863 term->ring_bell_hook = IT_ring_bell;
1872 term->reset_terminal_modes_hook = IT_reset_terminal_modes; 1864 term->reset_terminal_modes_hook = IT_reset_terminal_modes;
1873 term->set_terminal_modes_hook = IT_set_terminal_modes; 1865 term->set_terminal_modes_hook = IT_set_terminal_modes;
1874 term->set_terminal_window_hook = IT_set_terminal_window; 1866 term->set_terminal_window_hook = NULL;
1875 term->update_begin_hook = IT_update_begin; 1867 term->update_begin_hook = IT_update_begin;
1876 term->update_end_hook = IT_update_end; 1868 term->update_end_hook = IT_update_end;
1877 term->frame_up_to_date_hook = IT_frame_up_to_date; 1869 term->frame_up_to_date_hook = IT_frame_up_to_date;
@@ -2673,10 +2665,10 @@ dos_rawgetc (void)
2673 /* Generate SELECT_WINDOW_EVENTs when needed. */ 2665 /* Generate SELECT_WINDOW_EVENTs when needed. */
2674 if (!NILP (Vmouse_autoselect_window)) 2666 if (!NILP (Vmouse_autoselect_window))
2675 { 2667 {
2676 mouse_window = window_from_coordinates (SELECTED_FRAME (), 2668 static Lisp_Object last_mouse_window;
2677 mouse_last_x, 2669
2678 mouse_last_y, 2670 mouse_window = window_from_coordinates
2679 0, 0); 2671 (SELECTED_FRAME (), mouse_last_x, mouse_last_y, 0, 0);
2680 /* A window will be selected only when it is not 2672 /* A window will be selected only when it is not
2681 selected now, and the last mouse movement event was 2673 selected now, and the last mouse movement event was
2682 not in it. A minibuffer window will be selected iff 2674 not in it. A minibuffer window will be selected iff
@@ -2691,10 +2683,9 @@ dos_rawgetc (void)
2691 event.timestamp = event_timestamp (); 2683 event.timestamp = event_timestamp ();
2692 kbd_buffer_store_event (&event); 2684 kbd_buffer_store_event (&event);
2693 } 2685 }
2686 /* Remember the last window where we saw the mouse. */
2694 last_mouse_window = mouse_window; 2687 last_mouse_window = mouse_window;
2695 } 2688 }
2696 else
2697 last_mouse_window = Qnil;
2698 2689
2699 previous_help_echo_string = help_echo_string; 2690 previous_help_echo_string = help_echo_string;
2700 help_echo_string = help_echo_object = help_echo_window = Qnil; 2691 help_echo_string = help_echo_object = help_echo_window = Qnil;
diff --git a/src/nsfns.m b/src/nsfns.m
index fc276c2b12d..f021e834d59 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2231,15 +2231,6 @@ x_get_focus_frame (struct frame *frame)
2231 return nsfocus; 2231 return nsfocus;
2232} 2232}
2233 2233
2234void
2235x_sync (struct frame *f)
2236{
2237 /* XXX Not implemented XXX */
2238 return;
2239}
2240
2241
2242
2243/* ========================================================================== 2234/* ==========================================================================
2244 2235
2245 Lisp definitions that, for whatever reason, we can't alias as 'ns-XXX'. 2236 Lisp definitions that, for whatever reason, we can't alias as 'ns-XXX'.
diff --git a/src/nsfont.m b/src/nsfont.m
index 235150e3aef..e1c7d32dde0 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -61,6 +61,7 @@ static void ns_uni_to_glyphs (struct nsfont_info *font_info,
61static void ns_glyph_metrics (struct nsfont_info *font_info, 61static void ns_glyph_metrics (struct nsfont_info *font_info,
62 unsigned char block); 62 unsigned char block);
63 63
64#define INVALID_GLYPH 0xFFFF
64 65
65/* ========================================================================== 66/* ==========================================================================
66 67
@@ -981,7 +982,7 @@ nsfont_encode_char (struct font *font, int c)
981 ns_uni_to_glyphs (font_info, high); 982 ns_uni_to_glyphs (font_info, high);
982 983
983 g = font_info->glyphs[high][low]; 984 g = font_info->glyphs[high][low];
984 return g == 0xFFFF ? FONT_INVALID_CODE : g; 985 return g == INVALID_GLYPH ? FONT_INVALID_CODE : g;
985} 986}
986 987
987 988
@@ -1354,8 +1355,8 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
1354#else 1355#else
1355 g = glyphStorage->cglyphs[i]; 1356 g = glyphStorage->cglyphs[i];
1356 /* TODO: is this a good check? maybe need to use coveredChars.. */ 1357 /* TODO: is this a good check? maybe need to use coveredChars.. */
1357 if (g > numGlyphs) 1358 if (g > numGlyphs || g == NSNullGlyph)
1358 g = 0xFFFF; /* hopefully unused... */ 1359 g = INVALID_GLYPH; /* hopefully unused... */
1359#endif 1360#endif
1360 *glyphs = g; 1361 *glyphs = g;
1361 } 1362 }
@@ -1483,7 +1484,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
1483 characterIndex: (NSUInteger)charIndex 1484 characterIndex: (NSUInteger)charIndex
1484{ 1485{
1485 len = glyphIndex+length; 1486 len = glyphIndex+length;
1486 for (i =glyphIndex; i<len; i++) 1487 for (i =glyphIndex; i<len; i++)
1487 cglyphs[i] = glyphs[i-glyphIndex]; 1488 cglyphs[i] = glyphs[i-glyphIndex];
1488 if (len > maxGlyph) 1489 if (len > maxGlyph)
1489 maxGlyph = len; 1490 maxGlyph = len;
diff --git a/src/nsterm.m b/src/nsterm.m
index ec365df0c22..38d76e9389c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -308,8 +308,13 @@ static CGPoint menu_mouse_point;
308/* This is a piece of code which is common to all the event handling 308/* This is a piece of code which is common to all the event handling
309 methods. Maybe it should even be a function. */ 309 methods. Maybe it should even be a function. */
310#define EV_TRAILER(e) \ 310#define EV_TRAILER(e) \
311 { \ 311 { \
312 XSETFRAME (emacs_event->frame_or_window, emacsframe); \ 312 XSETFRAME (emacs_event->frame_or_window, emacsframe); \
313 EV_TRAILER2 (e); \
314 }
315
316#define EV_TRAILER2(e) \
317 { \
313 if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \ 318 if (e) emacs_event->timestamp = EV_TIMESTAMP (e); \
314 if (q_event_ptr) \ 319 if (q_event_ptr) \
315 { \ 320 { \
@@ -720,7 +725,7 @@ ns_update_window_begin (struct window *w)
720 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 725 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
721 726
722 NSTRACE (ns_update_window_begin); 727 NSTRACE (ns_update_window_begin);
723 set_output_cursor (&w->cursor); 728 w->output_cursor = w->cursor;
724 729
725 block_input (); 730 block_input ();
726 731
@@ -756,8 +761,8 @@ ns_update_window_end (struct window *w, bool cursor_on_p,
756 761
757 if (cursor_on_p) 762 if (cursor_on_p)
758 display_and_set_cursor (w, 1, 763 display_and_set_cursor (w, 1,
759 output_cursor.hpos, output_cursor.vpos, 764 w->output_cursor.hpos, w->output_cursor.vpos,
760 output_cursor.x, output_cursor.y); 765 w->output_cursor.x, w->output_cursor.y);
761 766
762 if (draw_window_fringes (w, 1)) 767 if (draw_window_fringes (w, 1))
763 x_draw_vertical_border (w); 768 x_draw_vertical_border (w);
@@ -796,18 +801,6 @@ ns_update_end (struct frame *f)
796 NSTRACE (ns_update_end); 801 NSTRACE (ns_update_end);
797} 802}
798 803
799
800static void
801ns_flush (struct frame *f)
802/* --------------------------------------------------------------------------
803 external (RIF) call
804 NS impl is no-op since currently we flush in ns_update_end and elsewhere
805 -------------------------------------------------------------------------- */
806{
807 NSTRACE (ns_flush);
808}
809
810
811static void 804static void
812ns_focus (struct frame *f, NSRect *r, int n) 805ns_focus (struct frame *f, NSRect *r, int n)
813/* -------------------------------------------------------------------------- 806/* --------------------------------------------------------------------------
@@ -885,7 +878,8 @@ ns_unfocus (struct frame *f)
885 878
886 879
887static void 880static void
888ns_clip_to_row (struct window *w, struct glyph_row *row, int area, BOOL gc) 881ns_clip_to_row (struct window *w, struct glyph_row *row,
882 enum glyph_row_area area, BOOL gc)
889/* -------------------------------------------------------------------------- 883/* --------------------------------------------------------------------------
890 Internal (but parallels other terms): Focus drawing on given row 884 Internal (but parallels other terms): Focus drawing on given row
891 -------------------------------------------------------------------------- */ 885 -------------------------------------------------------------------------- */
@@ -954,24 +948,6 @@ ns_ring_bell (struct frame *f)
954 } 948 }
955} 949}
956 950
957
958static void
959ns_reset_terminal_modes (struct terminal *terminal)
960/* Externally called as hook */
961{
962 NSTRACE (ns_reset_terminal_modes);
963}
964
965
966static void
967ns_set_terminal_modes (struct terminal *terminal)
968/* Externally called as hook */
969{
970 NSTRACE (ns_set_terminal_modes);
971}
972
973
974
975/* ========================================================================== 951/* ==========================================================================
976 952
977 Frame / window manager related functions 953 Frame / window manager related functions
@@ -1989,9 +1965,6 @@ ns_clear_frame (struct frame *f)
1989 1965
1990 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); 1966 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
1991 1967
1992 output_cursor.hpos = output_cursor.vpos = 0;
1993 output_cursor.x = -1;
1994
1995 r = [view bounds]; 1968 r = [view bounds];
1996 1969
1997 block_input (); 1970 block_input ();
@@ -2047,7 +2020,7 @@ ns_scroll_run (struct window *w, struct run *run)
2047 /* Get frame-relative bounding box of the text display area of W, 2020 /* Get frame-relative bounding box of the text display area of W,
2048 without mode lines. Include in this box the left and right 2021 without mode lines. Include in this box the left and right
2049 fringe of W. */ 2022 fringe of W. */
2050 window_box (w, -1, &x, &y, &width, &height); 2023 window_box (w, ANY_AREA, &x, &y, &width, &height);
2051 2024
2052 from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y); 2025 from_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->current_y);
2053 to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y); 2026 to_y = WINDOW_TO_FRAME_PIXEL_Y (w, run->desired_y);
@@ -2222,7 +2195,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
2222 } 2195 }
2223 2196
2224 /* Must clip because of partially visible lines. */ 2197 /* Must clip because of partially visible lines. */
2225 ns_clip_to_row (w, row, -1, YES); 2198 ns_clip_to_row (w, row, ANY_AREA, YES);
2226 2199
2227 if (!p->overlay_p) 2200 if (!p->overlay_p)
2228 { 2201 {
@@ -2402,7 +2375,7 @@ ns_draw_window_cursor (struct window *w, struct glyph_row *glyph_row,
2402 2375
2403 /* TODO: only needed in rare cases with last-resort font in HELLO.. 2376 /* TODO: only needed in rare cases with last-resort font in HELLO..
2404 should we do this more efficiently? */ 2377 should we do this more efficiently? */
2405 ns_clip_to_row (w, glyph_row, -1, NO); /* do ns_focus(f, &r, 1); if remove */ 2378 ns_clip_to_row (w, glyph_row, ANY_AREA, NO); /* do ns_focus(f, &r, 1); if remove */
2406 2379
2407 2380
2408 face = FACE_FROM_ID (f, phys_cursor_glyph->face_id); 2381 face = FACE_FROM_ID (f, phys_cursor_glyph->face_id);
@@ -3713,7 +3686,7 @@ ns_set_vertical_scroll_bar (struct window *window,
3713 NSTRACE (ns_set_vertical_scroll_bar); 3686 NSTRACE (ns_set_vertical_scroll_bar);
3714 3687
3715 /* Get dimensions. */ 3688 /* Get dimensions. */
3716 window_box (window, -1, 0, &window_y, 0, &window_height); 3689 window_box (window, ANY_AREA, 0, &window_y, 0, &window_height);
3717 top = window_y; 3690 top = window_y;
3718 height = window_height; 3691 height = window_height;
3719 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f); 3692 width = WINDOW_CONFIG_SCROLL_BAR_COLS (window) * FRAME_COLUMN_WIDTH (f);
@@ -3978,9 +3951,7 @@ static struct redisplay_interface ns_redisplay_interface =
3978 ns_after_update_window_line, 3951 ns_after_update_window_line,
3979 ns_update_window_begin, 3952 ns_update_window_begin,
3980 ns_update_window_end, 3953 ns_update_window_end,
3981 x_cursor_to, 3954 0, /* flush_display */
3982 ns_flush,
3983 0, /* flush_display_optional */
3984 x_clear_window_mouse_face, 3955 x_clear_window_mouse_face,
3985 x_get_glyph_overhangs, 3956 x_get_glyph_overhangs,
3986 x_fix_overlapping_area, 3957 x_fix_overlapping_area,
@@ -4045,8 +4016,8 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
4045 terminal->ins_del_lines_hook = 0; /* XXX vestigial? */ 4016 terminal->ins_del_lines_hook = 0; /* XXX vestigial? */
4046 terminal->delete_glyphs_hook = 0; /* XXX vestigial? */ 4017 terminal->delete_glyphs_hook = 0; /* XXX vestigial? */
4047 terminal->ring_bell_hook = ns_ring_bell; 4018 terminal->ring_bell_hook = ns_ring_bell;
4048 terminal->reset_terminal_modes_hook = ns_reset_terminal_modes; 4019 terminal->reset_terminal_modes_hook = NULL;
4049 terminal->set_terminal_modes_hook = ns_set_terminal_modes; 4020 terminal->set_terminal_modes_hook = NULL;
4050 terminal->update_begin_hook = ns_update_begin; 4021 terminal->update_begin_hook = ns_update_begin;
4051 terminal->update_end_hook = ns_update_end; 4022 terminal->update_end_hook = ns_update_end;
4052 terminal->set_terminal_window_hook = NULL; /* XXX vestigial? */ 4023 terminal->set_terminal_window_hook = NULL; /* XXX vestigial? */
@@ -4686,7 +4657,7 @@ not_in_argv (NSString *arg)
4686 int waiting = 1, nfds; 4657 int waiting = 1, nfds;
4687 char c; 4658 char c;
4688 4659
4689 SELECT_TYPE readfds, writefds, *wfds; 4660 fd_set readfds, writefds, *wfds;
4690 struct timespec timeout, *tmo; 4661 struct timespec timeout, *tmo;
4691 NSAutoreleasePool *pool = nil; 4662 NSAutoreleasePool *pool = nil;
4692 4663
@@ -4699,7 +4670,7 @@ not_in_argv (NSString *arg)
4699 4670
4700 if (waiting) 4671 if (waiting)
4701 { 4672 {
4702 SELECT_TYPE fds; 4673 fd_set fds;
4703 FD_ZERO (&fds); 4674 FD_ZERO (&fds);
4704 FD_SET (selfds[0], &fds); 4675 FD_SET (selfds[0], &fds);
4705 result = select (selfds[0]+1, &fds, NULL, NULL, NULL); 4676 result = select (selfds[0]+1, &fds, NULL, NULL, NULL);
@@ -5468,6 +5439,30 @@ not_in_argv (NSString *arg)
5468 previous_help_echo_string = help_echo_string; 5439 previous_help_echo_string = help_echo_string;
5469 help_echo_string = Qnil; 5440 help_echo_string = Qnil;
5470 5441
5442 if (!NILP (Vmouse_autoselect_window))
5443 {
5444 NSTRACE (mouse_autoselect_window);
5445 static Lisp_Object last_mouse_window;
5446 Lisp_Object window = window_from_coordinates
5447 (emacsframe, last_mouse_motion_position.x,
5448 last_mouse_motion_position.y, 0, 0);
5449
5450 if (WINDOWP (window)
5451 && !EQ (window, last_mouse_window)
5452 && !EQ (window, selected_window)
5453 && (focus_follows_mouse
5454 || (EQ (XWINDOW (window)->frame,
5455 XWINDOW (selected_window)->frame))))
5456 {
5457 NSTRACE (in_window);
5458 emacs_event->kind = SELECT_WINDOW_EVENT;
5459 emacs_event->frame_or_window = window;
5460 EV_TRAILER2 (e);
5461 }
5462 /* Remember the last window where we saw the mouse. */
5463 last_mouse_window = window;
5464 }
5465
5471 if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x, 5466 if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x,
5472 last_mouse_motion_position.y)) 5467 last_mouse_motion_position.y))
5473 help_echo_string = previous_help_echo_string; 5468 help_echo_string = previous_help_echo_string;
diff --git a/src/print.c b/src/print.c
index e55657d7d8c..03e781cac18 100644
--- a/src/print.c
+++ b/src/print.c
@@ -126,7 +126,8 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
126 set_buffer_internal (XMARKER (printcharfun)->buffer); \ 126 set_buffer_internal (XMARKER (printcharfun)->buffer); \
127 marker_pos = marker_position (printcharfun); \ 127 marker_pos = marker_position (printcharfun); \
128 if (marker_pos < BEGV || marker_pos > ZV) \ 128 if (marker_pos < BEGV || marker_pos > ZV) \
129 error ("Marker is outside the accessible part of the buffer"); \ 129 signal_error ("Marker is outside the accessible " \
130 "part of the buffer", printcharfun); \
130 old_point = PT; \ 131 old_point = PT; \
131 old_point_byte = PT_BYTE; \ 132 old_point_byte = PT_BYTE; \
132 SET_PT_BOTH (marker_pos, \ 133 SET_PT_BOTH (marker_pos, \
@@ -138,10 +139,10 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
138 if (NILP (printcharfun)) \ 139 if (NILP (printcharfun)) \
139 { \ 140 { \
140 Lisp_Object string; \ 141 Lisp_Object string; \
141 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) \ 142 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) \
142 && ! print_escape_multibyte) \ 143 && ! print_escape_multibyte) \
143 specbind (Qprint_escape_multibyte, Qt); \ 144 specbind (Qprint_escape_multibyte, Qt); \
144 if (! NILP (BVAR (current_buffer, enable_multibyte_characters)) \ 145 if (! NILP (BVAR (current_buffer, enable_multibyte_characters)) \
145 && ! print_escape_nonascii) \ 146 && ! print_escape_nonascii) \
146 specbind (Qprint_escape_nonascii, Qt); \ 147 specbind (Qprint_escape_nonascii, Qt); \
147 if (print_buffer != 0) \ 148 if (print_buffer != 0) \
@@ -168,7 +169,7 @@ bool print_output_debug_flag EXTERNALLY_VISIBLE = 1;
168 if (NILP (printcharfun)) \ 169 if (NILP (printcharfun)) \
169 { \ 170 { \
170 if (print_buffer_pos != print_buffer_pos_byte \ 171 if (print_buffer_pos != print_buffer_pos_byte \
171 && NILP (BVAR (current_buffer, enable_multibyte_characters))) \ 172 && NILP (BVAR (current_buffer, enable_multibyte_characters)))\
172 { \ 173 { \
173 unsigned char *temp = alloca (print_buffer_pos + 1); \ 174 unsigned char *temp = alloca (print_buffer_pos + 1); \
174 copy_text ((unsigned char *) print_buffer, temp, \ 175 copy_text ((unsigned char *) print_buffer, temp, \
diff --git a/src/process.c b/src/process.c
index 3b62f45bf0a..20f84990d6f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -132,7 +132,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
132#endif 132#endif
133 133
134#ifdef WINDOWSNT 134#ifdef WINDOWSNT
135extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 135extern int sys_select (int, fd_set *, fd_set *, fd_set *,
136 struct timespec *, void *); 136 struct timespec *, void *);
137#endif 137#endif
138 138
@@ -280,7 +280,7 @@ static bool process_output_skip;
280 280
281static void create_process (Lisp_Object, char **, Lisp_Object); 281static void create_process (Lisp_Object, char **, Lisp_Object);
282#ifdef USABLE_SIGIO 282#ifdef USABLE_SIGIO
283static bool keyboard_bit_set (SELECT_TYPE *); 283static bool keyboard_bit_set (fd_set *);
284#endif 284#endif
285static void deactivate_process (Lisp_Object); 285static void deactivate_process (Lisp_Object);
286static void status_notify (struct Lisp_Process *); 286static void status_notify (struct Lisp_Process *);
@@ -299,26 +299,26 @@ static void exec_sentinel (Lisp_Object proc, Lisp_Object reason);
299 299
300/* Mask of bits indicating the descriptors that we wait for input on. */ 300/* Mask of bits indicating the descriptors that we wait for input on. */
301 301
302static SELECT_TYPE input_wait_mask; 302static fd_set input_wait_mask;
303 303
304/* Mask that excludes keyboard input descriptor(s). */ 304/* Mask that excludes keyboard input descriptor(s). */
305 305
306static SELECT_TYPE non_keyboard_wait_mask; 306static fd_set non_keyboard_wait_mask;
307 307
308/* Mask that excludes process input descriptor(s). */ 308/* Mask that excludes process input descriptor(s). */
309 309
310static SELECT_TYPE non_process_wait_mask; 310static fd_set non_process_wait_mask;
311 311
312/* Mask for selecting for write. */ 312/* Mask for selecting for write. */
313 313
314static SELECT_TYPE write_mask; 314static fd_set write_mask;
315 315
316#ifdef NON_BLOCKING_CONNECT 316#ifdef NON_BLOCKING_CONNECT
317/* Mask of bits indicating the descriptors that we wait for connect to 317/* Mask of bits indicating the descriptors that we wait for connect to
318 complete on. Once they complete, they are removed from this mask 318 complete on. Once they complete, they are removed from this mask
319 and added to the input_wait_mask and non_keyboard_wait_mask. */ 319 and added to the input_wait_mask and non_keyboard_wait_mask. */
320 320
321static SELECT_TYPE connect_wait_mask; 321static fd_set connect_wait_mask;
322 322
323/* Number of bits set in connect_wait_mask. */ 323/* Number of bits set in connect_wait_mask. */
324static int num_pending_connects; 324static int num_pending_connects;
@@ -331,7 +331,7 @@ static int max_process_desc;
331static int max_input_desc; 331static int max_input_desc;
332 332
333/* Indexed by descriptor, gives the process (if any) for that descriptor */ 333/* Indexed by descriptor, gives the process (if any) for that descriptor */
334static Lisp_Object chan_process[MAXDESC]; 334static Lisp_Object chan_process[FD_SETSIZE];
335 335
336/* Alist of elements (NAME . PROCESS) */ 336/* Alist of elements (NAME . PROCESS) */
337static Lisp_Object Vprocess_alist; 337static Lisp_Object Vprocess_alist;
@@ -342,18 +342,18 @@ static Lisp_Object Vprocess_alist;
342 output from the process is to read at least one char. 342 output from the process is to read at least one char.
343 Always -1 on systems that support FIONREAD. */ 343 Always -1 on systems that support FIONREAD. */
344 344
345static int proc_buffered_char[MAXDESC]; 345static int proc_buffered_char[FD_SETSIZE];
346 346
347/* Table of `struct coding-system' for each process. */ 347/* Table of `struct coding-system' for each process. */
348static struct coding_system *proc_decode_coding_system[MAXDESC]; 348static struct coding_system *proc_decode_coding_system[FD_SETSIZE];
349static struct coding_system *proc_encode_coding_system[MAXDESC]; 349static struct coding_system *proc_encode_coding_system[FD_SETSIZE];
350 350
351#ifdef DATAGRAM_SOCKETS 351#ifdef DATAGRAM_SOCKETS
352/* Table of `partner address' for datagram sockets. */ 352/* Table of `partner address' for datagram sockets. */
353static struct sockaddr_and_len { 353static struct sockaddr_and_len {
354 struct sockaddr *sa; 354 struct sockaddr *sa;
355 int len; 355 int len;
356} datagram_address[MAXDESC]; 356} datagram_address[FD_SETSIZE];
357#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0) 357#define DATAGRAM_CHAN_P(chan) (datagram_address[chan].sa != 0)
358#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0) 358#define DATAGRAM_CONN_P(proc) (PROCESSP (proc) && datagram_address[XPROCESS (proc)->infd].sa != 0)
359#else 359#else
@@ -458,7 +458,7 @@ static struct fd_callback_data
458#define FOR_READ 1 458#define FOR_READ 1
459#define FOR_WRITE 2 459#define FOR_WRITE 2
460 int condition; /* mask of the defines above. */ 460 int condition; /* mask of the defines above. */
461} fd_callback_info[MAXDESC]; 461} fd_callback_info[FD_SETSIZE];
462 462
463 463
464/* Add a file descriptor FD to be monitored for when read is possible. 464/* Add a file descriptor FD to be monitored for when read is possible.
@@ -467,7 +467,7 @@ static struct fd_callback_data
467void 467void
468add_read_fd (int fd, fd_callback func, void *data) 468add_read_fd (int fd, fd_callback func, void *data)
469{ 469{
470 eassert (fd < MAXDESC); 470 eassert (fd < FD_SETSIZE);
471 add_keyboard_wait_descriptor (fd); 471 add_keyboard_wait_descriptor (fd);
472 472
473 fd_callback_info[fd].func = func; 473 fd_callback_info[fd].func = func;
@@ -480,7 +480,7 @@ add_read_fd (int fd, fd_callback func, void *data)
480void 480void
481delete_read_fd (int fd) 481delete_read_fd (int fd)
482{ 482{
483 eassert (fd < MAXDESC); 483 eassert (fd < FD_SETSIZE);
484 delete_keyboard_wait_descriptor (fd); 484 delete_keyboard_wait_descriptor (fd);
485 485
486 fd_callback_info[fd].condition &= ~FOR_READ; 486 fd_callback_info[fd].condition &= ~FOR_READ;
@@ -497,7 +497,7 @@ delete_read_fd (int fd)
497void 497void
498add_write_fd (int fd, fd_callback func, void *data) 498add_write_fd (int fd, fd_callback func, void *data)
499{ 499{
500 eassert (fd < MAXDESC); 500 eassert (fd < FD_SETSIZE);
501 FD_SET (fd, &write_mask); 501 FD_SET (fd, &write_mask);
502 if (fd > max_input_desc) 502 if (fd > max_input_desc)
503 max_input_desc = fd; 503 max_input_desc = fd;
@@ -528,7 +528,7 @@ delete_input_desc (int fd)
528void 528void
529delete_write_fd (int fd) 529delete_write_fd (int fd)
530{ 530{
531 eassert (fd < MAXDESC); 531 eassert (fd < FD_SETSIZE);
532 FD_CLR (fd, &write_mask); 532 FD_CLR (fd, &write_mask);
533 fd_callback_info[fd].condition &= ~FOR_WRITE; 533 fd_callback_info[fd].condition &= ~FOR_WRITE;
534 if (fd_callback_info[fd].condition == 0) 534 if (fd_callback_info[fd].condition == 0)
@@ -3232,7 +3232,7 @@ usage: (make-network-process &rest ARGS) */)
3232 wait for completion is pselect(). */ 3232 wait for completion is pselect(). */
3233 int sc; 3233 int sc;
3234 socklen_t len; 3234 socklen_t len;
3235 SELECT_TYPE fdset; 3235 fd_set fdset;
3236 retry_select: 3236 retry_select:
3237 FD_ZERO (&fdset); 3237 FD_ZERO (&fdset);
3238 FD_SET (s, &fdset); 3238 FD_SET (s, &fdset);
@@ -4232,8 +4232,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4232 struct Lisp_Process *wait_proc, int just_wait_proc) 4232 struct Lisp_Process *wait_proc, int just_wait_proc)
4233{ 4233{
4234 int channel, nfds; 4234 int channel, nfds;
4235 SELECT_TYPE Available; 4235 fd_set Available;
4236 SELECT_TYPE Writeok; 4236 fd_set Writeok;
4237 bool check_write; 4237 bool check_write;
4238 int check_delay; 4238 int check_delay;
4239 bool no_avail; 4239 bool no_avail;
@@ -4387,8 +4387,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4387 timeout to get our attention. */ 4387 timeout to get our attention. */
4388 if (update_tick != process_tick) 4388 if (update_tick != process_tick)
4389 { 4389 {
4390 SELECT_TYPE Atemp; 4390 fd_set Atemp;
4391 SELECT_TYPE Ctemp; 4391 fd_set Ctemp;
4392 4392
4393 if (kbd_on_hold_p ()) 4393 if (kbd_on_hold_p ())
4394 FD_ZERO (&Atemp); 4394 FD_ZERO (&Atemp);
@@ -4571,7 +4571,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4571 the gnutls library -- 2.12.14 has been confirmed 4571 the gnutls library -- 2.12.14 has been confirmed
4572 to need it. See 4572 to need it. See
4573 http://comments.gmane.org/gmane.emacs.devel/145074 */ 4573 http://comments.gmane.org/gmane.emacs.devel/145074 */
4574 for (channel = 0; channel < MAXDESC; ++channel) 4574 for (channel = 0; channel < FD_SETSIZE; ++channel)
4575 if (! NILP (chan_process[channel])) 4575 if (! NILP (chan_process[channel]))
4576 { 4576 {
4577 struct Lisp_Process *p = 4577 struct Lisp_Process *p =
@@ -5178,15 +5178,10 @@ DEFUN ("internal-default-process-filter", Finternal_default_process_filter,
5178 5178
5179 bset_read_only (current_buffer, Qnil); 5179 bset_read_only (current_buffer, Qnil);
5180 5180
5181 /* Insert new output into buffer 5181 /* Insert new output into buffer at the current end-of-output
5182 at the current end-of-output marker, 5182 marker, thus preserving logical ordering of input and output. */
5183 thus preserving logical ordering of input and output. */
5184 if (XMARKER (p->mark)->buffer) 5183 if (XMARKER (p->mark)->buffer)
5185 SET_PT_BOTH (clip_to_bounds (BEGV, 5184 set_point_from_marker (p->mark);
5186 marker_position (p->mark), ZV),
5187 clip_to_bounds (BEGV_BYTE,
5188 marker_byte_position (p->mark),
5189 ZV_BYTE));
5190 else 5185 else
5191 SET_PT_BOTH (ZV, ZV_BYTE); 5186 SET_PT_BOTH (ZV, ZV_BYTE);
5192 before = PT; 5187 before = PT;
@@ -6542,7 +6537,7 @@ keyboard_bit_set (fd_set *mask)
6542#else /* not subprocesses */ 6537#else /* not subprocesses */
6543 6538
6544/* Defined on msdos.c. */ 6539/* Defined on msdos.c. */
6545extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, 6540extern int sys_select (int, fd_set *, fd_set *, fd_set *,
6546 struct timespec *, void *); 6541 struct timespec *, void *);
6547 6542
6548/* Implementation of wait_reading_process_output, assuming that there 6543/* Implementation of wait_reading_process_output, assuming that there
@@ -6608,7 +6603,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6608 while (1) 6603 while (1)
6609 { 6604 {
6610 bool timeout_reduced_for_timers = 0; 6605 bool timeout_reduced_for_timers = 0;
6611 SELECT_TYPE waitchannels; 6606 fd_set waitchannels;
6612 int xerrno; 6607 int xerrno;
6613 6608
6614 /* If calling from keyboard input, do not quit 6609 /* If calling from keyboard input, do not quit
@@ -7072,7 +7067,7 @@ init_process_emacs (void)
7072 7067
7073 Vprocess_alist = Qnil; 7068 Vprocess_alist = Qnil;
7074 deleted_pid_list = Qnil; 7069 deleted_pid_list = Qnil;
7075 for (i = 0; i < MAXDESC; i++) 7070 for (i = 0; i < FD_SETSIZE; i++)
7076 { 7071 {
7077 chan_process[i] = Qnil; 7072 chan_process[i] = Qnil;
7078 proc_buffered_char[i] = -1; 7073 proc_buffered_char[i] = -1;
diff --git a/src/regex.c b/src/regex.c
index 2363fe2a290..1befececd22 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -257,15 +257,10 @@ xrealloc (void *block, size_t size)
257enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 }; 257enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
258 258
259/* Dummy macros for non-Emacs environments. */ 259/* Dummy macros for non-Emacs environments. */
260# define CHAR_CHARSET(c) 0
261# define CHARSET_LEADING_CODE_BASE(c) 0
262# define MAX_MULTIBYTE_LENGTH 1 260# define MAX_MULTIBYTE_LENGTH 1
263# define RE_MULTIBYTE_P(x) 0 261# define RE_MULTIBYTE_P(x) 0
264# define RE_TARGET_MULTIBYTE_P(x) 0 262# define RE_TARGET_MULTIBYTE_P(x) 0
265# define WORD_BOUNDARY_P(c1, c2) (0) 263# define WORD_BOUNDARY_P(c1, c2) (0)
266# define CHAR_HEAD_P(p) (1)
267# define SINGLE_BYTE_CHAR_P(c) (1)
268# define SAME_CHARSET_P(c1, c2) (1)
269# define BYTES_BY_CHAR_HEAD(p) (1) 264# define BYTES_BY_CHAR_HEAD(p) (1)
270# define PREV_CHAR_BOUNDARY(p, limit) ((p)--) 265# define PREV_CHAR_BOUNDARY(p, limit) ((p)--)
271# define STRING_CHAR(p) (*(p)) 266# define STRING_CHAR(p) (*(p))
@@ -279,8 +274,6 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
279 (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1))) 274 (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1)))
280# define GET_CHAR_AFTER(c, p, len) \ 275# define GET_CHAR_AFTER(c, p, len) \
281 (c = *p, len = 1) 276 (c = *p, len = 1)
282# define MAKE_CHAR(charset, c1, c2) (c1)
283# define BYTE8_TO_CHAR(c) (c)
284# define CHAR_BYTE8_P(c) (0) 277# define CHAR_BYTE8_P(c) (0)
285# define CHAR_LEADING_CODE(c) (c) 278# define CHAR_LEADING_CODE(c) (c)
286 279
@@ -775,10 +768,12 @@ extract_number_and_incr (re_char **source)
775 and the 2 bytes of flags at the start of the range table. */ 768 and the 2 bytes of flags at the start of the range table. */
776#define CHARSET_RANGE_TABLE(p) (&(p)[4 + CHARSET_BITMAP_SIZE (p)]) 769#define CHARSET_RANGE_TABLE(p) (&(p)[4 + CHARSET_BITMAP_SIZE (p)])
777 770
771#ifdef emacs
778/* Extract the bit flags that start a range table. */ 772/* Extract the bit flags that start a range table. */
779#define CHARSET_RANGE_TABLE_BITS(p) \ 773#define CHARSET_RANGE_TABLE_BITS(p) \
780 ((p)[2 + CHARSET_BITMAP_SIZE (p)] \ 774 ((p)[2 + CHARSET_BITMAP_SIZE (p)] \
781 + (p)[3 + CHARSET_BITMAP_SIZE (p)] * 0x100) 775 + (p)[3 + CHARSET_BITMAP_SIZE (p)] * 0x100)
776#endif
782 777
783/* Return the address of end of RANGE_TABLE. COUNT is number of 778/* Return the address of end of RANGE_TABLE. COUNT is number of
784 ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2' 779 ranges (which is a pair of (start, end)) in the RANGE_TABLE. `* 2'
@@ -1830,6 +1825,8 @@ struct range_table_work_area
1830 int bits; /* flag to record character classes */ 1825 int bits; /* flag to record character classes */
1831}; 1826};
1832 1827
1828#ifdef emacs
1829
1833/* Make sure that WORK_AREA can hold more N multibyte characters. 1830/* Make sure that WORK_AREA can hold more N multibyte characters.
1834 This is used only in set_image_of_range and set_image_of_range_1. 1831 This is used only in set_image_of_range and set_image_of_range_1.
1835 It expects WORK_AREA to be a pointer. 1832 It expects WORK_AREA to be a pointer.
@@ -1848,15 +1845,6 @@ struct range_table_work_area
1848#define SET_RANGE_TABLE_WORK_AREA_BIT(work_area, bit) \ 1845#define SET_RANGE_TABLE_WORK_AREA_BIT(work_area, bit) \
1849 (work_area).bits |= (bit) 1846 (work_area).bits |= (bit)
1850 1847
1851/* Bits used to implement the multibyte-part of the various character classes
1852 such as [:alnum:] in a charset's range table. */
1853#define BIT_WORD 0x1
1854#define BIT_LOWER 0x2
1855#define BIT_PUNCT 0x4
1856#define BIT_SPACE 0x8
1857#define BIT_UPPER 0x10
1858#define BIT_MULTIBYTE 0x20
1859
1860/* Set a range (RANGE_START, RANGE_END) to WORK_AREA. */ 1848/* Set a range (RANGE_START, RANGE_END) to WORK_AREA. */
1861#define SET_RANGE_TABLE_WORK_AREA(work_area, range_start, range_end) \ 1849#define SET_RANGE_TABLE_WORK_AREA(work_area, range_start, range_end) \
1862 do { \ 1850 do { \
@@ -1865,6 +1853,8 @@ struct range_table_work_area
1865 (work_area).table[(work_area).used++] = (range_end); \ 1853 (work_area).table[(work_area).used++] = (range_end); \
1866 } while (0) 1854 } while (0)
1867 1855
1856#endif /* emacs */
1857
1868/* Free allocated memory for WORK_AREA. */ 1858/* Free allocated memory for WORK_AREA. */
1869#define FREE_RANGE_TABLE_WORK_AREA(work_area) \ 1859#define FREE_RANGE_TABLE_WORK_AREA(work_area) \
1870 do { \ 1860 do { \
@@ -1876,6 +1866,15 @@ struct range_table_work_area
1876#define RANGE_TABLE_WORK_USED(work_area) ((work_area).used) 1866#define RANGE_TABLE_WORK_USED(work_area) ((work_area).used)
1877#define RANGE_TABLE_WORK_BITS(work_area) ((work_area).bits) 1867#define RANGE_TABLE_WORK_BITS(work_area) ((work_area).bits)
1878#define RANGE_TABLE_WORK_ELT(work_area, i) ((work_area).table[i]) 1868#define RANGE_TABLE_WORK_ELT(work_area, i) ((work_area).table[i])
1869
1870/* Bits used to implement the multibyte-part of the various character classes
1871 such as [:alnum:] in a charset's range table. */
1872#define BIT_WORD 0x1
1873#define BIT_LOWER 0x2
1874#define BIT_PUNCT 0x4
1875#define BIT_SPACE 0x8
1876#define BIT_UPPER 0x10
1877#define BIT_MULTIBYTE 0x20
1879 1878
1880 1879
1881/* Set the bit for character C in a list. */ 1880/* Set the bit for character C in a list. */
diff --git a/src/search.c b/src/search.c
index 761c12a364a..99e8d2501fe 100644
--- a/src/search.c
+++ b/src/search.c
@@ -859,88 +859,20 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
859 If ALLOW_QUIT, set immediate_quit. That's good to do 859 If ALLOW_QUIT, set immediate_quit. That's good to do
860 except in special cases. */ 860 except in special cases. */
861 861
862EMACS_INT 862ptrdiff_t
863scan_newline (ptrdiff_t start, ptrdiff_t start_byte, 863scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
864 ptrdiff_t limit, ptrdiff_t limit_byte, 864 ptrdiff_t limit, ptrdiff_t limit_byte,
865 EMACS_INT count, bool allow_quit) 865 ptrdiff_t count, bool allow_quit)
866{ 866{
867 int direction = ((count > 0) ? 1 : -1); 867 ptrdiff_t charpos, bytepos, shortage;
868
869 unsigned char *cursor;
870 unsigned char *base;
871
872 ptrdiff_t ceiling;
873 unsigned char *ceiling_addr;
874
875 bool old_immediate_quit = immediate_quit;
876
877 if (allow_quit)
878 immediate_quit++;
879 868
880 if (count > 0) 869 charpos = find_newline (start, start_byte, limit, limit_byte,
881 { 870 count, &shortage, &bytepos, allow_quit);
882 while (start_byte < limit_byte) 871 if (shortage)
883 { 872 TEMP_SET_PT_BOTH (limit, limit_byte);
884 ceiling = BUFFER_CEILING_OF (start_byte);
885 ceiling = min (limit_byte - 1, ceiling);
886 ceiling_addr = BYTE_POS_ADDR (ceiling) + 1;
887 base = (cursor = BYTE_POS_ADDR (start_byte));
888
889 do
890 {
891 unsigned char *nl = memchr (cursor, '\n', ceiling_addr - cursor);
892 if (! nl)
893 break;
894 if (--count == 0)
895 {
896 immediate_quit = old_immediate_quit;
897 start_byte += nl - base + 1;
898 start = BYTE_TO_CHAR (start_byte);
899 TEMP_SET_PT_BOTH (start, start_byte);
900 return 0;
901 }
902 cursor = nl + 1;
903 }
904 while (cursor < ceiling_addr);
905
906 start_byte += ceiling_addr - base;
907 }
908 }
909 else 873 else
910 { 874 TEMP_SET_PT_BOTH (charpos, bytepos);
911 while (start_byte > limit_byte) 875 return shortage;
912 {
913 ceiling = BUFFER_FLOOR_OF (start_byte - 1);
914 ceiling = max (limit_byte, ceiling);
915 ceiling_addr = BYTE_POS_ADDR (ceiling);
916 base = (cursor = BYTE_POS_ADDR (start_byte - 1) + 1);
917 while (1)
918 {
919 unsigned char *nl = memrchr (ceiling_addr, '\n',
920 cursor - ceiling_addr);
921 if (! nl)
922 break;
923
924 if (++count == 0)
925 {
926 immediate_quit = old_immediate_quit;
927 /* Return the position AFTER the match we found. */
928 start_byte += nl - base + 1;
929 start = BYTE_TO_CHAR (start_byte);
930 TEMP_SET_PT_BOTH (start, start_byte);
931 return 0;
932 }
933
934 cursor = nl;
935 }
936 start_byte += ceiling_addr - base;
937 }
938 }
939
940 TEMP_SET_PT_BOTH (limit, limit_byte);
941 immediate_quit = old_immediate_quit;
942
943 return count * direction;
944} 876}
945 877
946/* Like find_newline, but doesn't allow QUITting and doesn't return 878/* Like find_newline, but doesn't allow QUITting and doesn't return
diff --git a/src/sysdep.c b/src/sysdep.c
index e43991f41ab..6439697501e 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -588,7 +588,7 @@ restore_signal_handlers (struct save_signal *saved_handlers)
588} 588}
589 589
590#ifdef USABLE_SIGIO 590#ifdef USABLE_SIGIO
591static int old_fcntl_flags[MAXDESC]; 591static int old_fcntl_flags[FD_SETSIZE];
592#endif 592#endif
593 593
594void 594void
@@ -817,7 +817,7 @@ emacs_set_tty (int fd, struct emacs_tty *settings, bool flushp)
817 817
818 818
819#ifdef F_SETOWN 819#ifdef F_SETOWN
820static int old_fcntl_owner[MAXDESC]; 820static int old_fcntl_owner[FD_SETSIZE];
821#endif /* F_SETOWN */ 821#endif /* F_SETOWN */
822 822
823/* This may also be defined in stdio, 823/* This may also be defined in stdio,
diff --git a/src/sysselect.h b/src/sysselect.h
index 0a4f7e3ad96..5df0af9ed37 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -25,15 +25,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 definitions in w32.h are incompatible with the below. */ 25 definitions in w32.h are incompatible with the below. */
26#ifndef WINDOWSNT 26#ifndef WINDOWSNT
27#ifdef FD_SET 27#ifdef FD_SET
28#ifdef FD_SETSIZE 28#ifndef FD_SETSIZE
29#define MAXDESC FD_SETSIZE 29#define FD_SETSIZE 64
30#else
31#define MAXDESC 64
32#endif 30#endif
33#define SELECT_TYPE fd_set
34#else /* no FD_SET */ 31#else /* no FD_SET */
35#define MAXDESC 32 32#define FD_SETSIZE 32
36#define SELECT_TYPE int 33typedef int fd_set;
37 34
38/* Define the macros to access a single-int bitmap of descriptors. */ 35/* Define the macros to access a single-int bitmap of descriptors. */
39#define FD_SET(n, p) (*(p) |= (1 << (n))) 36#define FD_SET(n, p) (*(p) |= (1 << (n)))
diff --git a/src/term.c b/src/term.c
index aa61fde06ee..0270c1eefa6 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1800,27 +1800,10 @@ append_glyphless_glyph (struct it *it, int face_id, const char *str)
1800static void 1800static void
1801produce_glyphless_glyph (struct it *it, Lisp_Object acronym) 1801produce_glyphless_glyph (struct it *it, Lisp_Object acronym)
1802{ 1802{
1803 int face_id; 1803 int len, face_id = merge_glyphless_glyph_face (it);
1804 int len;
1805 char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)]; 1804 char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)];
1806 char const *str = " "; 1805 char const *str = " ";
1807 1806
1808 /* Get a face ID for the glyph by utilizing a cache (the same way as
1809 done for `escape-glyph' in get_next_display_element). */
1810 if (it->f == last_glyphless_glyph_frame
1811 && it->face_id == last_glyphless_glyph_face_id)
1812 {
1813 face_id = last_glyphless_glyph_merged_face_id;
1814 }
1815 else
1816 {
1817 /* Merge the `glyphless-char' face into the current face. */
1818 face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id);
1819 last_glyphless_glyph_frame = it->f;
1820 last_glyphless_glyph_face_id = it->face_id;
1821 last_glyphless_glyph_merged_face_id = face_id;
1822 }
1823
1824 if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) 1807 if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
1825 { 1808 {
1826 /* As there's no way to produce a thin space, we produce a space 1809 /* As there's no way to produce a thin space, we produce a space
diff --git a/src/termhooks.h b/src/termhooks.h
index b22367b6751..e47d9701229 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -18,7 +18,9 @@ GNU General Public License for more details.
18You should have received a copy of the GNU General Public License 18You should have received a copy of the GNU General Public License
19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 19along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 20
21 21#ifndef EMACS_TERMHOOKS_H
22#define EMACS_TERMHOOKS_H
23
22/* Miscellanea. */ 24/* Miscellanea. */
23 25
24#include "systime.h" /* for Time */ 26#include "systime.h" /* for Time */
@@ -28,10 +30,6 @@ INLINE_HEADER_BEGIN
28# define TERMHOOKS_INLINE INLINE 30# define TERMHOOKS_INLINE INLINE
29#endif 31#endif
30 32
31struct glyph;
32struct frame;
33
34
35enum scroll_bar_part { 33enum scroll_bar_part {
36 scroll_bar_above_handle, 34 scroll_bar_above_handle,
37 scroll_bar_handle, 35 scroll_bar_handle,
@@ -49,7 +47,18 @@ enum scroll_bar_part {
49 may do something OS dependent, like extended window manager hints on X11. */ 47 may do something OS dependent, like extended window manager hints on X11. */
50extern void (*fullscreen_hook) (struct frame *f); 48extern void (*fullscreen_hook) (struct frame *f);
51 49
52 50/* Output method of a terminal (and frames on this terminal, respectively). */
51
52enum output_method
53{
54 output_initial,
55 output_termcap,
56 output_x_window,
57 output_msdos_raw,
58 output_w32,
59 output_ns
60};
61
53/* Input queue declarations and hooks. */ 62/* Input queue declarations and hooks. */
54 63
55enum event_kind 64enum event_kind
@@ -324,11 +333,6 @@ extern void term_mouse_moveto (int, int);
324extern struct tty_display_info *gpm_tty; 333extern struct tty_display_info *gpm_tty;
325#endif 334#endif
326 335
327
328struct ns_display_info;
329struct x_display_info;
330struct w32_display_info;
331
332/* Terminal-local parameters. */ 336/* Terminal-local parameters. */
333struct terminal 337struct terminal
334{ 338{
@@ -663,3 +667,5 @@ extern void close_gpm (int gpm_fd);
663#endif 667#endif
664 668
665INLINE_HEADER_END 669INLINE_HEADER_END
670
671#endif /* EMACS_TERMHOOKS_H */
diff --git a/src/w32.c b/src/w32.c
index 05a3fde97ce..1dcf46b5f4b 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -6092,6 +6092,7 @@ term_winsock (void)
6092{ 6092{
6093 if (winsock_lib != NULL && winsock_inuse == 0) 6093 if (winsock_lib != NULL && winsock_inuse == 0)
6094 { 6094 {
6095 release_listen_threads ();
6095 /* Not sure what would cause WSAENETDOWN, or even if it can happen 6096 /* Not sure what would cause WSAENETDOWN, or even if it can happen
6096 after WSAStartup returns successfully, but it seems reasonable 6097 after WSAStartup returns successfully, but it seems reasonable
6097 to allow unloading winsock anyway in that case. */ 6098 to allow unloading winsock anyway in that case. */
@@ -7076,7 +7077,12 @@ _sys_wait_accept (int fd)
7076 rc = pfn_WSAEventSelect (SOCK_HANDLE (fd), hEv, FD_ACCEPT); 7077 rc = pfn_WSAEventSelect (SOCK_HANDLE (fd), hEv, FD_ACCEPT);
7077 if (rc != SOCKET_ERROR) 7078 if (rc != SOCKET_ERROR)
7078 { 7079 {
7079 rc = WaitForSingleObject (hEv, INFINITE); 7080 do {
7081 rc = WaitForSingleObject (hEv, 500);
7082 Sleep (5);
7083 } while (rc == WAIT_TIMEOUT
7084 && cp->status != STATUS_READ_ERROR
7085 && cp->char_avail);
7080 pfn_WSAEventSelect (SOCK_HANDLE (fd), NULL, 0); 7086 pfn_WSAEventSelect (SOCK_HANDLE (fd), NULL, 0);
7081 if (rc == WAIT_OBJECT_0) 7087 if (rc == WAIT_OBJECT_0)
7082 cp->status = STATUS_READ_SUCCEEDED; 7088 cp->status = STATUS_READ_SUCCEEDED;
diff --git a/src/w32.h b/src/w32.h
index 9c1f1efa699..32d0fdbe3cf 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -163,6 +163,7 @@ extern void reset_standard_handles (int in, int out,
163/* Return the string resource associated with KEY of type TYPE. */ 163/* Return the string resource associated with KEY of type TYPE. */
164extern LPBYTE w32_get_resource (char * key, LPDWORD type); 164extern LPBYTE w32_get_resource (char * key, LPDWORD type);
165 165
166extern void release_listen_threads (void);
166extern void init_ntproc (int); 167extern void init_ntproc (int);
167extern void term_ntproc (int); 168extern void term_ntproc (int);
168extern void globals_of_w32 (void); 169extern void globals_of_w32 (void);
diff --git a/src/w32console.c b/src/w32console.c
index a707344efc8..8da1ccf1892 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -53,7 +53,6 @@ static void w32con_write_glyphs (struct frame *f, struct glyph *string, int len)
53static void w32con_delete_glyphs (struct frame *f, int n); 53static void w32con_delete_glyphs (struct frame *f, int n);
54static void w32con_reset_terminal_modes (struct terminal *t); 54static void w32con_reset_terminal_modes (struct terminal *t);
55static void w32con_set_terminal_modes (struct terminal *t); 55static void w32con_set_terminal_modes (struct terminal *t);
56static void w32con_set_terminal_window (struct frame *f, int size);
57static void w32con_update_begin (struct frame * f); 56static void w32con_update_begin (struct frame * f);
58static void w32con_update_end (struct frame * f); 57static void w32con_update_end (struct frame * f);
59static WORD w32_face_attributes (struct frame *f, int face_id); 58static WORD w32_face_attributes (struct frame *f, int face_id);
@@ -497,11 +496,6 @@ w32con_update_end (struct frame * f)
497 SetConsoleCursorPosition (cur_screen, cursor_coords); 496 SetConsoleCursorPosition (cur_screen, cursor_coords);
498} 497}
499 498
500static void
501w32con_set_terminal_window (struct frame *f, int size)
502{
503}
504
505/*********************************************************************** 499/***********************************************************************
506 stubs from termcap.c 500 stubs from termcap.c
507 ***********************************************************************/ 501 ***********************************************************************/
@@ -619,7 +613,7 @@ initialize_w32_display (struct terminal *term, int *width, int *height)
619 term->ring_bell_hook = w32_sys_ring_bell; 613 term->ring_bell_hook = w32_sys_ring_bell;
620 term->reset_terminal_modes_hook = w32con_reset_terminal_modes; 614 term->reset_terminal_modes_hook = w32con_reset_terminal_modes;
621 term->set_terminal_modes_hook = w32con_set_terminal_modes; 615 term->set_terminal_modes_hook = w32con_set_terminal_modes;
622 term->set_terminal_window_hook = w32con_set_terminal_window; 616 term->set_terminal_window_hook = NULL;
623 term->update_begin_hook = w32con_update_begin; 617 term->update_begin_hook = w32con_update_begin;
624 term->update_end_hook = w32con_update_end; 618 term->update_end_hook = w32con_update_end;
625 619
diff --git a/src/w32fns.c b/src/w32fns.c
index b8c445a3a36..58c63d959ef 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1637,7 +1637,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1637 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); 1637 x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
1638 do_pending_window_change (0); 1638 do_pending_window_change (0);
1639 } 1639 }
1640 adjust_glyphs (f); 1640 adjust_frame_glyphs (f);
1641} 1641}
1642 1642
1643 1643
@@ -1679,7 +1679,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1679 1679
1680 FRAME_TOOL_BAR_LINES (f) = nlines; 1680 FRAME_TOOL_BAR_LINES (f) = nlines;
1681 resize_frame_windows (f, FRAME_LINES (f), 0); 1681 resize_frame_windows (f, FRAME_LINES (f), 0);
1682 adjust_glyphs (f); 1682 adjust_frame_glyphs (f);
1683 1683
1684 /* We also have to make sure that the internal border at the top of 1684 /* We also have to make sure that the internal border at the top of
1685 the frame, below the menu bar or tool bar, is redrawn when the 1685 the frame, below the menu bar or tool bar, is redrawn when the
@@ -6059,7 +6059,7 @@ Text larger than the specified size is clipped. */)
6059 } 6059 }
6060 6060
6061 FRAME_TOTAL_COLS (f) = WINDOW_TOTAL_COLS (w); 6061 FRAME_TOTAL_COLS (f) = WINDOW_TOTAL_COLS (w);
6062 adjust_glyphs (f); 6062 adjust_frame_glyphs (f);
6063 w->pseudo_window_p = 1; 6063 w->pseudo_window_p = 1;
6064 6064
6065 /* Display the tooltip text in a temporary buffer. */ 6065 /* Display the tooltip text in a temporary buffer. */
@@ -6128,7 +6128,7 @@ Text larger than the specified size is clipped. */)
6128 width /= WINDOW_FRAME_COLUMN_WIDTH (w); 6128 width /= WINDOW_FRAME_COLUMN_WIDTH (w);
6129 w->total_cols = width; 6129 w->total_cols = width;
6130 FRAME_TOTAL_COLS (f) = width; 6130 FRAME_TOTAL_COLS (f) = width;
6131 adjust_glyphs (f); 6131 adjust_frame_glyphs (f);
6132 w->pseudo_window_p = 1; 6132 w->pseudo_window_p = 1;
6133 clear_glyph_matrix (w->desired_matrix); 6133 clear_glyph_matrix (w->desired_matrix);
6134 clear_glyph_matrix (w->current_matrix); 6134 clear_glyph_matrix (w->current_matrix);
diff --git a/src/w32proc.c b/src/w32proc.c
index 54316a6f80f..dabaa62f71c 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -990,6 +990,18 @@ find_child_pid (DWORD pid)
990 return NULL; 990 return NULL;
991} 991}
992 992
993void
994release_listen_threads (void)
995{
996 int i;
997
998 for (i = child_proc_count - 1; i >= 0; i--)
999 {
1000 if (CHILD_ACTIVE (&child_procs[i])
1001 && (fd_info[child_procs[i].fd].flags & FILE_LISTEN))
1002 child_procs[i].status = STATUS_READ_ERROR;
1003 }
1004}
993 1005
994/* Thread proc for child process and socket reader threads. Each thread 1006/* Thread proc for child process and socket reader threads. Each thread
995 is normally blocked until woken by select() to check for input by 1007 is normally blocked until woken by select() to check for input by
diff --git a/src/w32term.c b/src/w32term.c
index ba3aadd0b49..681f70b5888 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -84,9 +84,6 @@ static int last_mousemove_y = 0;
84 84
85static int any_help_event_p; 85static int any_help_event_p;
86 86
87/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
88static Lisp_Object last_window;
89
90extern unsigned int msh_mousewheel; 87extern unsigned int msh_mousewheel;
91 88
92extern void free_frame_menubar (struct frame *); 89extern void free_frame_menubar (struct frame *);
@@ -224,8 +221,6 @@ void x_wm_set_icon_pixmap (struct frame *, int);
224static void w32_initialize (void); 221static void w32_initialize (void);
225static void x_update_end (struct frame *); 222static void x_update_end (struct frame *);
226static void w32_frame_up_to_date (struct frame *); 223static void w32_frame_up_to_date (struct frame *);
227static void w32_set_terminal_modes (struct terminal *);
228static void w32_reset_terminal_modes (struct terminal *);
229static void x_clear_frame (struct frame *); 224static void x_clear_frame (struct frame *);
230static void frame_highlight (struct frame *); 225static void frame_highlight (struct frame *);
231static void frame_unhighlight (struct frame *); 226static void frame_unhighlight (struct frame *);
@@ -240,7 +235,8 @@ static void x_frame_rehighlight (struct w32_display_info *);
240static void x_draw_hollow_cursor (struct window *, struct glyph_row *); 235static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
241static void x_draw_bar_cursor (struct window *, struct glyph_row *, int, 236static void x_draw_bar_cursor (struct window *, struct glyph_row *, int,
242 enum text_cursor_kinds); 237 enum text_cursor_kinds);
243static void w32_clip_to_row (struct window *, struct glyph_row *, int, HDC); 238static void w32_clip_to_row (struct window *, struct glyph_row *,
239 enum glyph_row_area, HDC);
244static BOOL my_show_window (struct frame *, HWND, int); 240static BOOL my_show_window (struct frame *, HWND, int);
245static void my_set_window_pos (HWND, HWND, int, int, int, int, UINT); 241static void my_set_window_pos (HWND, HWND, int, int, int, int, UINT);
246#if 0 242#if 0
@@ -576,8 +572,7 @@ x_update_begin (struct frame *f)
576} 572}
577 573
578 574
579/* Start update of window W. Set output_cursor to the cursor 575/* Start update of window W. */
580 position of W. */
581 576
582static void 577static void
583x_update_window_begin (struct window *w) 578x_update_window_begin (struct window *w)
@@ -591,7 +586,7 @@ x_update_window_begin (struct window *w)
591 SendMessage (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0); 586 SendMessage (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0);
592 } 587 }
593 588
594 set_output_cursor (&w->cursor); 589 w->output_cursor = w->cursor;
595 590
596 block_input (); 591 block_input ();
597 592
@@ -683,9 +678,9 @@ x_update_window_end (struct window *w, bool cursor_on_p,
683 block_input (); 678 block_input ();
684 679
685 if (cursor_on_p) 680 if (cursor_on_p)
686 display_and_set_cursor (w, 1, output_cursor.hpos, 681 display_and_set_cursor (w, 1,
687 output_cursor.vpos, 682 w->output_cursor.hpos, w->output_cursor.vpos,
688 output_cursor.x, output_cursor.y); 683 w->output_cursor.x, w->output_cursor.y);
689 684
690 if (draw_window_fringes (w, 1)) 685 if (draw_window_fringes (w, 1))
691 x_draw_vertical_border (w); 686 x_draw_vertical_border (w);
@@ -849,7 +844,7 @@ w32_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
849 } 844 }
850 845
851 /* Must clip because of partially visible lines. */ 846 /* Must clip because of partially visible lines. */
852 w32_clip_to_row (w, row, -1, hdc); 847 w32_clip_to_row (w, row, ANY_AREA, hdc);
853 848
854 if (p->which && p->which < max_fringe_bmp) 849 if (p->which && p->which < max_fringe_bmp)
855 { 850 {
@@ -934,28 +929,6 @@ w32_destroy_fringe_bitmap (int which)
934 fringe_bmp[which] = 0; 929 fringe_bmp[which] = 0;
935} 930}
936 931
937
938
939/* This is called when starting Emacs and when restarting after
940 suspend. When starting Emacs, no window is mapped. And nothing
941 must be done to Emacs's own window if it is suspended (though that
942 rarely happens). */
943
944static void
945w32_set_terminal_modes (struct terminal *term)
946{
947}
948
949/* This is called when exiting or suspending Emacs. Exiting will make
950 the W32 windows go away, and suspending requires no action. */
951
952static void
953w32_reset_terminal_modes (struct terminal *term)
954{
955}
956
957
958
959/*********************************************************************** 932/***********************************************************************
960 Display Iterator 933 Display Iterator
961 ***********************************************************************/ 934 ***********************************************************************/
@@ -2651,11 +2624,7 @@ x_clear_frame (struct frame *f)
2651 /* Clearing the frame will erase any cursor, so mark them all as no 2624 /* Clearing the frame will erase any cursor, so mark them all as no
2652 longer visible. */ 2625 longer visible. */
2653 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); 2626 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
2654 output_cursor.hpos = output_cursor.vpos = 0;
2655 output_cursor.x = -1;
2656 2627
2657 /* We don't set the output cursor here because there will always
2658 follow an explicit cursor_to. */
2659 block_input (); 2628 block_input ();
2660 2629
2661 w32_clear_window (f); 2630 w32_clear_window (f);
@@ -2693,19 +2662,6 @@ w32_ring_bell (struct frame *f)
2693 unblock_input (); 2662 unblock_input ();
2694} 2663}
2695 2664
2696
2697/* Specify how many text lines, from the top of the window,
2698 should be affected by insert-lines and delete-lines operations.
2699 This, and those operations, are used only within an update
2700 that is bounded by calls to x_update_begin and x_update_end. */
2701
2702static void
2703w32_set_terminal_window (struct frame *f, int n)
2704{
2705 /* This function intentionally left blank. */
2706}
2707
2708
2709/*********************************************************************** 2665/***********************************************************************
2710 Line Dance 2666 Line Dance
2711 ***********************************************************************/ 2667 ***********************************************************************/
@@ -2736,7 +2692,7 @@ x_scroll_run (struct window *w, struct run *run)
2736 /* Get frame-relative bounding box of the text display area of W, 2692 /* Get frame-relative bounding box of the text display area of W,
2737 without mode lines. Include in this box the left and right 2693 without mode lines. Include in this box the left and right
2738 fringes of W. */ 2694 fringes of W. */
2739 window_box (w, -1, &x, &y, &width, &height); 2695 window_box (w, ANY_AREA, &x, &y, &width, &height);
2740 2696
2741 /* If the fringe is adjacent to the left (right) scroll bar of a 2697 /* If the fringe is adjacent to the left (right) scroll bar of a
2742 leftmost (rightmost, respectively) window, then extend its 2698 leftmost (rightmost, respectively) window, then extend its
@@ -3830,7 +3786,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3830 bool fringe_extended_p; 3786 bool fringe_extended_p;
3831 3787
3832 /* Get window dimensions. */ 3788 /* Get window dimensions. */
3833 window_box (w, -1, 0, &window_y, 0, &window_height); 3789 window_box (w, ANY_AREA, 0, &window_y, 0, &window_height);
3834 top = window_y; 3790 top = window_y;
3835 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f); 3791 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
3836 height = window_height; 3792 height = window_height;
@@ -4544,18 +4500,16 @@ w32_read_socket (struct terminal *terminal,
4544 /* Generate SELECT_WINDOW_EVENTs when needed. */ 4500 /* Generate SELECT_WINDOW_EVENTs when needed. */
4545 if (!NILP (Vmouse_autoselect_window)) 4501 if (!NILP (Vmouse_autoselect_window))
4546 { 4502 {
4547 Lisp_Object window; 4503 static Lisp_Object last_mouse_window;
4548 int x = LOWORD (msg.msg.lParam); 4504 Lisp_Object window = window_from_coordinates
4549 int y = HIWORD (msg.msg.lParam); 4505 (f, LOWORD (msg.msg.lParam), HIWORD (msg.msg.lParam), 0, 0);
4550
4551 window = window_from_coordinates (f, x, y, 0, 0);
4552 4506
4553 /* Window will be selected only when it is not 4507 /* Window will be selected only when it is not
4554 selected now and last mouse movement event was 4508 selected now and last mouse movement event was
4555 not in it. Minibuffer window will be selected 4509 not in it. Minibuffer window will be selected
4556 only when it is active. */ 4510 only when it is active. */
4557 if (WINDOWP (window) 4511 if (WINDOWP (window)
4558 && !EQ (window, last_window) 4512 && !EQ (window, last_mouse_window)
4559 && !EQ (window, selected_window) 4513 && !EQ (window, selected_window)
4560 /* For click-to-focus window managers 4514 /* For click-to-focus window managers
4561 create event iff we don't leave the 4515 create event iff we don't leave the
@@ -4567,8 +4521,8 @@ w32_read_socket (struct terminal *terminal,
4567 inev.kind = SELECT_WINDOW_EVENT; 4521 inev.kind = SELECT_WINDOW_EVENT;
4568 inev.frame_or_window = window; 4522 inev.frame_or_window = window;
4569 } 4523 }
4570 4524 /* Remember the last window where we saw the mouse. */
4571 last_window = window; 4525 last_mouse_window = window;
4572 } 4526 }
4573 if (!note_mouse_movement (f, &msg.msg)) 4527 if (!note_mouse_movement (f, &msg.msg))
4574 help_echo_string = previous_help_echo_string; 4528 help_echo_string = previous_help_echo_string;
@@ -5123,7 +5077,8 @@ w32_read_socket (struct terminal *terminal,
5123 mode lines must be clipped to the whole window. */ 5077 mode lines must be clipped to the whole window. */
5124 5078
5125static void 5079static void
5126w32_clip_to_row (struct window *w, struct glyph_row *row, int area, HDC hdc) 5080w32_clip_to_row (struct window *w, struct glyph_row *row,
5081 enum glyph_row_area area, HDC hdc)
5127{ 5082{
5128 RECT clip_rect; 5083 RECT clip_rect;
5129 int window_x, window_y, window_width; 5084 int window_x, window_y, window_width;
@@ -6303,11 +6258,6 @@ w32_make_rdb (char *xrm_option)
6303 return buffer; 6258 return buffer;
6304} 6259}
6305 6260
6306void
6307x_flush (struct frame * f)
6308{ /* Nothing to do */ }
6309
6310
6311extern frame_parm_handler w32_frame_parm_handlers[]; 6261extern frame_parm_handler w32_frame_parm_handlers[];
6312 6262
6313static struct redisplay_interface w32_redisplay_interface = 6263static struct redisplay_interface w32_redisplay_interface =
@@ -6321,9 +6271,7 @@ static struct redisplay_interface w32_redisplay_interface =
6321 x_after_update_window_line, 6271 x_after_update_window_line,
6322 x_update_window_begin, 6272 x_update_window_begin,
6323 x_update_window_end, 6273 x_update_window_end,
6324 x_cursor_to, 6274 0, /* flush_display */
6325 x_flush,
6326 0, /* flush_display_optional */
6327 x_clear_window_mouse_face, 6275 x_clear_window_mouse_face,
6328 x_get_glyph_overhangs, 6276 x_get_glyph_overhangs,
6329 x_fix_overlapping_area, 6277 x_fix_overlapping_area,
@@ -6358,11 +6306,11 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
6358 terminal->ins_del_lines_hook = x_ins_del_lines; 6306 terminal->ins_del_lines_hook = x_ins_del_lines;
6359 terminal->delete_glyphs_hook = x_delete_glyphs; 6307 terminal->delete_glyphs_hook = x_delete_glyphs;
6360 terminal->ring_bell_hook = w32_ring_bell; 6308 terminal->ring_bell_hook = w32_ring_bell;
6361 terminal->reset_terminal_modes_hook = w32_reset_terminal_modes; 6309 terminal->reset_terminal_modes_hook = NULL;
6362 terminal->set_terminal_modes_hook = w32_set_terminal_modes; 6310 terminal->set_terminal_modes_hook = NULL;
6363 terminal->update_begin_hook = x_update_begin; 6311 terminal->update_begin_hook = x_update_begin;
6364 terminal->update_end_hook = x_update_end; 6312 terminal->update_end_hook = x_update_end;
6365 terminal->set_terminal_window_hook = w32_set_terminal_window; 6313 terminal->set_terminal_window_hook = NULL;
6366 terminal->read_socket_hook = w32_read_socket; 6314 terminal->read_socket_hook = w32_read_socket;
6367 terminal->frame_up_to_date_hook = w32_frame_up_to_date; 6315 terminal->frame_up_to_date_hook = w32_frame_up_to_date;
6368 terminal->mouse_position_hook = w32_mouse_position; 6316 terminal->mouse_position_hook = w32_mouse_position;
diff --git a/src/w32term.h b/src/w32term.h
index 41c5c71832a..b4818f69aee 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -211,7 +211,6 @@ extern void x_set_window_size (struct frame *f, int change_grav,
211 int cols, int rows); 211 int cols, int rows);
212extern int x_display_pixel_height (struct w32_display_info *); 212extern int x_display_pixel_height (struct w32_display_info *);
213extern int x_display_pixel_width (struct w32_display_info *); 213extern int x_display_pixel_width (struct w32_display_info *);
214extern void x_sync (struct frame *);
215extern Lisp_Object x_get_focus_frame (struct frame *); 214extern Lisp_Object x_get_focus_frame (struct frame *);
216extern void x_set_mouse_position (struct frame *f, int h, int v); 215extern void x_set_mouse_position (struct frame *f, int h, int v);
217extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y); 216extern void x_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y);
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 19c6b72bf89..7629e49caf8 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -333,9 +333,3 @@ drain_message_queue (void)
333 } 333 }
334 return retval; 334 return retval;
335} 335}
336
337/* x_sync is a no-op on W32. */
338void
339x_sync (struct frame *f)
340{
341}
diff --git a/src/window.c b/src/window.c
index 1331ac014ff..410015e472e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -39,13 +39,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
39#include "blockinput.h" 39#include "blockinput.h"
40#include "intervals.h" 40#include "intervals.h"
41#include "termhooks.h" /* For FRAME_TERMINAL. */ 41#include "termhooks.h" /* For FRAME_TERMINAL. */
42 42#ifdef HAVE_WINDOW_SYSTEM
43#ifdef HAVE_X_WINDOWS 43#include TERM_HEADER
44#include "xterm.h" 44#endif /* HAVE_WINDOW_SYSTEM */
45#endif /* HAVE_X_WINDOWS */
46#ifdef HAVE_NTGUI
47#include "w32term.h"
48#endif
49#ifdef MSDOS 45#ifdef MSDOS
50#include "msdos.h" 46#include "msdos.h"
51#endif 47#endif
@@ -552,15 +548,7 @@ select_window_1 (Lisp_Object window, bool inhibit_point_swap)
552 than one window. It also matters when 548 than one window. It also matters when
553 redisplay_window has altered point after scrolling, 549 redisplay_window has altered point after scrolling,
554 because it makes the change only in the window. */ 550 because it makes the change only in the window. */
555 { 551 set_point_from_marker (XWINDOW (window)->pointm);
556 register ptrdiff_t new_point = marker_position (XWINDOW (window)->pointm);
557 if (new_point < BEGV)
558 SET_PT (BEGV);
559 else if (new_point > ZV)
560 SET_PT (ZV);
561 else
562 SET_PT (new_point);
563 }
564} 552}
565 553
566DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0, 554DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
@@ -1505,7 +1493,6 @@ if it isn't already recorded. */)
1505 && !noninteractive) 1493 && !noninteractive)
1506 { 1494 {
1507 struct text_pos startp; 1495 struct text_pos startp;
1508 ptrdiff_t charpos = marker_position (w->start);
1509 struct it it; 1496 struct it it;
1510 struct buffer *old_buffer = NULL; 1497 struct buffer *old_buffer = NULL;
1511 void *itdata = NULL; 1498 void *itdata = NULL;
@@ -1523,12 +1510,7 @@ if it isn't already recorded. */)
1523 `-l' containing a call to `rmail' with subsequent other 1510 `-l' containing a call to `rmail' with subsequent other
1524 commands. At the end, W->start happened to be BEG, while 1511 commands. At the end, W->start happened to be BEG, while
1525 rmail had already narrowed the buffer. */ 1512 rmail had already narrowed the buffer. */
1526 if (charpos < BEGV) 1513 CLIP_TEXT_POS_FROM_MARKER (startp, w->start);
1527 SET_TEXT_POS (startp, BEGV, BEGV_BYTE);
1528 else if (charpos > ZV)
1529 SET_TEXT_POS (startp, ZV, ZV_BYTE);
1530 else
1531 SET_TEXT_POS_FROM_MARKER (startp, w->start);
1532 1514
1533 itdata = bidi_shelve_cache (); 1515 itdata = bidi_shelve_cache ();
1534 start_display (&it, w, startp); 1516 start_display (&it, w, startp);
@@ -2969,7 +2951,7 @@ window-start value is reasonable when this function is called. */)
2969 } 2951 }
2970 } 2952 }
2971 2953
2972 adjust_glyphs (f); 2954 adjust_frame_glyphs (f);
2973 unblock_input (); 2955 unblock_input ();
2974 2956
2975 run_window_configuration_change_hook (f); 2957 run_window_configuration_change_hook (f);
@@ -3352,10 +3334,8 @@ temp_output_buffer_show (register Lisp_Object buf)
3352 3334
3353 if (!NILP (Vtemp_buffer_show_function)) 3335 if (!NILP (Vtemp_buffer_show_function))
3354 call1 (Vtemp_buffer_show_function, buf); 3336 call1 (Vtemp_buffer_show_function, buf);
3355 else 3337 else if (WINDOW_LIVE_P (window = display_buffer (buf, Qnil, Qnil)))
3356 { 3338 {
3357 window = display_buffer (buf, Qnil, Qnil);
3358
3359 if (!EQ (XWINDOW (window)->frame, selected_frame)) 3339 if (!EQ (XWINDOW (window)->frame, selected_frame))
3360 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window))); 3340 Fmake_frame_visible (WINDOW_FRAME (XWINDOW (window)));
3361 Vminibuf_scroll_window = window; 3341 Vminibuf_scroll_window = window;
@@ -3445,6 +3425,7 @@ make_window (void)
3445 non-Lisp data, so do it only for slots which should not be zero. */ 3425 non-Lisp data, so do it only for slots which should not be zero. */
3446 w->nrows_scale_factor = w->ncols_scale_factor = 1; 3426 w->nrows_scale_factor = w->ncols_scale_factor = 1;
3447 w->left_fringe_width = w->right_fringe_width = -1; 3427 w->left_fringe_width = w->right_fringe_width = -1;
3428 w->mode_line_height = w->header_line_height = -1;
3448 w->phys_cursor_type = -1; 3429 w->phys_cursor_type = -1;
3449 w->phys_cursor_width = -1; 3430 w->phys_cursor_width = -1;
3450 w->scroll_bar_width = -1; 3431 w->scroll_bar_width = -1;
@@ -3670,7 +3651,7 @@ be applied on the Elisp level. */)
3670 windows_or_buffers_changed++; 3651 windows_or_buffers_changed++;
3671 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 3652 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
3672 3653
3673 adjust_glyphs (f); 3654 adjust_frame_glyphs (f);
3674 unblock_input (); 3655 unblock_input ();
3675 3656
3676 run_window_configuration_change_hook (f); 3657 run_window_configuration_change_hook (f);
@@ -3940,7 +3921,7 @@ set correctly. See the code of `split-window' for how this is done. */)
3940 3921
3941 block_input (); 3922 block_input ();
3942 window_resize_apply (p, horflag); 3923 window_resize_apply (p, horflag);
3943 adjust_glyphs (f); 3924 adjust_frame_glyphs (f);
3944 /* Set buffer of NEW to buffer of reference window. Don't run 3925 /* Set buffer of NEW to buffer of reference window. Don't run
3945 any hooks. */ 3926 any hooks. */
3946 set_window_buffer (new, r->contents, 0, 1); 3927 set_window_buffer (new, r->contents, 0, 1);
@@ -4072,7 +4053,7 @@ Signal an error when WINDOW is the only window on its frame. */)
4072 recombine_windows (sibling); 4053 recombine_windows (sibling);
4073 } 4054 }
4074 4055
4075 adjust_glyphs (f); 4056 adjust_frame_glyphs (f);
4076 4057
4077 if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f))) 4058 if (!WINDOW_LIVE_P (FRAME_SELECTED_WINDOW (f)))
4078 /* We deleted the frame's selected window. */ 4059 /* We deleted the frame's selected window. */
@@ -4159,7 +4140,7 @@ grow_mini_window (struct window *w, int delta)
4159 w->total_lines -= XINT (value); 4140 w->total_lines -= XINT (value);
4160 /* Enforce full redisplay. FIXME: make it more selective. */ 4141 /* Enforce full redisplay. FIXME: make it more selective. */
4161 windows_or_buffers_changed++; 4142 windows_or_buffers_changed++;
4162 adjust_glyphs (f); 4143 adjust_frame_glyphs (f);
4163 unblock_input (); 4144 unblock_input ();
4164 } 4145 }
4165} 4146}
@@ -4193,7 +4174,7 @@ shrink_mini_window (struct window *w)
4193 w->total_lines = 1; 4174 w->total_lines = 1;
4194 /* Enforce full redisplay. FIXME: make it more selective. */ 4175 /* Enforce full redisplay. FIXME: make it more selective. */
4195 windows_or_buffers_changed++; 4176 windows_or_buffers_changed++;
4196 adjust_glyphs (f); 4177 adjust_frame_glyphs (f);
4197 unblock_input (); 4178 unblock_input ();
4198 } 4179 }
4199 /* If the above failed for whatever strange reason we must make a 4180 /* If the above failed for whatever strange reason we must make a
@@ -4234,7 +4215,7 @@ DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, Sresize_mini
4234 4215
4235 windows_or_buffers_changed++; 4216 windows_or_buffers_changed++;
4236 FRAME_WINDOW_SIZES_CHANGED (f) = 1; 4217 FRAME_WINDOW_SIZES_CHANGED (f) = 1;
4237 adjust_glyphs (f); 4218 adjust_frame_glyphs (f);
4238 unblock_input (); 4219 unblock_input ();
4239 4220
4240 run_window_configuration_change_hook (f); 4221 run_window_configuration_change_hook (f);
@@ -4505,7 +4486,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, int noerror)
4505 visible. */ 4486 visible. */
4506 w->vscroll = (it.last_visible_y 4487 w->vscroll = (it.last_visible_y
4507 - it.current_y + it.max_ascent + it.max_descent); 4488 - it.current_y + it.max_ascent + it.max_descent);
4508 adjust_glyphs (it.f); 4489 adjust_frame_glyphs (it.f);
4509 } 4490 }
4510 else 4491 else
4511 { 4492 {
@@ -5054,7 +5035,6 @@ displayed_window_lines (struct window *w)
5054{ 5035{
5055 struct it it; 5036 struct it it;
5056 struct text_pos start; 5037 struct text_pos start;
5057 ptrdiff_t charpos = marker_position (w->start);
5058 int height = window_box_height (w); 5038 int height = window_box_height (w);
5059 struct buffer *old_buffer; 5039 struct buffer *old_buffer;
5060 int bottom_y; 5040 int bottom_y;
@@ -5071,12 +5051,7 @@ displayed_window_lines (struct window *w)
5071 /* In case W->start is out of the accessible range, do something 5051 /* In case W->start is out of the accessible range, do something
5072 reasonable. This happens in Info mode when Info-scroll-down 5052 reasonable. This happens in Info mode when Info-scroll-down
5073 calls (recenter -1) while W->start is 1. */ 5053 calls (recenter -1) while W->start is 1. */
5074 if (charpos < BEGV) 5054 CLIP_TEXT_POS_FROM_MARKER (start, w->start);
5075 SET_TEXT_POS (start, BEGV, BEGV_BYTE);
5076 else if (charpos > ZV)
5077 SET_TEXT_POS (start, ZV, ZV_BYTE);
5078 else
5079 SET_TEXT_POS_FROM_MARKER (start, w->start);
5080 5055
5081 itdata = bidi_shelve_cache (); 5056 itdata = bidi_shelve_cache ();
5082 start_display (&it, w, start); 5057 start_display (&it, w, start);
@@ -5788,7 +5763,7 @@ the return value is nil. Otherwise the value is t. */)
5788 ++n; 5763 ++n;
5789 } 5764 }
5790 5765
5791 adjust_glyphs (f); 5766 adjust_frame_glyphs (f);
5792 unblock_input (); 5767 unblock_input ();
5793 5768
5794 /* Scan dead buffer windows. */ 5769 /* Scan dead buffer windows. */
@@ -6117,7 +6092,7 @@ apply_window_adjustment (struct window *w)
6117 clear_glyph_matrix (w->current_matrix); 6092 clear_glyph_matrix (w->current_matrix);
6118 w->window_end_valid = 0; 6093 w->window_end_valid = 0;
6119 windows_or_buffers_changed++; 6094 windows_or_buffers_changed++;
6120 adjust_glyphs (XFRAME (WINDOW_FRAME (w))); 6095 adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w)));
6121} 6096}
6122 6097
6123 6098
@@ -6383,7 +6358,7 @@ If PIXELS-P is non-nil, the return value is VSCROLL. */)
6383 /* Adjust glyph matrix of the frame if the virtual display 6358 /* Adjust glyph matrix of the frame if the virtual display
6384 area becomes larger than before. */ 6359 area becomes larger than before. */
6385 if (w->vscroll < 0 && w->vscroll < old_dy) 6360 if (w->vscroll < 0 && w->vscroll < old_dy)
6386 adjust_glyphs (f); 6361 adjust_frame_glyphs (f);
6387 6362
6388 /* Prevent redisplay shortcuts. */ 6363 /* Prevent redisplay shortcuts. */
6389 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; 6364 XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1;
diff --git a/src/window.h b/src/window.h
index de77dcabc85..f5ae81149b3 100644
--- a/src/window.h
+++ b/src/window.h
@@ -236,6 +236,9 @@ struct window
236 /* Where the cursor actually is. */ 236 /* Where the cursor actually is. */
237 struct cursor_pos phys_cursor; 237 struct cursor_pos phys_cursor;
238 238
239 /* Internally used for redisplay purposes. */
240 struct cursor_pos output_cursor;
241
239 /* Vertical cursor position as of last update that completed 242 /* Vertical cursor position as of last update that completed
240 without pause. This is the position of last_point. */ 243 without pause. This is the position of last_point. */
241 int last_cursor_vpos; 244 int last_cursor_vpos;
@@ -261,6 +264,12 @@ struct window
261 A value of -1 means use frame values. */ 264 A value of -1 means use frame values. */
262 int scroll_bar_width; 265 int scroll_bar_width;
263 266
267 /* Effective height of the mode line, or -1 if not known. */
268 int mode_line_height;
269
270 /* Effective height of the header line, or -1 if not known. */
271 int header_line_height;
272
264 /* Z - the buffer position of the last glyph in the current 273 /* Z - the buffer position of the last glyph in the current
265 matrix of W. Only valid if window_end_valid is nonzero. */ 274 matrix of W. Only valid if window_end_valid is nonzero. */
266 ptrdiff_t window_end_pos; 275 ptrdiff_t window_end_pos;
@@ -856,14 +865,6 @@ extern Lisp_Object minibuf_window;
856 865
857extern Lisp_Object minibuf_selected_window; 866extern Lisp_Object minibuf_selected_window;
858 867
859/* Window that the mouse is over (nil if no mouse support). */
860
861extern Lisp_Object Vmouse_window;
862
863/* Last mouse-click event (nil if no mouse support). */
864
865extern Lisp_Object Vmouse_event;
866
867extern Lisp_Object make_window (void); 868extern Lisp_Object make_window (void);
868extern Lisp_Object window_from_coordinates (struct frame *, int, int, 869extern Lisp_Object window_from_coordinates (struct frame *, int, int,
869 enum window_part *, bool); 870 enum window_part *, bool);
@@ -956,6 +957,22 @@ extern void init_window (void);
956extern void syms_of_window (void); 957extern void syms_of_window (void);
957extern void keys_of_window (void); 958extern void keys_of_window (void);
958 959
960/* Move cursor to row/column position VPOS/HPOS, pixel coordinates
961 Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y
962 are window-relative pixel positions. This is always done during
963 window update, so the position is the future output cursor position
964 for currently updated window W. */
965
966WINDOW_INLINE void
967output_cursor_to (struct window *w, int vpos, int hpos, int y, int x)
968{
969 eassert (w);
970 w->output_cursor.hpos = hpos;
971 w->output_cursor.vpos = vpos;
972 w->output_cursor.x = x;
973 w->output_cursor.y = y;
974}
975
959INLINE_HEADER_END 976INLINE_HEADER_END
960 977
961#endif /* not WINDOW_H_INCLUDED */ 978#endif /* not WINDOW_H_INCLUDED */
diff --git a/src/xdisp.c b/src/xdisp.c
index e3a6eca387f..b9a16ffcc43 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -299,19 +299,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
299#include "font.h" 299#include "font.h"
300#include "fontset.h" 300#include "fontset.h"
301#include "blockinput.h" 301#include "blockinput.h"
302 302#ifdef HAVE_WINDOW_SYSTEM
303#ifdef HAVE_X_WINDOWS 303#include TERM_HEADER
304#include "xterm.h" 304#endif /* HAVE_WINDOW_SYSTEM */
305#endif
306#ifdef HAVE_NTGUI
307#include "w32term.h"
308#endif
309#ifdef HAVE_NS
310#include "nsterm.h"
311#endif
312#ifdef USE_GTK
313#include "gtkutil.h"
314#endif
315 305
316#include "font.h" 306#include "font.h"
317#ifdef HAVE_XWIDGETS 307#ifdef HAVE_XWIDGETS
@@ -526,10 +516,6 @@ int update_mode_lines;
526 516
527int windows_or_buffers_changed; 517int windows_or_buffers_changed;
528 518
529/* Nonzero means a frame's cursor type has been changed. */
530
531static int cursor_type_changed;
532
533/* Nonzero after display_mode_line if %l was used and it displayed a 519/* Nonzero after display_mode_line if %l was used and it displayed a
534 line number. */ 520 line number. */
535 521
@@ -587,12 +573,6 @@ static int last_height;
587 573
588int help_echo_showing_p; 574int help_echo_showing_p;
589 575
590/* If >= 0, computed, exact values of mode-line and header-line height
591 to use in the macros CURRENT_MODE_LINE_HEIGHT and
592 CURRENT_HEADER_LINE_HEIGHT. */
593
594int current_mode_line_height, current_header_line_height;
595
596/* The maximum distance to look ahead for text properties. Values 576/* The maximum distance to look ahead for text properties. Values
597 that are too small let us call compute_char_face and similar 577 that are too small let us call compute_char_face and similar
598 functions too often which is expensive. Values that are too large 578 functions too often which is expensive. Values that are too large
@@ -764,6 +744,8 @@ Lisp_Object previous_help_echo_string;
764 744
765/* Platform-independent portion of hourglass implementation. */ 745/* Platform-independent portion of hourglass implementation. */
766 746
747#ifdef HAVE_WINDOW_SYSTEM
748
767/* Non-zero means an hourglass cursor is currently shown. */ 749/* Non-zero means an hourglass cursor is currently shown. */
768int hourglass_shown_p; 750int hourglass_shown_p;
769 751
@@ -771,6 +753,8 @@ int hourglass_shown_p;
771 an hourglass cursor on all frames. */ 753 an hourglass cursor on all frames. */
772struct atimer *hourglass_atimer; 754struct atimer *hourglass_atimer;
773 755
756#endif /* HAVE_WINDOW_SYSTEM */
757
774/* Name of the face used to display glyphless characters. */ 758/* Name of the face used to display glyphless characters. */
775Lisp_Object Qglyphless_char; 759Lisp_Object Qglyphless_char;
776 760
@@ -780,14 +764,17 @@ static Lisp_Object Qglyphless_char_display;
780/* Method symbols for Vglyphless_char_display. */ 764/* Method symbols for Vglyphless_char_display. */
781static Lisp_Object Qhex_code, Qempty_box, Qthin_space, Qzero_width; 765static Lisp_Object Qhex_code, Qempty_box, Qthin_space, Qzero_width;
782 766
783/* Default pixel width of `thin-space' display method. */
784#define THIN_SPACE_WIDTH 1
785
786/* Default number of seconds to wait before displaying an hourglass 767/* Default number of seconds to wait before displaying an hourglass
787 cursor. */ 768 cursor. */
788#define DEFAULT_HOURGLASS_DELAY 1 769#define DEFAULT_HOURGLASS_DELAY 1
789 770
790 771#ifdef HAVE_WINDOW_SYSTEM
772
773/* Default pixel width of `thin-space' display method. */
774#define THIN_SPACE_WIDTH 1
775
776#endif /* HAVE_WINDOW_SYSTEM */
777
791/* Function prototypes. */ 778/* Function prototypes. */
792 779
793static void setup_for_ellipsis (struct it *, int); 780static void setup_for_ellipsis (struct it *, int);
@@ -973,12 +960,12 @@ window_text_bottom_y (struct window *w)
973 return height; 960 return height;
974} 961}
975 962
976/* Return the pixel width of display area AREA of window W. AREA < 0 963/* Return the pixel width of display area AREA of window W.
977 means return the total width of W, not including fringes to 964 ANY_AREA means return the total width of W, not including
978 the left and right of the window. */ 965 fringes to the left and right of the window. */
979 966
980int 967int
981window_box_width (struct window *w, int area) 968window_box_width (struct window *w, enum glyph_row_area area)
982{ 969{
983 int cols = w->total_cols; 970 int cols = w->total_cols;
984 int pixels = 0; 971 int pixels = 0;
@@ -1056,11 +1043,11 @@ window_box_height (struct window *w)
1056} 1043}
1057 1044
1058/* Return the window-relative coordinate of the left edge of display 1045/* Return the window-relative coordinate of the left edge of display
1059 area AREA of window W. AREA < 0 means return the left edge of the 1046 area AREA of window W. ANY_AREA means return the left edge of the
1060 whole window, to the right of the left fringe of W. */ 1047 whole window, to the right of the left fringe of W. */
1061 1048
1062int 1049int
1063window_box_left_offset (struct window *w, int area) 1050window_box_left_offset (struct window *w, enum glyph_row_area area)
1064{ 1051{
1065 int x; 1052 int x;
1066 1053
@@ -1088,21 +1075,21 @@ window_box_left_offset (struct window *w, int area)
1088 1075
1089 1076
1090/* Return the window-relative coordinate of the right edge of display 1077/* Return the window-relative coordinate of the right edge of display
1091 area AREA of window W. AREA < 0 means return the right edge of the 1078 area AREA of window W. ANY_AREA means return the right edge of the
1092 whole window, to the left of the right fringe of W. */ 1079 whole window, to the left of the right fringe of W. */
1093 1080
1094int 1081int
1095window_box_right_offset (struct window *w, int area) 1082window_box_right_offset (struct window *w, enum glyph_row_area area)
1096{ 1083{
1097 return window_box_left_offset (w, area) + window_box_width (w, area); 1084 return window_box_left_offset (w, area) + window_box_width (w, area);
1098} 1085}
1099 1086
1100/* Return the frame-relative coordinate of the left edge of display 1087/* Return the frame-relative coordinate of the left edge of display
1101 area AREA of window W. AREA < 0 means return the left edge of the 1088 area AREA of window W. ANY_AREA means return the left edge of the
1102 whole window, to the right of the left fringe of W. */ 1089 whole window, to the right of the left fringe of W. */
1103 1090
1104int 1091int
1105window_box_left (struct window *w, int area) 1092window_box_left (struct window *w, enum glyph_row_area area)
1106{ 1093{
1107 struct frame *f = XFRAME (w->frame); 1094 struct frame *f = XFRAME (w->frame);
1108 int x; 1095 int x;
@@ -1118,25 +1105,25 @@ window_box_left (struct window *w, int area)
1118 1105
1119 1106
1120/* Return the frame-relative coordinate of the right edge of display 1107/* Return the frame-relative coordinate of the right edge of display
1121 area AREA of window W. AREA < 0 means return the right edge of the 1108 area AREA of window W. ANY_AREA means return the right edge of the
1122 whole window, to the left of the right fringe of W. */ 1109 whole window, to the left of the right fringe of W. */
1123 1110
1124int 1111int
1125window_box_right (struct window *w, int area) 1112window_box_right (struct window *w, enum glyph_row_area area)
1126{ 1113{
1127 return window_box_left (w, area) + window_box_width (w, area); 1114 return window_box_left (w, area) + window_box_width (w, area);
1128} 1115}
1129 1116
1130/* Get the bounding box of the display area AREA of window W, without 1117/* Get the bounding box of the display area AREA of window W, without
1131 mode lines, in frame-relative coordinates. AREA < 0 means the 1118 mode lines, in frame-relative coordinates. ANY_AREA means the
1132 whole window, not including the left and right fringes of 1119 whole window, not including the left and right fringes of
1133 the window. Return in *BOX_X and *BOX_Y the frame-relative pixel 1120 the window. Return in *BOX_X and *BOX_Y the frame-relative pixel
1134 coordinates of the upper-left corner of the box. Return in 1121 coordinates of the upper-left corner of the box. Return in
1135 *BOX_WIDTH, and *BOX_HEIGHT the pixel width and height of the box. */ 1122 *BOX_WIDTH, and *BOX_HEIGHT the pixel width and height of the box. */
1136 1123
1137void 1124void
1138window_box (struct window *w, int area, int *box_x, int *box_y, 1125window_box (struct window *w, enum glyph_row_area area, int *box_x,
1139 int *box_width, int *box_height) 1126 int *box_y, int *box_width, int *box_height)
1140{ 1127{
1141 if (box_width) 1128 if (box_width)
1142 *box_width = window_box_width (w, area); 1129 *box_width = window_box_width (w, area);
@@ -1152,27 +1139,27 @@ window_box (struct window *w, int area, int *box_x, int *box_y,
1152 } 1139 }
1153} 1140}
1154 1141
1142#ifdef HAVE_WINDOW_SYSTEM
1155 1143
1156/* Get the bounding box of the display area AREA of window W, without 1144/* Get the bounding box of the display area AREA of window W, without
1157 mode lines. AREA < 0 means the whole window, not including the 1145 mode lines and both fringes of the window. Return in *TOP_LEFT_X
1158 left and right fringe of the window. Return in *TOP_LEFT_X
1159 and TOP_LEFT_Y the frame-relative pixel coordinates of the 1146 and TOP_LEFT_Y the frame-relative pixel coordinates of the
1160 upper-left corner of the box. Return in *BOTTOM_RIGHT_X, and 1147 upper-left corner of the box. Return in *BOTTOM_RIGHT_X, and
1161 *BOTTOM_RIGHT_Y the coordinates of the bottom-right corner of the 1148 *BOTTOM_RIGHT_Y the coordinates of the bottom-right corner of the
1162 box. */ 1149 box. */
1163 1150
1164static void 1151static void
1165window_box_edges (struct window *w, int area, int *top_left_x, int *top_left_y, 1152window_box_edges (struct window *w, int *top_left_x, int *top_left_y,
1166 int *bottom_right_x, int *bottom_right_y) 1153 int *bottom_right_x, int *bottom_right_y)
1167{ 1154{
1168 window_box (w, area, top_left_x, top_left_y, bottom_right_x, 1155 window_box (w, ANY_AREA, top_left_x, top_left_y,
1169 bottom_right_y); 1156 bottom_right_x, bottom_right_y);
1170 *bottom_right_x += *top_left_x; 1157 *bottom_right_x += *top_left_x;
1171 *bottom_right_y += *top_left_y; 1158 *bottom_right_y += *top_left_y;
1172} 1159}
1173 1160
1161#endif /* HAVE_WINDOW_SYSTEM */
1174 1162
1175
1176/*********************************************************************** 1163/***********************************************************************
1177 Utilities 1164 Utilities
1178 ***********************************************************************/ 1165 ***********************************************************************/
@@ -1359,12 +1346,12 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1359 1346
1360 /* Compute exact mode line heights. */ 1347 /* Compute exact mode line heights. */
1361 if (WINDOW_WANTS_MODELINE_P (w)) 1348 if (WINDOW_WANTS_MODELINE_P (w))
1362 current_mode_line_height 1349 w->mode_line_height
1363 = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w), 1350 = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
1364 BVAR (current_buffer, mode_line_format)); 1351 BVAR (current_buffer, mode_line_format));
1365 1352
1366 if (WINDOW_WANTS_HEADER_LINE_P (w)) 1353 if (WINDOW_WANTS_HEADER_LINE_P (w))
1367 current_header_line_height 1354 w->header_line_height
1368 = display_mode_line (w, HEADER_LINE_FACE_ID, 1355 = display_mode_line (w, HEADER_LINE_FACE_ID,
1369 BVAR (current_buffer, header_line_format)); 1356 BVAR (current_buffer, header_line_format));
1370 1357
@@ -1657,8 +1644,6 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1657 if (old_buffer) 1644 if (old_buffer)
1658 set_buffer_internal_1 (old_buffer); 1645 set_buffer_internal_1 (old_buffer);
1659 1646
1660 current_header_line_height = current_mode_line_height = -1;
1661
1662 if (visible_p && w->hscroll > 0) 1647 if (visible_p && w->hscroll > 0)
1663 *x -= 1648 *x -=
1664 window_hscroll_limited (w, WINDOW_XFRAME (w)) 1649 window_hscroll_limited (w, WINDOW_XFRAME (w))
@@ -6721,17 +6706,59 @@ lookup_glyphless_char_display (int c, struct it *it)
6721 return glyphless_method; 6706 return glyphless_method;
6722} 6707}
6723 6708
6724/* Load IT's display element fields with information about the next 6709/* Merge escape glyph face and cache the result. */
6725 display element from the current position of IT. Value is zero if
6726 end of buffer (or C string) is reached. */
6727 6710
6728static struct frame *last_escape_glyph_frame = NULL; 6711static struct frame *last_escape_glyph_frame = NULL;
6729static int last_escape_glyph_face_id = (1 << FACE_ID_BITS); 6712static int last_escape_glyph_face_id = (1 << FACE_ID_BITS);
6730static int last_escape_glyph_merged_face_id = 0; 6713static int last_escape_glyph_merged_face_id = 0;
6731 6714
6732struct frame *last_glyphless_glyph_frame = NULL; 6715static int
6733int last_glyphless_glyph_face_id = (1 << FACE_ID_BITS); 6716merge_escape_glyph_face (struct it *it)
6734int last_glyphless_glyph_merged_face_id = 0; 6717{
6718 int face_id;
6719
6720 if (it->f == last_escape_glyph_frame
6721 && it->face_id == last_escape_glyph_face_id)
6722 face_id = last_escape_glyph_merged_face_id;
6723 else
6724 {
6725 /* Merge the `escape-glyph' face into the current face. */
6726 face_id = merge_faces (it->f, Qescape_glyph, 0, it->face_id);
6727 last_escape_glyph_frame = it->f;
6728 last_escape_glyph_face_id = it->face_id;
6729 last_escape_glyph_merged_face_id = face_id;
6730 }
6731 return face_id;
6732}
6733
6734/* Likewise for glyphless glyph face. */
6735
6736static struct frame *last_glyphless_glyph_frame = NULL;
6737static int last_glyphless_glyph_face_id = (1 << FACE_ID_BITS);
6738static int last_glyphless_glyph_merged_face_id = 0;
6739
6740int
6741merge_glyphless_glyph_face (struct it *it)
6742{
6743 int face_id;
6744
6745 if (it->f == last_glyphless_glyph_frame
6746 && it->face_id == last_glyphless_glyph_face_id)
6747 face_id = last_glyphless_glyph_merged_face_id;
6748 else
6749 {
6750 /* Merge the `glyphless-char' face into the current face. */
6751 face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id);
6752 last_glyphless_glyph_frame = it->f;
6753 last_glyphless_glyph_face_id = it->face_id;
6754 last_glyphless_glyph_merged_face_id = face_id;
6755 }
6756 return face_id;
6757}
6758
6759/* Load IT's display element fields with information about the next
6760 display element from the current position of IT. Value is zero if
6761 end of buffer (or C string) is reached. */
6735 6762
6736static int 6763static int
6737get_next_display_element (struct it *it) 6764get_next_display_element (struct it *it)
@@ -6879,24 +6906,10 @@ get_next_display_element (struct it *it)
6879 g = GLYPH_CODE_CHAR (gc); 6906 g = GLYPH_CODE_CHAR (gc);
6880 lface_id = GLYPH_CODE_FACE (gc); 6907 lface_id = GLYPH_CODE_FACE (gc);
6881 } 6908 }
6882 if (lface_id) 6909
6883 { 6910 face_id = (lface_id
6884 face_id = merge_faces (it->f, Qt, lface_id, it->face_id); 6911 ? merge_faces (it->f, Qt, lface_id, it->face_id)
6885 } 6912 : merge_escape_glyph_face (it));
6886 else if (it->f == last_escape_glyph_frame
6887 && it->face_id == last_escape_glyph_face_id)
6888 {
6889 face_id = last_escape_glyph_merged_face_id;
6890 }
6891 else
6892 {
6893 /* Merge the escape-glyph face into the current face. */
6894 face_id = merge_faces (it->f, Qescape_glyph, 0,
6895 it->face_id);
6896 last_escape_glyph_frame = it->f;
6897 last_escape_glyph_face_id = it->face_id;
6898 last_escape_glyph_merged_face_id = face_id;
6899 }
6900 6913
6901 XSETINT (it->ctl_chars[0], g); 6914 XSETINT (it->ctl_chars[0], g);
6902 XSETINT (it->ctl_chars[1], c ^ 0100); 6915 XSETINT (it->ctl_chars[1], c ^ 0100);
@@ -6928,27 +6941,10 @@ get_next_display_element (struct it *it)
6928 escape_glyph = GLYPH_CODE_CHAR (gc); 6941 escape_glyph = GLYPH_CODE_CHAR (gc);
6929 lface_id = GLYPH_CODE_FACE (gc); 6942 lface_id = GLYPH_CODE_FACE (gc);
6930 } 6943 }
6931 if (lface_id) 6944
6932 { 6945 face_id = (lface_id
6933 /* The display table specified a face. 6946 ? merge_faces (it->f, Qt, lface_id, it->face_id)
6934 Merge it into face_id and also into escape_glyph. */ 6947 : merge_escape_glyph_face (it));
6935 face_id = merge_faces (it->f, Qt, lface_id,
6936 it->face_id);
6937 }
6938 else if (it->f == last_escape_glyph_frame
6939 && it->face_id == last_escape_glyph_face_id)
6940 {
6941 face_id = last_escape_glyph_merged_face_id;
6942 }
6943 else
6944 {
6945 /* Merge the escape-glyph face into the current face. */
6946 face_id = merge_faces (it->f, Qescape_glyph, 0,
6947 it->face_id);
6948 last_escape_glyph_frame = it->f;
6949 last_escape_glyph_face_id = it->face_id;
6950 last_escape_glyph_merged_face_id = face_id;
6951 }
6952 6948
6953 /* Draw non-ASCII hyphen with just highlighting: */ 6949 /* Draw non-ASCII hyphen with just highlighting: */
6954 6950
@@ -10827,11 +10823,9 @@ clear_garbaged_frames (void)
10827 if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f)) 10823 if (FRAME_VISIBLE_P (f) && FRAME_GARBAGED_P (f))
10828 { 10824 {
10829 if (f->resized_p) 10825 if (f->resized_p)
10830 { 10826 redraw_frame (f);
10831 redraw_frame (f); 10827 else
10832 f->force_flush_display_p = 1; 10828 clear_current_matrices (f);
10833 }
10834 clear_current_matrices (f);
10835 changed_count++; 10829 changed_count++;
10836 f->garbaged = 0; 10830 f->garbaged = 0;
10837 f->resized_p = 0; 10831 f->resized_p = 0;
@@ -10919,7 +10913,7 @@ echo_area_display (int update_frame_p)
10919 Can do with a display update of the echo area, 10913 Can do with a display update of the echo area,
10920 unless we displayed some mode lines. */ 10914 unless we displayed some mode lines. */
10921 update_single_window (w, 1); 10915 update_single_window (w, 1);
10922 FRAME_RIF (f)->flush_display (f); 10916 flush_frame (f);
10923 } 10917 }
10924 else 10918 else
10925 update_frame (f, 1, 1); 10919 update_frame (f, 1, 1);
@@ -11501,62 +11495,6 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run)
11501 return hooks_run; 11495 return hooks_run;
11502} 11496}
11503 11497
11504
11505
11506/***********************************************************************
11507 Output Cursor
11508 ***********************************************************************/
11509
11510#ifdef HAVE_WINDOW_SYSTEM
11511
11512/* EXPORT:
11513 Nominal cursor position -- where to draw output.
11514 HPOS and VPOS are window relative glyph matrix coordinates.
11515 X and Y are window relative pixel coordinates. */
11516
11517struct cursor_pos output_cursor;
11518
11519
11520/* EXPORT:
11521 Set the global variable output_cursor to CURSOR. All cursor
11522 positions are relative to currently updated window. */
11523
11524void
11525set_output_cursor (struct cursor_pos *cursor)
11526{
11527 output_cursor.hpos = cursor->hpos;
11528 output_cursor.vpos = cursor->vpos;
11529 output_cursor.x = cursor->x;
11530 output_cursor.y = cursor->y;
11531}
11532
11533
11534/* EXPORT for RIF:
11535 Set a nominal cursor position.
11536
11537 HPOS and VPOS are column/row positions in a window glyph matrix.
11538 X and Y are window text area relative pixel positions.
11539
11540 This is always done during window update, so the position is the
11541 future output cursor position for currently updated window W.
11542 NOTE: W is used only to check whether this function is called
11543 in a consistent manner via the redisplay interface. */
11544
11545void
11546x_cursor_to (struct window *w, int vpos, int hpos, int y, int x)
11547{
11548 eassert (w);
11549
11550 /* Set the output cursor. */
11551 output_cursor.hpos = hpos;
11552 output_cursor.vpos = vpos;
11553 output_cursor.x = x;
11554 output_cursor.y = y;
11555}
11556
11557#endif /* HAVE_WINDOW_SYSTEM */
11558
11559
11560/*********************************************************************** 11498/***********************************************************************
11561 Tool-bars 11499 Tool-bars
11562 ***********************************************************************/ 11500 ***********************************************************************/
@@ -12108,7 +12046,7 @@ redisplay_tool_bar (struct frame *f)
12108 if (WINDOW_TOTAL_LINES (w) != old_height) 12046 if (WINDOW_TOTAL_LINES (w) != old_height)
12109 { 12047 {
12110 clear_glyph_matrix (w->desired_matrix); 12048 clear_glyph_matrix (w->desired_matrix);
12111 fonts_changed_p = 1; 12049 f->fonts_changed = 1;
12112 return 1; 12050 return 1;
12113 } 12051 }
12114 } 12052 }
@@ -12209,7 +12147,7 @@ redisplay_tool_bar (struct frame *f)
12209 { 12147 {
12210 clear_glyph_matrix (w->desired_matrix); 12148 clear_glyph_matrix (w->desired_matrix);
12211 f->n_tool_bar_rows = nrows; 12149 f->n_tool_bar_rows = nrows;
12212 fonts_changed_p = 1; 12150 f->fonts_changed = 1;
12213 return 1; 12151 return 1;
12214 } 12152 }
12215 } 12153 }
@@ -13095,15 +13033,6 @@ redisplay_internal (void)
13095 last_glyphless_glyph_frame = NULL; 13033 last_glyphless_glyph_frame = NULL;
13096 last_glyphless_glyph_face_id = (1 << FACE_ID_BITS); 13034 last_glyphless_glyph_face_id = (1 << FACE_ID_BITS);
13097 13035
13098 /* If new fonts have been loaded that make a glyph matrix adjustment
13099 necessary, do it. */
13100 if (fonts_changed_p)
13101 {
13102 adjust_glyphs (NULL);
13103 ++windows_or_buffers_changed;
13104 fonts_changed_p = 0;
13105 }
13106
13107 /* If face_change_count is non-zero, init_iterator will free all 13036 /* If face_change_count is non-zero, init_iterator will free all
13108 realized faces, which includes the faces referenced from current 13037 realized faces, which includes the faces referenced from current
13109 matrices. So, we can't reuse current matrices in this case. */ 13038 matrices. So, we can't reuse current matrices in this case. */
@@ -13134,7 +13063,19 @@ redisplay_internal (void)
13134 struct frame *f = XFRAME (frame); 13063 struct frame *f = XFRAME (frame);
13135 13064
13136 if (FRAME_VISIBLE_P (f)) 13065 if (FRAME_VISIBLE_P (f))
13137 ++number_of_visible_frames; 13066 {
13067 ++number_of_visible_frames;
13068 /* Adjust matrices for visible frames only. */
13069 if (f->fonts_changed)
13070 {
13071 adjust_frame_glyphs (f);
13072 f->fonts_changed = 0;
13073 }
13074 /* If cursor type has been changed on the frame
13075 other than selected, consider all frames. */
13076 if (f != sf && f->cursor_type_changed)
13077 update_mode_lines++;
13078 }
13138 clear_desired_matrices (f); 13079 clear_desired_matrices (f);
13139 } 13080 }
13140 13081
@@ -13183,8 +13124,7 @@ redisplay_internal (void)
13183 } 13124 }
13184 13125
13185 consider_all_windows_p = (update_mode_lines 13126 consider_all_windows_p = (update_mode_lines
13186 || buffer_shared_and_changed () 13127 || buffer_shared_and_changed ());
13187 || cursor_type_changed);
13188 13128
13189 /* If specs for an arrow have changed, do thorough redisplay 13129 /* If specs for an arrow have changed, do thorough redisplay
13190 to ensure we remove any arrow that should no longer exist. */ 13130 to ensure we remove any arrow that should no longer exist. */
@@ -13218,9 +13158,7 @@ redisplay_internal (void)
13218 if (!display_last_displayed_message_p) 13158 if (!display_last_displayed_message_p)
13219 message_cleared_p = 0; 13159 message_cleared_p = 0;
13220 13160
13221 if (fonts_changed_p) 13161 if (window_height_changed_p)
13222 goto retry;
13223 else if (window_height_changed_p)
13224 { 13162 {
13225 consider_all_windows_p = 1; 13163 consider_all_windows_p = 1;
13226 ++update_mode_lines; 13164 ++update_mode_lines;
@@ -13277,6 +13215,7 @@ redisplay_internal (void)
13277 && !current_buffer->prevent_redisplay_optimizations_p 13215 && !current_buffer->prevent_redisplay_optimizations_p
13278 && FRAME_VISIBLE_P (XFRAME (w->frame)) 13216 && FRAME_VISIBLE_P (XFRAME (w->frame))
13279 && !FRAME_OBSCURED_P (XFRAME (w->frame)) 13217 && !FRAME_OBSCURED_P (XFRAME (w->frame))
13218 && !XFRAME (w->frame)->cursor_type_changed
13280 /* Make sure recorded data applies to current buffer, etc. */ 13219 /* Make sure recorded data applies to current buffer, etc. */
13281 && this_line_buffer == current_buffer 13220 && this_line_buffer == current_buffer
13282 && match_p 13221 && match_p
@@ -13502,6 +13441,8 @@ redisplay_internal (void)
13502 && !EQ (FRAME_TTY (f)->top_frame, frame)) 13441 && !EQ (FRAME_TTY (f)->top_frame, frame))
13503 continue; 13442 continue;
13504 13443
13444 retry_frame:
13445
13505 if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) 13446 if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf)
13506 { 13447 {
13507 /* Mark all the scroll bars to be removed; we'll redeem 13448 /* Mark all the scroll bars to be removed; we'll redeem
@@ -13521,20 +13462,22 @@ redisplay_internal (void)
13521 if (FRAME_TERMINAL (f)->judge_scroll_bars_hook) 13462 if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
13522 FRAME_TERMINAL (f)->judge_scroll_bars_hook (f); 13463 FRAME_TERMINAL (f)->judge_scroll_bars_hook (f);
13523 13464
13524 /* If fonts changed, display again. */
13525 /* ??? rms: I suspect it is a mistake to jump all the way
13526 back to retry here. It should just retry this frame. */
13527 if (fonts_changed_p)
13528 goto retry;
13529
13530 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) 13465 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
13531 { 13466 {
13467 /* If fonts changed on visible frame, display again. */
13468 if (f->fonts_changed)
13469 {
13470 adjust_frame_glyphs (f);
13471 f->fonts_changed = 0;
13472 goto retry_frame;
13473 }
13474
13532 /* See if we have to hscroll. */ 13475 /* See if we have to hscroll. */
13533 if (!f->already_hscrolled_p) 13476 if (!f->already_hscrolled_p)
13534 { 13477 {
13535 f->already_hscrolled_p = 1; 13478 f->already_hscrolled_p = 1;
13536 if (hscroll_windows (f->root_window)) 13479 if (hscroll_windows (f->root_window))
13537 goto retry; 13480 goto retry_frame;
13538 } 13481 }
13539 13482
13540 /* Prevent various kinds of signals during display 13483 /* Prevent various kinds of signals during display
@@ -13548,6 +13491,7 @@ redisplay_internal (void)
13548 /* Update the display. */ 13491 /* Update the display. */
13549 set_window_update_flags (XWINDOW (f->root_window), 1); 13492 set_window_update_flags (XWINDOW (f->root_window), 1);
13550 pending |= update_frame (f, 0, 0); 13493 pending |= update_frame (f, 0, 0);
13494 f->cursor_type_changed = 0;
13551 f->updated_p = 1; 13495 f->updated_p = 1;
13552 } 13496 }
13553 } 13497 }
@@ -13592,7 +13536,7 @@ redisplay_internal (void)
13592 13536
13593 update: 13537 update:
13594 /* If fonts changed, display again. */ 13538 /* If fonts changed, display again. */
13595 if (fonts_changed_p) 13539 if (sf->fonts_changed)
13596 goto retry; 13540 goto retry;
13597 13541
13598 /* Prevent various kinds of signals during display update. 13542 /* Prevent various kinds of signals during display update.
@@ -13609,6 +13553,7 @@ redisplay_internal (void)
13609 13553
13610 XWINDOW (selected_window)->must_be_updated_p = 1; 13554 XWINDOW (selected_window)->must_be_updated_p = 1;
13611 pending = update_frame (sf, 0, 0); 13555 pending = update_frame (sf, 0, 0);
13556 sf->cursor_type_changed = 0;
13612 } 13557 }
13613 13558
13614 /* We may have called echo_area_display at the top of this 13559 /* We may have called echo_area_display at the top of this
@@ -13623,6 +13568,7 @@ redisplay_internal (void)
13623 { 13568 {
13624 XWINDOW (mini_window)->must_be_updated_p = 1; 13569 XWINDOW (mini_window)->must_be_updated_p = 1;
13625 pending |= update_frame (mini_frame, 0, 0); 13570 pending |= update_frame (mini_frame, 0, 0);
13571 mini_frame->cursor_type_changed = 0;
13626 if (!pending && hscroll_windows (mini_window)) 13572 if (!pending && hscroll_windows (mini_window))
13627 goto retry; 13573 goto retry;
13628 } 13574 }
@@ -13663,7 +13609,6 @@ redisplay_internal (void)
13663 13609
13664 update_mode_lines = 0; 13610 update_mode_lines = 0;
13665 windows_or_buffers_changed = 0; 13611 windows_or_buffers_changed = 0;
13666 cursor_type_changed = 0;
13667 } 13612 }
13668 13613
13669 /* Start SIGIO interrupts coming again. Having them off during the 13614 /* Start SIGIO interrupts coming again. Having them off during the
@@ -13761,9 +13706,7 @@ redisplay_preserve_echo_area (int from_where)
13761 else 13706 else
13762 redisplay_internal (); 13707 redisplay_internal ();
13763 13708
13764 if (FRAME_RIF (SELECTED_FRAME ()) != NULL 13709 flush_frame (SELECTED_FRAME ());
13765 && FRAME_RIF (SELECTED_FRAME ())->flush_display_optional)
13766 FRAME_RIF (SELECTED_FRAME ())->flush_display_optional (NULL);
13767} 13710}
13768 13711
13769 13712
@@ -15105,7 +15048,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15105 cases. */ 15048 cases. */
15106 && !update_mode_lines 15049 && !update_mode_lines
15107 && !windows_or_buffers_changed 15050 && !windows_or_buffers_changed
15108 && !cursor_type_changed 15051 && !f->cursor_type_changed
15109 /* Can't use this case if highlighting a region. When a 15052 /* Can't use this case if highlighting a region. When a
15110 region exists, cursor movement has to do more than just 15053 region exists, cursor movement has to do more than just
15111 set the cursor. */ 15054 set the cursor. */
@@ -15452,9 +15395,8 @@ set_vertical_scroll_bar (struct window *w)
15452/* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only 15395/* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only
15453 selected_window is redisplayed. 15396 selected_window is redisplayed.
15454 15397
15455 We can return without actually redisplaying the window if 15398 We can return without actually redisplaying the window if fonts has been
15456 fonts_changed_p. In that case, redisplay_internal will 15399 changed on window's frame. In that case, redisplay_internal will retry. */
15457 retry. */
15458 15400
15459static void 15401static void
15460redisplay_window (Lisp_Object window, int just_this_one_p) 15402redisplay_window (Lisp_Object window, int just_this_one_p)
@@ -15839,7 +15781,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15839 debug_method_add (w, "try_window_id %d", tem); 15781 debug_method_add (w, "try_window_id %d", tem);
15840#endif 15782#endif
15841 15783
15842 if (fonts_changed_p) 15784 if (f->fonts_changed)
15843 goto need_larger_matrices; 15785 goto need_larger_matrices;
15844 if (tem > 0) 15786 if (tem > 0)
15845 goto done; 15787 goto done;
@@ -15909,12 +15851,12 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
15909 IF_DEBUG (debug_method_add (w, "1")); 15851 IF_DEBUG (debug_method_add (w, "1"));
15910 if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0) 15852 if (try_window (window, startp, TRY_WINDOW_CHECK_MARGINS) < 0)
15911 /* -1 means we need to scroll. 15853 /* -1 means we need to scroll.
15912 0 means we need new matrices, but fonts_changed_p 15854 0 means we need new matrices, but fonts_changed
15913 is set in that case, so we will detect it below. */ 15855 is set in that case, so we will detect it below. */
15914 goto try_to_scroll; 15856 goto try_to_scroll;
15915 } 15857 }
15916 15858
15917 if (fonts_changed_p) 15859 if (f->fonts_changed)
15918 goto need_larger_matrices; 15860 goto need_larger_matrices;
15919 15861
15920 if (w->cursor.vpos >= 0) 15862 if (w->cursor.vpos >= 0)
@@ -16102,7 +16044,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16102 /* Redisplay the window. */ 16044 /* Redisplay the window. */
16103 if (!current_matrix_up_to_date_p 16045 if (!current_matrix_up_to_date_p
16104 || windows_or_buffers_changed 16046 || windows_or_buffers_changed
16105 || cursor_type_changed 16047 || f->cursor_type_changed
16106 /* Don't use try_window_reusing_current_matrix in this case 16048 /* Don't use try_window_reusing_current_matrix in this case
16107 because it can have changed the buffer. */ 16049 because it can have changed the buffer. */
16108 || !NILP (Vwindow_scroll_functions) 16050 || !NILP (Vwindow_scroll_functions)
@@ -16115,7 +16057,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16115 /* If new fonts have been loaded (due to fontsets), give up. We 16057 /* If new fonts have been loaded (due to fontsets), give up. We
16116 have to start a new redisplay since we need to re-adjust glyph 16058 have to start a new redisplay since we need to re-adjust glyph
16117 matrices. */ 16059 matrices. */
16118 if (fonts_changed_p) 16060 if (f->fonts_changed)
16119 goto need_larger_matrices; 16061 goto need_larger_matrices;
16120 16062
16121 /* If cursor did not appear assume that the middle of the window is 16063 /* If cursor did not appear assume that the middle of the window is
@@ -16228,7 +16170,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16228 if (WINDOW_WANTS_MODELINE_P (w) 16170 if (WINDOW_WANTS_MODELINE_P (w)
16229 && CURRENT_MODE_LINE_HEIGHT (w) != DESIRED_MODE_LINE_HEIGHT (w)) 16171 && CURRENT_MODE_LINE_HEIGHT (w) != DESIRED_MODE_LINE_HEIGHT (w))
16230 { 16172 {
16231 fonts_changed_p = 1; 16173 f->fonts_changed = 1;
16174 w->mode_line_height = -1;
16232 MATRIX_MODE_LINE_ROW (w->current_matrix)->height 16175 MATRIX_MODE_LINE_ROW (w->current_matrix)->height
16233 = DESIRED_MODE_LINE_HEIGHT (w); 16176 = DESIRED_MODE_LINE_HEIGHT (w);
16234 } 16177 }
@@ -16238,12 +16181,13 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16238 if (WINDOW_WANTS_HEADER_LINE_P (w) 16181 if (WINDOW_WANTS_HEADER_LINE_P (w)
16239 && CURRENT_HEADER_LINE_HEIGHT (w) != DESIRED_HEADER_LINE_HEIGHT (w)) 16182 && CURRENT_HEADER_LINE_HEIGHT (w) != DESIRED_HEADER_LINE_HEIGHT (w))
16240 { 16183 {
16241 fonts_changed_p = 1; 16184 f->fonts_changed = 1;
16185 w->header_line_height = -1;
16242 MATRIX_HEADER_LINE_ROW (w->current_matrix)->height 16186 MATRIX_HEADER_LINE_ROW (w->current_matrix)->height
16243 = DESIRED_HEADER_LINE_HEIGHT (w); 16187 = DESIRED_HEADER_LINE_HEIGHT (w);
16244 } 16188 }
16245 16189
16246 if (fonts_changed_p) 16190 if (f->fonts_changed)
16247 goto need_larger_matrices; 16191 goto need_larger_matrices;
16248 } 16192 }
16249 16193
@@ -16308,8 +16252,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16308 } 16252 }
16309#endif /* HAVE_WINDOW_SYSTEM */ 16253#endif /* HAVE_WINDOW_SYSTEM */
16310 16254
16311 /* We go to this label, with fonts_changed_p set, 16255 /* We go to this label, with fonts_changed set, if it is
16312 if it is necessary to try again using larger glyph matrices. 16256 necessary to try again using larger glyph matrices.
16313 We have to redeem the scroll bar even in this case, 16257 We have to redeem the scroll bar even in this case,
16314 because the loop in redisplay_internal expects that. */ 16258 because the loop in redisplay_internal expects that. */
16315 need_larger_matrices: 16259 need_larger_matrices:
@@ -16383,7 +16327,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16383 { 16327 {
16384 if (display_line (&it)) 16328 if (display_line (&it))
16385 last_text_row = it.glyph_row - 1; 16329 last_text_row = it.glyph_row - 1;
16386 if (fonts_changed_p && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE)) 16330 if (f->fonts_changed && !(flags & TRY_WINDOW_IGNORE_FONTS_CHANGE))
16387 return 0; 16331 return 0;
16388 } 16332 }
16389#ifdef HAVE_XWIDGETS_xxx 16333#ifdef HAVE_XWIDGETS_xxx
@@ -16493,7 +16437,7 @@ try_window_reusing_current_matrix (struct window *w)
16493 /* Don't try to reuse the display if windows have been split 16437 /* Don't try to reuse the display if windows have been split
16494 or such. */ 16438 or such. */
16495 || windows_or_buffers_changed 16439 || windows_or_buffers_changed
16496 || cursor_type_changed) 16440 || f->cursor_type_changed)
16497 return 0; 16441 return 0;
16498 16442
16499 /* Can't do this if region may have changed. */ 16443 /* Can't do this if region may have changed. */
@@ -16541,8 +16485,7 @@ try_window_reusing_current_matrix (struct window *w)
16541 w->cursor.vpos = -1; 16485 w->cursor.vpos = -1;
16542 last_text_row = last_reused_text_row = NULL; 16486 last_text_row = last_reused_text_row = NULL;
16543 16487
16544 while (it.current_y < it.last_visible_y 16488 while (it.current_y < it.last_visible_y && !f->fonts_changed)
16545 && !fonts_changed_p)
16546 { 16489 {
16547 /* If we have reached into the characters in the START row, 16490 /* If we have reached into the characters in the START row,
16548 that means the line boundaries have changed. So we 16491 that means the line boundaries have changed. So we
@@ -16753,7 +16696,7 @@ try_window_reusing_current_matrix (struct window *w)
16753 if (pt_row == NULL) 16696 if (pt_row == NULL)
16754 w->cursor.vpos = -1; 16697 w->cursor.vpos = -1;
16755 last_text_row = NULL; 16698 last_text_row = NULL;
16756 while (it.current_y < it.last_visible_y && !fonts_changed_p) 16699 while (it.current_y < it.last_visible_y && !f->fonts_changed)
16757 if (display_line (&it)) 16700 if (display_line (&it))
16758 last_text_row = it.glyph_row - 1; 16701 last_text_row = it.glyph_row - 1;
16759 16702
@@ -17272,7 +17215,7 @@ try_window_id (struct window *w)
17272 GIVE_UP (1); 17215 GIVE_UP (1);
17273 17216
17274 /* This flag is used to prevent redisplay optimizations. */ 17217 /* This flag is used to prevent redisplay optimizations. */
17275 if (windows_or_buffers_changed || cursor_type_changed) 17218 if (windows_or_buffers_changed || f->cursor_type_changed)
17276 GIVE_UP (2); 17219 GIVE_UP (2);
17277 17220
17278 /* Verify that narrowing has not changed. 17221 /* Verify that narrowing has not changed.
@@ -17603,7 +17546,7 @@ try_window_id (struct window *w)
17603 last_text_row = NULL; 17546 last_text_row = NULL;
17604 overlay_arrow_seen = 0; 17547 overlay_arrow_seen = 0;
17605 while (it.current_y < it.last_visible_y 17548 while (it.current_y < it.last_visible_y
17606 && !fonts_changed_p 17549 && !f->fonts_changed
17607 && (first_unchanged_at_end_row == NULL 17550 && (first_unchanged_at_end_row == NULL
17608 || IT_CHARPOS (it) < stop_pos)) 17551 || IT_CHARPOS (it) < stop_pos))
17609 { 17552 {
@@ -17611,7 +17554,7 @@ try_window_id (struct window *w)
17611 last_text_row = it.glyph_row - 1; 17554 last_text_row = it.glyph_row - 1;
17612 } 17555 }
17613 17556
17614 if (fonts_changed_p) 17557 if (f->fonts_changed)
17615 return -1; 17558 return -1;
17616 17559
17617 17560
@@ -17858,8 +17801,7 @@ try_window_id (struct window *w)
17858 17801
17859 /* Display the rest of the lines at the window end. */ 17802 /* Display the rest of the lines at the window end. */
17860 it.glyph_row = MATRIX_ROW (desired_matrix, it.vpos); 17803 it.glyph_row = MATRIX_ROW (desired_matrix, it.vpos);
17861 while (it.current_y < it.last_visible_y 17804 while (it.current_y < it.last_visible_y && !f->fonts_changed)
17862 && !fonts_changed_p)
17863 { 17805 {
17864 /* Is it always sure that the display agrees with lines in 17806 /* Is it always sure that the display agrees with lines in
17865 the current matrix? I don't think so, so we mark rows 17807 the current matrix? I don't think so, so we mark rows
@@ -19418,7 +19360,7 @@ display_line (struct it *it)
19418 >= it->w->desired_matrix->nrows) 19360 >= it->w->desired_matrix->nrows)
19419 { 19361 {
19420 it->w->nrows_scale_factor++; 19362 it->w->nrows_scale_factor++;
19421 fonts_changed_p = 1; 19363 it->f->fonts_changed = 1;
19422 return 0; 19364 return 0;
19423 } 19365 }
19424 19366
@@ -20770,13 +20712,8 @@ redisplay_mode_lines (Lisp_Object window, int force)
20770 { 20712 {
20771 struct text_pos pt; 20713 struct text_pos pt;
20772 20714
20773 SET_TEXT_POS_FROM_MARKER (pt, w->pointm); 20715 CLIP_TEXT_POS_FROM_MARKER (pt, w->pointm);
20774 if (CHARPOS (pt) < BEGV) 20716 TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt));
20775 TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
20776 else if (CHARPOS (pt) > (ZV - 1))
20777 TEMP_SET_PT_BOTH (ZV, ZV_BYTE);
20778 else
20779 TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt));
20780 } 20717 }
20781 20718
20782 /* Display mode lines. */ 20719 /* Display mode lines. */
@@ -24205,12 +24142,12 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
24205 24142
24206#define IT_EXPAND_MATRIX_WIDTH(it, area) \ 24143#define IT_EXPAND_MATRIX_WIDTH(it, area) \
24207 { \ 24144 { \
24208 if (!fonts_changed_p \ 24145 if (!it->f->fonts_changed \
24209 && (it->glyph_row->glyphs[area] \ 24146 && (it->glyph_row->glyphs[area] \
24210 < it->glyph_row->glyphs[area + 1])) \ 24147 < it->glyph_row->glyphs[area + 1])) \
24211 { \ 24148 { \
24212 it->w->ncols_scale_factor++; \ 24149 it->w->ncols_scale_factor++; \
24213 fonts_changed_p = 1; \ 24150 it->f->fonts_changed = 1; \
24214 } \ 24151 } \
24215 } 24152 }
24216 24153
@@ -25209,21 +25146,7 @@ produce_glyphless_glyph (struct it *it, int for_no_font, Lisp_Object acronym)
25209 base_height = it->ascent + it->descent; 25146 base_height = it->ascent + it->descent;
25210 base_width = font->average_width; 25147 base_width = font->average_width;
25211 25148
25212 /* Get a face ID for the glyph by utilizing a cache (the same way as 25149 face_id = merge_glyphless_glyph_face (it);
25213 done for `escape-glyph' in get_next_display_element). */
25214 if (it->f == last_glyphless_glyph_frame
25215 && it->face_id == last_glyphless_glyph_face_id)
25216 {
25217 face_id = last_glyphless_glyph_merged_face_id;
25218 }
25219 else
25220 {
25221 /* Merge the `glyphless-char' face into the current face. */
25222 face_id = merge_faces (it->f, Qglyphless_char, 0, it->face_id);
25223 last_glyphless_glyph_frame = it->f;
25224 last_glyphless_glyph_face_id = it->face_id;
25225 last_glyphless_glyph_merged_face_id = face_id;
25226 }
25227 25150
25228 if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE) 25151 if (it->glyphless_method == GLYPHLESS_DISPLAY_THIN_SPACE)
25229 { 25152 {
@@ -26037,7 +25960,7 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row,
26037 /* Write glyphs. */ 25960 /* Write glyphs. */
26038 25961
26039 hpos = start - updated_row->glyphs[updated_area]; 25962 hpos = start - updated_row->glyphs[updated_area];
26040 x = draw_glyphs (w, output_cursor.x, 25963 x = draw_glyphs (w, w->output_cursor.x,
26041 updated_row, updated_area, 25964 updated_row, updated_area,
26042 hpos, hpos + len, 25965 hpos, hpos + len,
26043 DRAW_NORMAL_TEXT, 0); 25966 DRAW_NORMAL_TEXT, 0);
@@ -26045,7 +25968,7 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row,
26045 /* Invalidate old phys cursor if the glyph at its hpos is redrawn. */ 25968 /* Invalidate old phys cursor if the glyph at its hpos is redrawn. */
26046 if (updated_area == TEXT_AREA 25969 if (updated_area == TEXT_AREA
26047 && w->phys_cursor_on_p 25970 && w->phys_cursor_on_p
26048 && w->phys_cursor.vpos == output_cursor.vpos 25971 && w->phys_cursor.vpos == w->output_cursor.vpos
26049 && chpos >= hpos 25972 && chpos >= hpos
26050 && chpos < hpos + len) 25973 && chpos < hpos + len)
26051 w->phys_cursor_on_p = 0; 25974 w->phys_cursor_on_p = 0;
@@ -26053,8 +25976,8 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row,
26053 unblock_input (); 25976 unblock_input ();
26054 25977
26055 /* Advance the output cursor. */ 25978 /* Advance the output cursor. */
26056 output_cursor.hpos += len; 25979 w->output_cursor.hpos += len;
26057 output_cursor.x = x; 25980 w->output_cursor.x = x;
26058} 25981}
26059 25982
26060 25983
@@ -26087,25 +26010,25 @@ x_insert_glyphs (struct window *w, struct glyph_row *updated_row,
26087 26010
26088 /* Get the width of the region to shift right. */ 26011 /* Get the width of the region to shift right. */
26089 shifted_region_width = (window_box_width (w, updated_area) 26012 shifted_region_width = (window_box_width (w, updated_area)
26090 - output_cursor.x 26013 - w->output_cursor.x
26091 - shift_by_width); 26014 - shift_by_width);
26092 26015
26093 /* Shift right. */ 26016 /* Shift right. */
26094 frame_x = window_box_left (w, updated_area) + output_cursor.x; 26017 frame_x = window_box_left (w, updated_area) + w->output_cursor.x;
26095 frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, output_cursor.y); 26018 frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, w->output_cursor.y);
26096 26019
26097 FRAME_RIF (f)->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width, 26020 FRAME_RIF (f)->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width,
26098 line_height, shift_by_width); 26021 line_height, shift_by_width);
26099 26022
26100 /* Write the glyphs. */ 26023 /* Write the glyphs. */
26101 hpos = start - row->glyphs[updated_area]; 26024 hpos = start - row->glyphs[updated_area];
26102 draw_glyphs (w, output_cursor.x, row, updated_area, 26025 draw_glyphs (w, w->output_cursor.x, row, updated_area,
26103 hpos, hpos + len, 26026 hpos, hpos + len,
26104 DRAW_NORMAL_TEXT, 0); 26027 DRAW_NORMAL_TEXT, 0);
26105 26028
26106 /* Advance the output cursor. */ 26029 /* Advance the output cursor. */
26107 output_cursor.hpos += len; 26030 w->output_cursor.hpos += len;
26108 output_cursor.x += shift_by_width; 26031 w->output_cursor.x += shift_by_width;
26109 unblock_input (); 26032 unblock_input ();
26110} 26033}
26111 26034
@@ -26144,16 +26067,16 @@ x_clear_end_of_line (struct window *w, struct glyph_row *updated_row,
26144 else 26067 else
26145 to_x = min (to_x, max_x); 26068 to_x = min (to_x, max_x);
26146 26069
26147 to_y = min (max_y, output_cursor.y + updated_row->height); 26070 to_y = min (max_y, w->output_cursor.y + updated_row->height);
26148 26071
26149 /* Notice if the cursor will be cleared by this operation. */ 26072 /* Notice if the cursor will be cleared by this operation. */
26150 if (!updated_row->full_width_p) 26073 if (!updated_row->full_width_p)
26151 notice_overwritten_cursor (w, updated_area, 26074 notice_overwritten_cursor (w, updated_area,
26152 output_cursor.x, -1, 26075 w->output_cursor.x, -1,
26153 updated_row->y, 26076 updated_row->y,
26154 MATRIX_ROW_BOTTOM_Y (updated_row)); 26077 MATRIX_ROW_BOTTOM_Y (updated_row));
26155 26078
26156 from_x = output_cursor.x; 26079 from_x = w->output_cursor.x;
26157 26080
26158 /* Translate to frame coordinates. */ 26081 /* Translate to frame coordinates. */
26159 if (updated_row->full_width_p) 26082 if (updated_row->full_width_p)
@@ -26169,7 +26092,7 @@ x_clear_end_of_line (struct window *w, struct glyph_row *updated_row,
26169 } 26092 }
26170 26093
26171 min_y = WINDOW_HEADER_LINE_HEIGHT (w); 26094 min_y = WINDOW_HEADER_LINE_HEIGHT (w);
26172 from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y)); 26095 from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, w->output_cursor.y));
26173 to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y); 26096 to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y);
26174 26097
26175 /* Prevent inadvertently clearing to end of the X window. */ 26098 /* Prevent inadvertently clearing to end of the X window. */
@@ -26267,7 +26190,7 @@ set_frame_cursor_types (struct frame *f, Lisp_Object arg)
26267 FRAME_BLINK_OFF_CURSOR (f) = DEFAULT_CURSOR; 26190 FRAME_BLINK_OFF_CURSOR (f) = DEFAULT_CURSOR;
26268 26191
26269 /* Make sure the cursor gets redrawn. */ 26192 /* Make sure the cursor gets redrawn. */
26270 cursor_type_changed = 1; 26193 f->cursor_type_changed = 1;
26271} 26194}
26272 26195
26273 26196
@@ -29037,7 +28960,7 @@ x_draw_vertical_border (struct window *w)
29037 { 28960 {
29038 int x0, x1, y0, y1; 28961 int x0, x1, y0, y1;
29039 28962
29040 window_box_edges (w, -1, &x0, &y0, &x1, &y1); 28963 window_box_edges (w, &x0, &y0, &x1, &y1);
29041 y1 -= 1; 28964 y1 -= 1;
29042 28965
29043 if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0) 28966 if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
@@ -29050,7 +28973,7 @@ x_draw_vertical_border (struct window *w)
29050 { 28973 {
29051 int x0, x1, y0, y1; 28974 int x0, x1, y0, y1;
29052 28975
29053 window_box_edges (w, -1, &x0, &y0, &x1, &y1); 28976 window_box_edges (w, &x0, &y0, &x1, &y1);
29054 y1 -= 1; 28977 y1 -= 1;
29055 28978
29056 if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0) 28979 if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
@@ -29959,8 +29882,10 @@ cursor shapes. */);
29959 doc: /* Seconds to wait before displaying an hourglass pointer when Emacs is busy. */); 29882 doc: /* Seconds to wait before displaying an hourglass pointer when Emacs is busy. */);
29960 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); 29883 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
29961 29884
29885#ifdef HAVE_WINDOW_SYSTEM
29962 hourglass_atimer = NULL; 29886 hourglass_atimer = NULL;
29963 hourglass_shown_p = 0; 29887 hourglass_shown_p = 0;
29888#endif /* HAVE_WINDOW_SYSTEM */
29964 29889
29965 DEFSYM (Qglyphless_char, "glyphless-char"); 29890 DEFSYM (Qglyphless_char, "glyphless-char");
29966 DEFSYM (Qhex_code, "hex-code"); 29891 DEFSYM (Qhex_code, "hex-code");
@@ -30002,8 +29927,6 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
30002void 29927void
30003init_xdisp (void) 29928init_xdisp (void)
30004{ 29929{
30005 current_header_line_height = current_mode_line_height = -1;
30006
30007 CHARPOS (this_line_start_pos) = 0; 29930 CHARPOS (this_line_start_pos) = 0;
30008 29931
30009 if (!noninteractive) 29932 if (!noninteractive)
@@ -30047,13 +29970,14 @@ init_xdisp (void)
30047 help_echo_showing_p = 0; 29970 help_echo_showing_p = 0;
30048} 29971}
30049 29972
29973#ifdef HAVE_WINDOW_SYSTEM
29974
30050/* Platform-independent portion of hourglass implementation. */ 29975/* Platform-independent portion of hourglass implementation. */
30051 29976
30052/* Cancel a currently active hourglass timer, and start a new one. */ 29977/* Cancel a currently active hourglass timer, and start a new one. */
30053void 29978void
30054start_hourglass (void) 29979start_hourglass (void)
30055{ 29980{
30056#if defined (HAVE_WINDOW_SYSTEM)
30057 struct timespec delay; 29981 struct timespec delay;
30058 29982
30059 cancel_hourglass (); 29983 cancel_hourglass ();
@@ -30078,7 +30002,6 @@ start_hourglass (void)
30078 30002
30079 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 30003 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
30080 show_hourglass, NULL); 30004 show_hourglass, NULL);
30081#endif
30082} 30005}
30083 30006
30084 30007
@@ -30087,7 +30010,6 @@ start_hourglass (void)
30087void 30010void
30088cancel_hourglass (void) 30011cancel_hourglass (void)
30089{ 30012{
30090#if defined (HAVE_WINDOW_SYSTEM)
30091 if (hourglass_atimer) 30013 if (hourglass_atimer)
30092 { 30014 {
30093 cancel_atimer (hourglass_atimer); 30015 cancel_atimer (hourglass_atimer);
@@ -30096,5 +30018,6 @@ cancel_hourglass (void)
30096 30018
30097 if (hourglass_shown_p) 30019 if (hourglass_shown_p)
30098 hide_hourglass (); 30020 hide_hourglass ();
30099#endif
30100} 30021}
30022
30023#endif /* HAVE_WINDOW_SYSTEM */
diff --git a/src/xfaces.c b/src/xfaces.c
index a55ac90086d..e8cb7a70322 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -211,13 +211,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
211#include "frame.h" 211#include "frame.h"
212#include "termhooks.h" 212#include "termhooks.h"
213 213
214#ifdef HAVE_X_WINDOWS
215#include "xterm.h"
216#ifdef USE_MOTIF 214#ifdef USE_MOTIF
217#include <Xm/Xm.h> 215#include <Xm/Xm.h>
218#include <Xm/XmStrDefs.h> 216#include <Xm/XmStrDefs.h>
219#endif /* USE_MOTIF */ 217#endif /* USE_MOTIF */
220#endif /* HAVE_X_WINDOWS */
221 218
222#ifdef MSDOS 219#ifdef MSDOS
223#include "dosfns.h" 220#include "dosfns.h"
@@ -238,6 +235,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
238#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO 235#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
239#define GCGraphicsExposures 0 236#define GCGraphicsExposures 0
240#endif /* HAVE_NS */ 237#endif /* HAVE_NS */
238
239/* Number of pt per inch (from the TeXbook). */
240
241#define PT_PER_INCH 72.27
242
241#endif /* HAVE_WINDOW_SYSTEM */ 243#endif /* HAVE_WINDOW_SYSTEM */
242 244
243#include "buffer.h" 245#include "buffer.h"
@@ -272,10 +274,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
272 274
273#include <c-ctype.h> 275#include <c-ctype.h>
274 276
275/* Number of pt per inch (from the TeXbook). */
276
277#define PT_PER_INCH 72.27
278
279/* Non-zero if face attribute ATTR is unspecified. */ 277/* Non-zero if face attribute ATTR is unspecified. */
280 278
281#define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified) 279#define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified)
@@ -396,6 +394,8 @@ static Lisp_Object Qtty_color_desc, Qtty_color_by_index, Qtty_color_standard_val
396 394
397static Lisp_Object Qtty_color_alist; 395static Lisp_Object Qtty_color_alist;
398 396
397#ifdef HAVE_WINDOW_SYSTEM
398
399/* Counter for calls to clear_face_cache. If this counter reaches 399/* Counter for calls to clear_face_cache. If this counter reaches
400 CLEAR_FONT_TABLE_COUNT, and a frame has more than 400 CLEAR_FONT_TABLE_COUNT, and a frame has more than
401 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ 401 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */
@@ -404,6 +404,8 @@ static int clear_font_table_count;
404#define CLEAR_FONT_TABLE_COUNT 100 404#define CLEAR_FONT_TABLE_COUNT 100
405#define CLEAR_FONT_TABLE_NFONTS 10 405#define CLEAR_FONT_TABLE_NFONTS 10
406 406
407#endif /* HAVE_WINDOW_SYSTEM */
408
407/* Non-zero means face attributes have been changed since the last 409/* Non-zero means face attributes have been changed since the last
408 redisplay. Used in redisplay_internal. */ 410 redisplay. Used in redisplay_internal. */
409 411
@@ -434,29 +436,27 @@ static int ngcs;
434 436
435static int menu_face_changed_default; 437static int menu_face_changed_default;
436 438
437
438/* Function prototypes. */
439
440struct table_entry;
441struct named_merge_point; 439struct named_merge_point;
442 440
443static void set_font_frame_param (Lisp_Object, Lisp_Object);
444static struct face *realize_face (struct face_cache *, Lisp_Object *, 441static struct face *realize_face (struct face_cache *, Lisp_Object *,
445 int); 442 int);
446static struct face *realize_non_ascii_face (struct frame *, Lisp_Object,
447 struct face *);
448static struct face *realize_x_face (struct face_cache *, Lisp_Object *); 443static struct face *realize_x_face (struct face_cache *, Lisp_Object *);
449static struct face *realize_tty_face (struct face_cache *, Lisp_Object *); 444static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
450static bool realize_basic_faces (struct frame *); 445static bool realize_basic_faces (struct frame *);
451static bool realize_default_face (struct frame *); 446static bool realize_default_face (struct frame *);
452static void realize_named_face (struct frame *, Lisp_Object, int); 447static void realize_named_face (struct frame *, Lisp_Object, int);
453static struct face_cache *make_face_cache (struct frame *); 448static struct face_cache *make_face_cache (struct frame *);
454static void clear_face_gcs (struct face_cache *);
455static void free_face_cache (struct face_cache *); 449static void free_face_cache (struct face_cache *);
456static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *, 450static int merge_face_ref (struct frame *, Lisp_Object, Lisp_Object *,
457 int, struct named_merge_point *); 451 int, struct named_merge_point *);
458 452
459 453#ifdef HAVE_WINDOW_SYSTEM
454static void set_font_frame_param (Lisp_Object, Lisp_Object);
455static void clear_face_gcs (struct face_cache *);
456static struct face *realize_non_ascii_face (struct frame *, Lisp_Object,
457 struct face *);
458#endif /* HAVE_WINDOW_SYSTEM */
459
460/*********************************************************************** 460/***********************************************************************
461 Utilities 461 Utilities
462 ***********************************************************************/ 462 ***********************************************************************/
@@ -3983,6 +3983,7 @@ lface_hash (Lisp_Object *v)
3983 ^ XHASH (v[LFACE_HEIGHT_INDEX])); 3983 ^ XHASH (v[LFACE_HEIGHT_INDEX]));
3984} 3984}
3985 3985
3986#ifdef HAVE_WINDOW_SYSTEM
3986 3987
3987/* Return non-zero if LFACE1 and LFACE2 specify the same font (without 3988/* Return non-zero if LFACE1 and LFACE2 specify the same font (without
3988 considering charsets/registries). They do if they specify the same 3989 considering charsets/registries). They do if they specify the same
@@ -4011,8 +4012,8 @@ lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
4011 ); 4012 );
4012} 4013}
4013 4014
4015#endif /* HAVE_WINDOW_SYSTEM */
4014 4016
4015
4016/*********************************************************************** 4017/***********************************************************************
4017 Realized Faces 4018 Realized Faces
4018 ***********************************************************************/ 4019 ***********************************************************************/
@@ -4171,6 +4172,7 @@ make_face_cache (struct frame *f)
4171 return c; 4172 return c;
4172} 4173}
4173 4174
4175#ifdef HAVE_WINDOW_SYSTEM
4174 4176
4175/* Clear out all graphics contexts for all realized faces, except for 4177/* Clear out all graphics contexts for all realized faces, except for
4176 the basic faces. This should be done from time to time just to avoid 4178 the basic faces. This should be done from time to time just to avoid
@@ -4181,7 +4183,6 @@ clear_face_gcs (struct face_cache *c)
4181{ 4183{
4182 if (c && FRAME_WINDOW_P (c->f)) 4184 if (c && FRAME_WINDOW_P (c->f))
4183 { 4185 {
4184#ifdef HAVE_WINDOW_SYSTEM
4185 int i; 4186 int i;
4186 for (i = BASIC_FACE_ID_SENTINEL; i < c->used; ++i) 4187 for (i = BASIC_FACE_ID_SENTINEL; i < c->used; ++i)
4187 { 4188 {
@@ -4196,10 +4197,10 @@ clear_face_gcs (struct face_cache *c)
4196 unblock_input (); 4197 unblock_input ();
4197 } 4198 }
4198 } 4199 }
4199#endif /* HAVE_WINDOW_SYSTEM */
4200 } 4200 }
4201} 4201}
4202 4202
4203#endif /* HAVE_WINDOW_SYSTEM */
4203 4204
4204/* Free all realized faces in face cache C, including basic faces. 4205/* Free all realized faces in face cache C, including basic faces.
4205 C may be null. If faces are freed, make sure the frame's current 4206 C may be null. If faces are freed, make sure the frame's current
diff --git a/src/xfns.c b/src/xfns.c
index 0c91e298ec8..4e8442dd3a3 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -22,10 +22,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22#include <math.h> 22#include <math.h>
23#include <unistd.h> 23#include <unistd.h>
24 24
25/* This makes the fields of a Display accessible, in Xlib header files. */
26
27#define XLIB_ILLEGAL_ACCESS
28
29#include "lisp.h" 25#include "lisp.h"
30#include "xterm.h" 26#include "xterm.h"
31#include "frame.h" 27#include "frame.h"
@@ -1186,7 +1182,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1186 1182
1187 block_input (); 1183 block_input ();
1188 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1184 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1189 0, y, width, height, False); 1185 0, y, width, height);
1190 unblock_input (); 1186 unblock_input ();
1191 } 1187 }
1192 1188
@@ -1197,7 +1193,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1197 1193
1198 block_input (); 1194 block_input ();
1199 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1195 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1200 0, y, width, height, False); 1196 0, y, width, height);
1201 unblock_input (); 1197 unblock_input ();
1202 } 1198 }
1203 1199
@@ -1205,7 +1201,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1205 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix); 1201 clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
1206 } 1202 }
1207#endif /* not USE_X_TOOLKIT && not USE_GTK */ 1203#endif /* not USE_X_TOOLKIT && not USE_GTK */
1208 adjust_glyphs (f); 1204 adjust_frame_glyphs (f);
1209 run_window_configuration_change_hook (f); 1205 run_window_configuration_change_hook (f);
1210} 1206}
1211 1207
@@ -1268,7 +1264,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1268 1264
1269 FRAME_TOOL_BAR_LINES (f) = nlines; 1265 FRAME_TOOL_BAR_LINES (f) = nlines;
1270 resize_frame_windows (f, FRAME_LINES (f), 0); 1266 resize_frame_windows (f, FRAME_LINES (f), 0);
1271 adjust_glyphs (f); 1267 adjust_frame_glyphs (f);
1272 1268
1273 /* We also have to make sure that the internal border at the top of 1269 /* We also have to make sure that the internal border at the top of
1274 the frame, below the menu bar or tool bar, is redrawn when the 1270 the frame, below the menu bar or tool bar, is redrawn when the
@@ -1295,8 +1291,8 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1295 if (height > 0 && width > 0) 1291 if (height > 0 && width > 0)
1296 { 1292 {
1297 block_input (); 1293 block_input ();
1298 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 1294 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1299 0, y, width, height, False); 1295 0, y, width, height);
1300 unblock_input (); 1296 unblock_input ();
1301 } 1297 }
1302 1298
@@ -5490,7 +5486,7 @@ Text larger than the specified size is clipped. */)
5490 } 5486 }
5491 5487
5492 FRAME_TOTAL_COLS (f) = w->total_cols; 5488 FRAME_TOTAL_COLS (f) = w->total_cols;
5493 adjust_glyphs (f); 5489 adjust_frame_glyphs (f);
5494 w->pseudo_window_p = 1; 5490 w->pseudo_window_p = 1;
5495 5491
5496 /* Display the tooltip text in a temporary buffer. */ 5492 /* Display the tooltip text in a temporary buffer. */
@@ -5558,7 +5554,7 @@ Text larger than the specified size is clipped. */)
5558 width /= WINDOW_FRAME_COLUMN_WIDTH (w); 5554 width /= WINDOW_FRAME_COLUMN_WIDTH (w);
5559 w->total_cols = width; 5555 w->total_cols = width;
5560 FRAME_TOTAL_COLS (f) = width; 5556 FRAME_TOTAL_COLS (f) = width;
5561 adjust_glyphs (f); 5557 adjust_frame_glyphs (f);
5562 clear_glyph_matrix (w->desired_matrix); 5558 clear_glyph_matrix (w->desired_matrix);
5563 clear_glyph_matrix (w->current_matrix); 5559 clear_glyph_matrix (w->current_matrix);
5564 try_window (FRAME_ROOT_WINDOW (f), pos, 0); 5560 try_window (FRAME_ROOT_WINDOW (f), pos, 0);
diff --git a/src/xgselect.c b/src/xgselect.c
index 45a34f2e0a5..7a754bd75c0 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -29,10 +29,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
29#include "frame.h" 29#include "frame.h"
30 30
31int 31int
32xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 32xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
33 struct timespec const *timeout, sigset_t const *sigmask) 33 struct timespec const *timeout, sigset_t const *sigmask)
34{ 34{
35 SELECT_TYPE all_rfds, all_wfds; 35 fd_set all_rfds, all_wfds;
36 struct timespec tmo; 36 struct timespec tmo;
37 struct timespec const *tmop = timeout; 37 struct timespec const *tmop = timeout;
38 38
diff --git a/src/xgselect.h b/src/xgselect.h
index f85c17f7190..1f8555591d0 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -25,9 +25,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25#include "sysselect.h" 25#include "sysselect.h"
26 26
27extern int xg_select (int max_fds, 27extern int xg_select (int max_fds,
28 SELECT_TYPE *rfds, 28 fd_set *rfds, fd_set *wfds, fd_set *efds,
29 SELECT_TYPE *wfds,
30 SELECT_TYPE *efds,
31 struct timespec const *timeout, 29 struct timespec const *timeout,
32 sigset_t const *sigmask); 30 sigset_t const *sigmask);
33 31
diff --git a/src/xmenu.c b/src/xmenu.c
index 98473939373..823c63bfc6f 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -378,7 +378,7 @@ x_menu_wait_for_event (void *data)
378 ) 378 )
379 { 379 {
380 struct timespec next_time = timer_check (), *ntp; 380 struct timespec next_time = timer_check (), *ntp;
381 SELECT_TYPE read_fds; 381 fd_set read_fds;
382 struct x_display_info *dpyinfo; 382 struct x_display_info *dpyinfo;
383 int n = 0; 383 int n = 0;
384 384
diff --git a/src/xterm.c b/src/xterm.c
index 548975c635a..3e05ba6fed2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -143,16 +143,11 @@ int use_xim = 1;
143int use_xim = 0; /* configure --without-xim */ 143int use_xim = 0; /* configure --without-xim */
144#endif 144#endif
145 145
146
147
148/* Non-zero means that a HELP_EVENT has been generated since Emacs 146/* Non-zero means that a HELP_EVENT has been generated since Emacs
149 start. */ 147 start. */
150 148
151static bool any_help_event_p; 149static bool any_help_event_p;
152 150
153/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
154static Lisp_Object last_window;
155
156/* This is a chain of structures for all the X displays currently in 151/* This is a chain of structures for all the X displays currently in
157 use. */ 152 use. */
158 153
@@ -300,8 +295,6 @@ static struct terminal *x_create_terminal (struct x_display_info *);
300void x_delete_terminal (struct terminal *); 295void x_delete_terminal (struct terminal *);
301static void x_update_end (struct frame *); 296static void x_update_end (struct frame *);
302static void XTframe_up_to_date (struct frame *); 297static void XTframe_up_to_date (struct frame *);
303static void XTset_terminal_modes (struct terminal *);
304static void XTreset_terminal_modes (struct terminal *);
305static void x_clear_frame (struct frame *); 298static void x_clear_frame (struct frame *);
306static _Noreturn void x_ins_del_lines (struct frame *, int, int); 299static _Noreturn void x_ins_del_lines (struct frame *, int, int);
307static void frame_highlight (struct frame *); 300static void frame_highlight (struct frame *);
@@ -317,7 +310,8 @@ static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
317static void x_draw_bar_cursor (struct window *, struct glyph_row *, int, 310static void x_draw_bar_cursor (struct window *, struct glyph_row *, int,
318 enum text_cursor_kinds); 311 enum text_cursor_kinds);
319 312
320static void x_clip_to_row (struct window *, struct glyph_row *, int, GC); 313static void x_clip_to_row (struct window *, struct glyph_row *,
314 enum glyph_row_area, GC);
321static void x_flush (struct frame *f); 315static void x_flush (struct frame *f);
322static void x_update_begin (struct frame *); 316static void x_update_begin (struct frame *);
323static void x_update_window_begin (struct window *); 317static void x_update_window_begin (struct window *);
@@ -343,29 +337,19 @@ static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
343static void x_initialize (void); 337static void x_initialize (void);
344 338
345 339
346/* Flush display of frame F, or of all frames if F is null. */ 340/* Flush display of frame F. */
347 341
348static void 342static void
349x_flush (struct frame *f) 343x_flush (struct frame *f)
350{ 344{
345 eassert (f && FRAME_X_P (f));
351 /* Don't call XFlush when it is not safe to redisplay; the X 346 /* Don't call XFlush when it is not safe to redisplay; the X
352 connection may be broken. */ 347 connection may be broken. */
353 if (!NILP (Vinhibit_redisplay)) 348 if (!NILP (Vinhibit_redisplay))
354 return; 349 return;
355 350
356 block_input (); 351 block_input ();
357 if (f) 352 XFlush (FRAME_X_DISPLAY (f));
358 {
359 eassert (FRAME_X_P (f));
360 XFlush (FRAME_X_DISPLAY (f));
361 }
362 else
363 {
364 /* Flush all displays and so all frames on them. */
365 struct x_display_info *xdi;
366 for (xdi = x_display_list; xdi; xdi = xdi->next)
367 XFlush (xdi->display);
368 }
369 unblock_input (); 353 unblock_input ();
370} 354}
371 355
@@ -554,8 +538,7 @@ x_update_begin (struct frame *f)
554} 538}
555 539
556 540
557/* Start update of window W. Set output_cursor to the cursor 541/* Start update of window W. */
558 position of W. */
559 542
560static void 543static void
561x_update_window_begin (struct window *w) 544x_update_window_begin (struct window *w)
@@ -563,7 +546,7 @@ x_update_window_begin (struct window *w)
563 struct frame *f = XFRAME (WINDOW_FRAME (w)); 546 struct frame *f = XFRAME (WINDOW_FRAME (w));
564 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 547 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
565 548
566 set_output_cursor (&w->cursor); 549 w->output_cursor = w->cursor;
567 550
568 block_input (); 551 block_input ();
569 552
@@ -621,9 +604,9 @@ x_update_window_end (struct window *w, bool cursor_on_p,
621 block_input (); 604 block_input ();
622 605
623 if (cursor_on_p) 606 if (cursor_on_p)
624 display_and_set_cursor (w, 1, output_cursor.hpos, 607 display_and_set_cursor (w, 1,
625 output_cursor.vpos, 608 w->output_cursor.hpos, w->output_cursor.vpos,
626 output_cursor.x, output_cursor.y); 609 w->output_cursor.x, w->output_cursor.y);
627 610
628 if (draw_window_fringes (w, 1)) 611 if (draw_window_fringes (w, 1))
629 x_draw_vertical_border (w); 612 x_draw_vertical_border (w);
@@ -701,10 +684,10 @@ x_after_update_window_line (struct window *w, struct glyph_row *desired_row)
701 684
702 block_input (); 685 block_input ();
703 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 686 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
704 0, y, width, height, False); 687 0, y, width, height);
705 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 688 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
706 FRAME_PIXEL_WIDTH (f) - width, 689 FRAME_PIXEL_WIDTH (f) - width,
707 y, width, height, False); 690 y, width, height);
708 unblock_input (); 691 unblock_input ();
709 } 692 }
710} 693}
@@ -719,7 +702,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
719 struct face *face = p->face; 702 struct face *face = p->face;
720 703
721 /* Must clip because of partially visible lines. */ 704 /* Must clip because of partially visible lines. */
722 x_clip_to_row (w, row, -1, gc); 705 x_clip_to_row (w, row, ANY_AREA, gc);
723 706
724 if (!p->overlay_p) 707 if (!p->overlay_p)
725 { 708 {
@@ -836,27 +819,6 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring
836 XSetClipMask (display, gc, None); 819 XSetClipMask (display, gc, None);
837} 820}
838 821
839
840
841/* This is called when starting Emacs and when restarting after
842 suspend. When starting Emacs, no X window is mapped. And nothing
843 must be done to Emacs's own window if it is suspended (though that
844 rarely happens). */
845
846static void
847XTset_terminal_modes (struct terminal *terminal)
848{
849}
850
851/* This is called when exiting or suspending Emacs. Exiting will make
852 the X-windows go away, and suspending requires no action. */
853
854static void
855XTreset_terminal_modes (struct terminal *terminal)
856{
857}
858
859
860/*********************************************************************** 822/***********************************************************************
861 Glyph display 823 Glyph display
862 ***********************************************************************/ 824 ***********************************************************************/
@@ -2977,10 +2939,10 @@ x_delete_glyphs (struct frame *f, register int n)
2977 If they are <= 0, this is probably an error. */ 2939 If they are <= 0, this is probably an error. */
2978 2940
2979void 2941void
2980x_clear_area (Display *dpy, Window window, int x, int y, int width, int height, int exposures) 2942x_clear_area (Display *dpy, Window window, int x, int y, int width, int height)
2981{ 2943{
2982 eassert (width > 0 && height > 0); 2944 eassert (width > 0 && height > 0);
2983 XClearArea (dpy, window, x, y, width, height, exposures); 2945 XClearArea (dpy, window, x, y, width, height, False);
2984} 2946}
2985 2947
2986 2948
@@ -2992,11 +2954,7 @@ x_clear_frame (struct frame *f)
2992 /* Clearing the frame will erase any cursor, so mark them all as no 2954 /* Clearing the frame will erase any cursor, so mark them all as no
2993 longer visible. */ 2955 longer visible. */
2994 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); 2956 mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
2995 output_cursor.hpos = output_cursor.vpos = 0;
2996 output_cursor.x = -1;
2997 2957
2998 /* We don't set the output cursor here because there will always
2999 follow an explicit cursor_to. */
3000 block_input (); 2958 block_input ();
3001 2959
3002 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 2960 XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
@@ -3222,20 +3180,6 @@ XTring_bell (struct frame *f)
3222 } 3180 }
3223} 3181}
3224 3182
3225
3226/* Specify how many text lines, from the top of the window,
3227 should be affected by insert-lines and delete-lines operations.
3228 This, and those operations, are used only within an update
3229 that is bounded by calls to x_update_begin and x_update_end. */
3230
3231static void
3232XTset_terminal_window (struct frame *f, int n)
3233{
3234 /* This function intentionally left blank. */
3235}
3236
3237
3238
3239/*********************************************************************** 3183/***********************************************************************
3240 Line Dance 3184 Line Dance
3241 ***********************************************************************/ 3185 ***********************************************************************/
@@ -3261,7 +3205,7 @@ x_scroll_run (struct window *w, struct run *run)
3261 /* Get frame-relative bounding box of the text display area of W, 3205 /* Get frame-relative bounding box of the text display area of W,
3262 without mode lines. Include in this box the left and right 3206 without mode lines. Include in this box the left and right
3263 fringe of W. */ 3207 fringe of W. */
3264 window_box (w, -1, &x, &y, &width, &height); 3208 window_box (w, ANY_AREA, &x, &y, &width, &height);
3265 3209
3266#ifdef USE_TOOLKIT_SCROLL_BARS 3210#ifdef USE_TOOLKIT_SCROLL_BARS
3267 /* If the fringe is adjacent to the left (right) scroll bar of a 3211 /* If the fringe is adjacent to the left (right) scroll bar of a
@@ -3777,7 +3721,6 @@ construct_mouse_click (struct input_event *result, XButtonEvent *event, struct f
3777 return Qnil; 3721 return Qnil;
3778} 3722}
3779 3723
3780
3781/* Function to report a mouse movement to the mainstream Emacs code. 3724/* Function to report a mouse movement to the mainstream Emacs code.
3782 The input handler calls this. 3725 The input handler calls this.
3783 3726
@@ -4197,9 +4140,9 @@ xt_action_hook (Widget widget, XtPointer client_data, String action_name,
4197 scroll_bar_end_scroll, 0, 0); 4140 scroll_bar_end_scroll, 0, 0);
4198 w = XWINDOW (window_being_scrolled); 4141 w = XWINDOW (window_being_scrolled);
4199 4142
4200 if (!NILP (XSCROLL_BAR (w->vertical_scroll_bar)->dragging)) 4143 if (XSCROLL_BAR (w->vertical_scroll_bar)->dragging != -1)
4201 { 4144 {
4202 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = Qnil; 4145 XSCROLL_BAR (w->vertical_scroll_bar)->dragging = -1;
4203 /* The thumb size is incorrect while dragging: fix it. */ 4146 /* The thumb size is incorrect while dragging: fix it. */
4204 set_vertical_scroll_bar (w); 4147 set_vertical_scroll_bar (w);
4205 } 4148 }
@@ -4337,32 +4280,32 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4337 switch (cs->reason) 4280 switch (cs->reason)
4338 { 4281 {
4339 case XmCR_DECREMENT: 4282 case XmCR_DECREMENT:
4340 bar->dragging = Qnil; 4283 bar->dragging = -1;
4341 part = scroll_bar_up_arrow; 4284 part = scroll_bar_up_arrow;
4342 break; 4285 break;
4343 4286
4344 case XmCR_INCREMENT: 4287 case XmCR_INCREMENT:
4345 bar->dragging = Qnil; 4288 bar->dragging = -1;
4346 part = scroll_bar_down_arrow; 4289 part = scroll_bar_down_arrow;
4347 break; 4290 break;
4348 4291
4349 case XmCR_PAGE_DECREMENT: 4292 case XmCR_PAGE_DECREMENT:
4350 bar->dragging = Qnil; 4293 bar->dragging = -1;
4351 part = scroll_bar_above_handle; 4294 part = scroll_bar_above_handle;
4352 break; 4295 break;
4353 4296
4354 case XmCR_PAGE_INCREMENT: 4297 case XmCR_PAGE_INCREMENT:
4355 bar->dragging = Qnil; 4298 bar->dragging = -1;
4356 part = scroll_bar_below_handle; 4299 part = scroll_bar_below_handle;
4357 break; 4300 break;
4358 4301
4359 case XmCR_TO_TOP: 4302 case XmCR_TO_TOP:
4360 bar->dragging = Qnil; 4303 bar->dragging = -1;
4361 part = scroll_bar_to_top; 4304 part = scroll_bar_to_top;
4362 break; 4305 break;
4363 4306
4364 case XmCR_TO_BOTTOM: 4307 case XmCR_TO_BOTTOM:
4365 bar->dragging = Qnil; 4308 bar->dragging = -1;
4366 part = scroll_bar_to_bottom; 4309 part = scroll_bar_to_bottom;
4367 break; 4310 break;
4368 4311
@@ -4378,7 +4321,7 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4378 whole = XM_SB_MAX - slider_size; 4321 whole = XM_SB_MAX - slider_size;
4379 portion = min (cs->value, whole); 4322 portion = min (cs->value, whole);
4380 part = scroll_bar_handle; 4323 part = scroll_bar_handle;
4381 bar->dragging = make_number (cs->value); 4324 bar->dragging = cs->value;
4382 } 4325 }
4383 break; 4326 break;
4384 4327
@@ -4426,24 +4369,24 @@ xg_scroll_callback (GtkRange *range,
4426 whole = gtk_adjustment_get_upper (adj) - 4369 whole = gtk_adjustment_get_upper (adj) -
4427 gtk_adjustment_get_page_size (adj); 4370 gtk_adjustment_get_page_size (adj);
4428 portion = min ((int)position, whole); 4371 portion = min ((int)position, whole);
4429 bar->dragging = make_number ((int)portion); 4372 bar->dragging = portion;
4430 } 4373 }
4431 break; 4374 break;
4432 case GTK_SCROLL_STEP_BACKWARD: 4375 case GTK_SCROLL_STEP_BACKWARD:
4433 part = scroll_bar_up_arrow; 4376 part = scroll_bar_up_arrow;
4434 bar->dragging = Qnil; 4377 bar->dragging = -1;
4435 break; 4378 break;
4436 case GTK_SCROLL_STEP_FORWARD: 4379 case GTK_SCROLL_STEP_FORWARD:
4437 part = scroll_bar_down_arrow; 4380 part = scroll_bar_down_arrow;
4438 bar->dragging = Qnil; 4381 bar->dragging = -1;
4439 break; 4382 break;
4440 case GTK_SCROLL_PAGE_BACKWARD: 4383 case GTK_SCROLL_PAGE_BACKWARD:
4441 part = scroll_bar_above_handle; 4384 part = scroll_bar_above_handle;
4442 bar->dragging = Qnil; 4385 bar->dragging = -1;
4443 break; 4386 break;
4444 case GTK_SCROLL_PAGE_FORWARD: 4387 case GTK_SCROLL_PAGE_FORWARD:
4445 part = scroll_bar_below_handle; 4388 part = scroll_bar_below_handle;
4446 bar->dragging = Qnil; 4389 bar->dragging = -1;
4447 break; 4390 break;
4448 } 4391 }
4449 4392
@@ -4457,7 +4400,7 @@ xg_scroll_callback (GtkRange *range,
4457 return FALSE; 4400 return FALSE;
4458} 4401}
4459 4402
4460/* Callback for button release. Sets dragging to Qnil when dragging is done. */ 4403/* Callback for button release. Sets dragging to -1 when dragging is done. */
4461 4404
4462static gboolean 4405static gboolean
4463xg_end_scroll_callback (GtkWidget *widget, 4406xg_end_scroll_callback (GtkWidget *widget,
@@ -4465,7 +4408,7 @@ xg_end_scroll_callback (GtkWidget *widget,
4465 gpointer user_data) 4408 gpointer user_data)
4466{ 4409{
4467 struct scroll_bar *bar = user_data; 4410 struct scroll_bar *bar = user_data;
4468 bar->dragging = Qnil; 4411 bar->dragging = -1;
4469 if (WINDOWP (window_being_scrolled)) 4412 if (WINDOWP (window_being_scrolled))
4470 { 4413 {
4471 x_send_scroll_bar_event (window_being_scrolled, 4414 x_send_scroll_bar_event (window_being_scrolled,
@@ -4513,7 +4456,7 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4513 part = scroll_bar_handle; 4456 part = scroll_bar_handle;
4514 4457
4515 window_being_scrolled = bar->window; 4458 window_being_scrolled = bar->window;
4516 bar->dragging = make_number (portion); 4459 bar->dragging = portion;
4517 last_scroll_bar_part = part; 4460 last_scroll_bar_part = part;
4518 x_send_scroll_bar_event (bar->window, part, portion, whole); 4461 x_send_scroll_bar_event (bar->window, part, portion, whole);
4519} 4462}
@@ -4552,7 +4495,7 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4552 part = scroll_bar_move_ratio; 4495 part = scroll_bar_move_ratio;
4553 4496
4554 window_being_scrolled = bar->window; 4497 window_being_scrolled = bar->window;
4555 bar->dragging = Qnil; 4498 bar->dragging = -1;
4556 last_scroll_bar_part = part; 4499 last_scroll_bar_part = part;
4557 x_send_scroll_bar_event (bar->window, part, position, height); 4500 x_send_scroll_bar_event (bar->window, part, position, height);
4558} 4501}
@@ -4828,7 +4771,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4828 shown = (float) portion / whole; 4771 shown = (float) portion / whole;
4829 } 4772 }
4830 4773
4831 if (NILP (bar->dragging)) 4774 if (bar->dragging == -1)
4832 { 4775 {
4833 int size, value; 4776 int size, value;
4834 4777
@@ -4863,7 +4806,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4863 NULL); 4806 NULL);
4864 4807
4865 /* Massage the top+shown values. */ 4808 /* Massage the top+shown values. */
4866 if (NILP (bar->dragging) || last_scroll_bar_part == scroll_bar_down_arrow) 4809 if (bar->dragging == -1 || last_scroll_bar_part == scroll_bar_down_arrow)
4867 top = max (0, min (1, top)); 4810 top = max (0, min (1, top));
4868 else 4811 else
4869 top = old_top; 4812 top = old_top;
@@ -4875,7 +4818,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
4875 for `NARROWPROTO'. See s/freebsd.h for an example. */ 4818 for `NARROWPROTO'. See s/freebsd.h for an example. */
4876 if (top != old_top || shown != old_shown) 4819 if (top != old_top || shown != old_shown)
4877 { 4820 {
4878 if (NILP (bar->dragging)) 4821 if (bar->dragging == -1)
4879 XawScrollbarSetThumb (widget, top, shown); 4822 XawScrollbarSetThumb (widget, top, shown);
4880 else 4823 else
4881 { 4824 {
@@ -4940,8 +4883,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4940 this case, no clear_frame is generated to reduce flickering. */ 4883 this case, no clear_frame is generated to reduce flickering. */
4941 if (width > 0 && height > 0) 4884 if (width > 0 && height > 0)
4942 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4885 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4943 left, top, width, 4886 left, top, width, window_box_height (w));
4944 window_box_height (w), False);
4945 4887
4946 window = XCreateWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4888 window = XCreateWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4947 /* Position and size of scroll bar. */ 4889 /* Position and size of scroll bar. */
@@ -4967,7 +4909,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
4967 bar->height = height; 4909 bar->height = height;
4968 bar->start = 0; 4910 bar->start = 0;
4969 bar->end = 0; 4911 bar->end = 0;
4970 bar->dragging = Qnil; 4912 bar->dragging = -1;
4971 bar->fringe_extended_p = 0; 4913 bar->fringe_extended_p = 0;
4972 4914
4973 /* Add bar to its frame's list of scroll bars. */ 4915 /* Add bar to its frame's list of scroll bars. */
@@ -5025,7 +4967,7 @@ x_scroll_bar_create (struct window *w, int top, int left, int width, int height)
5025static void 4967static void
5026x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild) 4968x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild)
5027{ 4969{
5028 int dragging = ! NILP (bar->dragging); 4970 bool dragging = bar->dragging != -1;
5029 Window w = bar->x_window; 4971 Window w = bar->x_window;
5030 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 4972 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
5031 GC gc = f->output_data.x->normal_gc; 4973 GC gc = f->output_data.x->normal_gc;
@@ -5077,11 +5019,9 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5077 zero-height areas; that means "clear to end of window." */ 5019 zero-height areas; that means "clear to end of window." */
5078 if (start > 0) 5020 if (start > 0)
5079 x_clear_area (FRAME_X_DISPLAY (f), w, 5021 x_clear_area (FRAME_X_DISPLAY (f), w,
5080 /* x, y, width, height, and exposures. */
5081 VERTICAL_SCROLL_BAR_LEFT_BORDER, 5022 VERTICAL_SCROLL_BAR_LEFT_BORDER,
5082 VERTICAL_SCROLL_BAR_TOP_BORDER, 5023 VERTICAL_SCROLL_BAR_TOP_BORDER,
5083 inside_width, start, 5024 inside_width, start);
5084 False);
5085 5025
5086 /* Change to proper foreground color if one is specified. */ 5026 /* Change to proper foreground color if one is specified. */
5087 if (f->output_data.x->scroll_bar_foreground_pixel != -1) 5027 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
@@ -5104,12 +5044,9 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild
5104 clear zero-height areas; that means "clear to end of window." */ 5044 clear zero-height areas; that means "clear to end of window." */
5105 if (end < inside_height) 5045 if (end < inside_height)
5106 x_clear_area (FRAME_X_DISPLAY (f), w, 5046 x_clear_area (FRAME_X_DISPLAY (f), w,
5107 /* x, y, width, height, and exposures. */
5108 VERTICAL_SCROLL_BAR_LEFT_BORDER, 5047 VERTICAL_SCROLL_BAR_LEFT_BORDER,
5109 VERTICAL_SCROLL_BAR_TOP_BORDER + end, 5048 VERTICAL_SCROLL_BAR_TOP_BORDER + end,
5110 inside_width, inside_height - end, 5049 inside_width, inside_height - end);
5111 False);
5112
5113 } 5050 }
5114 5051
5115 unblock_input (); 5052 unblock_input ();
@@ -5161,7 +5098,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5161#endif 5098#endif
5162 5099
5163 /* Get window dimensions. */ 5100 /* Get window dimensions. */
5164 window_box (w, -1, 0, &window_y, 0, &window_height); 5101 window_box (w, ANY_AREA, 0, &window_y, 0, &window_height);
5165 top = window_y; 5102 top = window_y;
5166 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f); 5103 width = WINDOW_CONFIG_SCROLL_BAR_COLS (w) * FRAME_COLUMN_WIDTH (f);
5167 height = window_height; 5104 height = window_height;
@@ -5202,11 +5139,11 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5202#ifdef USE_TOOLKIT_SCROLL_BARS 5139#ifdef USE_TOOLKIT_SCROLL_BARS
5203 if (fringe_extended_p) 5140 if (fringe_extended_p)
5204 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5141 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5205 sb_left, top, sb_width, height, False); 5142 sb_left, top, sb_width, height);
5206 else 5143 else
5207#endif 5144#endif
5208 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5145 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5209 left, top, width, height, False); 5146 left, top, width, height);
5210 unblock_input (); 5147 unblock_input ();
5211 } 5148 }
5212 5149
@@ -5241,10 +5178,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5241 { 5178 {
5242 if (fringe_extended_p) 5179 if (fringe_extended_p)
5243 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5180 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5244 sb_left, top, sb_width, height, False); 5181 sb_left, top, sb_width, height);
5245 else 5182 else
5246 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5183 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5247 left, top, width, height, False); 5184 left, top, width, height);
5248 } 5185 }
5249#ifdef USE_GTK 5186#ifdef USE_GTK
5250 xg_update_scrollbar_pos (f, 5187 xg_update_scrollbar_pos (f,
@@ -5268,12 +5205,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5268 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM) 5205 if (VERTICAL_SCROLL_BAR_WIDTH_TRIM)
5269 { 5206 {
5270 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5207 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5271 left, top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5208 left, top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, height);
5272 height, False);
5273 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5209 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5274 left + width - VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5210 left + width - VERTICAL_SCROLL_BAR_WIDTH_TRIM,
5275 top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, 5211 top, VERTICAL_SCROLL_BAR_WIDTH_TRIM, height);
5276 height, False);
5277 } 5212 }
5278 5213
5279 /* Clear areas not covered by the scroll bar because it's not as 5214 /* Clear areas not covered by the scroll bar because it's not as
@@ -5287,11 +5222,10 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5287 { 5222 {
5288 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w)) 5223 if (WINDOW_HAS_VERTICAL_SCROLL_BAR_ON_LEFT (w))
5289 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5224 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5290 left + area_width - rest, top, 5225 left + area_width - rest, top, rest, height);
5291 rest, height, False);
5292 else 5226 else
5293 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 5227 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5294 left, top, rest, height, False); 5228 left, top, rest, height);
5295 } 5229 }
5296 } 5230 }
5297 5231
@@ -5326,7 +5260,7 @@ XTset_vertical_scroll_bar (struct window *w, int portion, int whole, int positio
5326#else /* not USE_TOOLKIT_SCROLL_BARS */ 5260#else /* not USE_TOOLKIT_SCROLL_BARS */
5327 /* Set the scroll bar's current state, unless we're currently being 5261 /* Set the scroll bar's current state, unless we're currently being
5328 dragged. */ 5262 dragged. */
5329 if (NILP (bar->dragging)) 5263 if (bar->dragging == -1)
5330 { 5264 {
5331 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height); 5265 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, height);
5332 5266
@@ -5536,14 +5470,13 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e
5536 5470
5537#ifndef USE_TOOLKIT_SCROLL_BARS 5471#ifndef USE_TOOLKIT_SCROLL_BARS
5538 /* If the user has released the handle, set it to its final position. */ 5472 /* If the user has released the handle, set it to its final position. */
5539 if (event->type == ButtonRelease 5473 if (event->type == ButtonRelease && bar->dragging != -1)
5540 && ! NILP (bar->dragging))
5541 { 5474 {
5542 int new_start = y - XINT (bar->dragging); 5475 int new_start = y - bar->dragging;
5543 int new_end = new_start + bar->end - bar->start; 5476 int new_end = new_start + bar->end - bar->start;
5544 5477
5545 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 5478 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
5546 bar->dragging = Qnil; 5479 bar->dragging = -1;
5547 } 5480 }
5548#endif 5481#endif
5549 5482
@@ -5560,20 +5493,20 @@ x_scroll_bar_handle_click (struct scroll_bar *bar, XEvent *event, struct input_e
5560 mark bits. */ 5493 mark bits. */
5561 5494
5562static void 5495static void
5563x_scroll_bar_note_movement (struct scroll_bar *bar, XEvent *event) 5496x_scroll_bar_note_movement (struct scroll_bar *bar, XMotionEvent *event)
5564{ 5497{
5565 struct frame *f = XFRAME (XWINDOW (bar->window)->frame); 5498 struct frame *f = XFRAME (XWINDOW (bar->window)->frame);
5566 5499
5567 last_mouse_movement_time = event->xmotion.time; 5500 last_mouse_movement_time = event->time;
5568 5501
5569 f->mouse_moved = 1; 5502 f->mouse_moved = 1;
5570 XSETVECTOR (last_mouse_scroll_bar, bar); 5503 XSETVECTOR (last_mouse_scroll_bar, bar);
5571 5504
5572 /* If we're dragging the bar, display it. */ 5505 /* If we're dragging the bar, display it. */
5573 if (! NILP (bar->dragging)) 5506 if (bar->dragging != -1)
5574 { 5507 {
5575 /* Where should the handle be now? */ 5508 /* Where should the handle be now? */
5576 int new_start = event->xmotion.y - XINT (bar->dragging); 5509 int new_start = event->y - bar->dragging;
5577 5510
5578 if (new_start != bar->start) 5511 if (new_start != bar->start)
5579 { 5512 {
@@ -5625,8 +5558,8 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
5625 5558
5626 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; 5559 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
5627 5560
5628 if (! NILP (bar->dragging)) 5561 if (bar->dragging != -1)
5629 win_y -= XINT (bar->dragging); 5562 win_y -= bar->dragging;
5630 5563
5631 if (win_y < 0) 5564 if (win_y < 0)
5632 win_y = 0; 5565 win_y = 0;
@@ -5636,7 +5569,7 @@ x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
5636 *fp = f; 5569 *fp = f;
5637 *bar_window = bar->window; 5570 *bar_window = bar->window;
5638 5571
5639 if (! NILP (bar->dragging)) 5572 if (bar->dragging != -1)
5640 *part = scroll_bar_handle; 5573 *part = scroll_bar_handle;
5641 else if (win_y < bar->start) 5574 else if (win_y < bar->start)
5642 *part = scroll_bar_above_handle; 5575 *part = scroll_bar_above_handle;
@@ -5681,18 +5614,7 @@ x_scroll_bar_clear (struct frame *f)
5681#endif /* not USE_TOOLKIT_SCROLL_BARS */ 5614#endif /* not USE_TOOLKIT_SCROLL_BARS */
5682} 5615}
5683 5616
5684 5617#ifdef ENABLE_CHECKING
5685/* The main X event-reading loop - XTread_socket. */
5686
5687/* This holds the state XLookupString needs to implement dead keys
5688 and other tricks known as "compose processing". _X Window System_
5689 says that a portable program can't use this, but Stephen Gildea assures
5690 me that letting the compiler initialize it to zeros will work okay.
5691
5692 This must be defined outside of XTread_socket, for the same reasons
5693 given for enter_timestamp, above. */
5694
5695static XComposeStatus compose_status;
5696 5618
5697/* Record the last 100 characters stored 5619/* Record the last 100 characters stored
5698 to help debug the loss-of-chars-during-GC problem. */ 5620 to help debug the loss-of-chars-during-GC problem. */
@@ -5705,6 +5627,12 @@ static short temp_buffer[100];
5705 temp_index = 0; \ 5627 temp_index = 0; \
5706 temp_buffer[temp_index++] = (keysym) 5628 temp_buffer[temp_index++] = (keysym)
5707 5629
5630#else /* not ENABLE_CHECKING */
5631
5632#define STORE_KEYSYM_FOR_DEBUG(keysym) ((void)0)
5633
5634#endif /* ENABLE_CHECKING */
5635
5708/* Set this to nonzero to fake an "X I/O error" 5636/* Set this to nonzero to fake an "X I/O error"
5709 on a particular display. */ 5637 on a particular display. */
5710 5638
@@ -5842,6 +5770,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
5842 struct coding_system coding; 5770 struct coding_system coding;
5843 XEvent event = *eventptr; 5771 XEvent event = *eventptr;
5844 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; 5772 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5773 /* This holds the state XLookupString needs to implement dead keys
5774 and other tricks known as "compose processing". _X Window System_
5775 says that a portable program can't use this, but Stephen Gildea assures
5776 me that letting the compiler initialize it to zeros will work okay. */
5777 static XComposeStatus compose_status;
5778
5845 USE_SAFE_ALLOCA; 5779 USE_SAFE_ALLOCA;
5846 5780
5847 *finish = X_EVENT_NORMAL; 5781 *finish = X_EVENT_NORMAL;
@@ -6135,11 +6069,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6135 { 6069 {
6136#ifdef USE_GTK 6070#ifdef USE_GTK
6137 /* This seems to be needed for GTK 2.6. */ 6071 /* This seems to be needed for GTK 2.6. */
6138 x_clear_area (event.xexpose.display, 6072 x_clear_area (event.xexpose.display,
6139 event.xexpose.window, 6073 event.xexpose.window,
6140 event.xexpose.x, event.xexpose.y, 6074 event.xexpose.x, event.xexpose.y,
6141 event.xexpose.width, event.xexpose.height, 6075 event.xexpose.width, event.xexpose.height);
6142 FALSE);
6143#endif 6076#endif
6144 if (!FRAME_VISIBLE_P (f)) 6077 if (!FRAME_VISIBLE_P (f))
6145 { 6078 {
@@ -6211,7 +6144,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6211 6144
6212 case UnmapNotify: 6145 case UnmapNotify:
6213 /* Redo the mouse-highlight after the tooltip has gone. */ 6146 /* Redo the mouse-highlight after the tooltip has gone. */
6214 if (event.xmap.window == tip_window) 6147 if (event.xunmap.window == tip_window)
6215 { 6148 {
6216 tip_window = 0; 6149 tip_window = 0;
6217 redo_mouse_highlight (); 6150 redo_mouse_highlight ();
@@ -6715,18 +6648,16 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6715 /* Generate SELECT_WINDOW_EVENTs when needed. 6648 /* Generate SELECT_WINDOW_EVENTs when needed.
6716 Don't let popup menus influence things (bug#1261). */ 6649 Don't let popup menus influence things (bug#1261). */
6717 if (!NILP (Vmouse_autoselect_window) && !popup_activated ()) 6650 if (!NILP (Vmouse_autoselect_window) && !popup_activated ())
6718 { 6651 {
6719 Lisp_Object window; 6652 static Lisp_Object last_mouse_window;
6720 6653 Lisp_Object window = window_from_coordinates
6721 window = window_from_coordinates (f, 6654 (f, event.xmotion.x, event.xmotion.y, 0, 0);
6722 event.xmotion.x, event.xmotion.y, 6655
6723 0, 0); 6656 /* Window will be selected only when it is not selected now and
6724 6657 last mouse movement event was not in it. Minibuffer window
6725 /* Window will be selected only when it is not selected now and 6658 will be selected only when it is active. */
6726 last mouse movement event was not in it. Minibuffer window 6659 if (WINDOWP (window)
6727 will be selected only when it is active. */ 6660 && !EQ (window, last_mouse_window)
6728 if (WINDOWP (window)
6729 && !EQ (window, last_window)
6730 && !EQ (window, selected_window) 6661 && !EQ (window, selected_window)
6731 /* For click-to-focus window managers 6662 /* For click-to-focus window managers
6732 create event iff we don't leave the 6663 create event iff we don't leave the
@@ -6734,13 +6665,13 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6734 && (focus_follows_mouse 6665 && (focus_follows_mouse
6735 || (EQ (XWINDOW (window)->frame, 6666 || (EQ (XWINDOW (window)->frame,
6736 XWINDOW (selected_window)->frame)))) 6667 XWINDOW (selected_window)->frame))))
6737 { 6668 {
6738 inev.ie.kind = SELECT_WINDOW_EVENT; 6669 inev.ie.kind = SELECT_WINDOW_EVENT;
6739 inev.ie.frame_or_window = window; 6670 inev.ie.frame_or_window = window;
6740 } 6671 }
6741 6672 /* Remember the last window where we saw the mouse. */
6742 last_window=window; 6673 last_mouse_window = window;
6743 } 6674 }
6744 if (!note_mouse_movement (f, &event.xmotion)) 6675 if (!note_mouse_movement (f, &event.xmotion))
6745 help_echo_string = previous_help_echo_string; 6676 help_echo_string = previous_help_echo_string;
6746 } 6677 }
@@ -6752,7 +6683,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6752 event.xmotion.window); 6683 event.xmotion.window);
6753 6684
6754 if (bar) 6685 if (bar)
6755 x_scroll_bar_note_movement (bar, &event); 6686 x_scroll_bar_note_movement (bar, &event.xmotion);
6756#endif /* USE_TOOLKIT_SCROLL_BARS */ 6687#endif /* USE_TOOLKIT_SCROLL_BARS */
6757 6688
6758 /* If we move outside the frame, then we're 6689 /* If we move outside the frame, then we're
@@ -7184,7 +7115,8 @@ XTread_socket (struct terminal *terminal, struct input_event *hold_quit)
7184 mode lines must be clipped to the whole window. */ 7115 mode lines must be clipped to the whole window. */
7185 7116
7186static void 7117static void
7187x_clip_to_row (struct window *w, struct glyph_row *row, int area, GC gc) 7118x_clip_to_row (struct window *w, struct glyph_row *row,
7119 enum glyph_row_area area, GC gc)
7188{ 7120{
7189 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7121 struct frame *f = XFRAME (WINDOW_FRAME (w));
7190 XRectangle clip_rect; 7122 XRectangle clip_rect;
@@ -7366,8 +7298,7 @@ x_define_frame_cursor (struct frame *f, Cursor cursor)
7366static void 7298static void
7367x_clear_frame_area (struct frame *f, int x, int y, int width, int height) 7299x_clear_frame_area (struct frame *f, int x, int y, int width, int height)
7368{ 7300{
7369 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7301 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), x, y, width, height);
7370 x, y, width, height, False);
7371#ifdef USE_GTK 7302#ifdef USE_GTK
7372 /* Must queue a redraw, because scroll bars might have been cleared. */ 7303 /* Must queue a redraw, because scroll bars might have been cleared. */
7373 if (FRAME_GTK_WIDGET (f)) 7304 if (FRAME_GTK_WIDGET (f))
@@ -7434,9 +7365,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x,
7434#endif 7365#endif
7435 } 7366 }
7436 7367
7437#ifndef XFlush
7438 XFlush (FRAME_X_DISPLAY (f)); 7368 XFlush (FRAME_X_DISPLAY (f));
7439#endif
7440} 7369}
7441 7370
7442 7371
@@ -8189,9 +8118,6 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
8189 8118
8190 if (change_gravity > 0) 8119 if (change_gravity > 0)
8191 { 8120 {
8192 FRAME_X_OUTPUT (f)->left_before_move = f->left_pos;
8193 FRAME_X_OUTPUT (f)->top_before_move = f->top_pos;
8194
8195 f->top_pos = yoff; 8121 f->top_pos = yoff;
8196 f->left_pos = xoff; 8122 f->left_pos = xoff;
8197 f->size_hint_flags &= ~ (XNegative | YNegative); 8123 f->size_hint_flags &= ~ (XNegative | YNegative);
@@ -8690,7 +8616,7 @@ x_wait_for_event (struct frame *f, int eventtype)
8690{ 8616{
8691 int level = interrupt_input_blocked; 8617 int level = interrupt_input_blocked;
8692 8618
8693 SELECT_TYPE fds; 8619 fd_set fds;
8694 struct timespec tmo, tmo_at, time_now; 8620 struct timespec tmo, tmo_at, time_now;
8695 int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); 8621 int fd = ConnectionNumber (FRAME_X_DISPLAY (f));
8696 8622
@@ -10250,9 +10176,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10250 dpyinfo->x_dnd_atoms_size = 8; 10176 dpyinfo->x_dnd_atoms_size = 8;
10251 dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms 10177 dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms
10252 * dpyinfo->x_dnd_atoms_size); 10178 * dpyinfo->x_dnd_atoms_size);
10253
10254 connection = ConnectionNumber (dpyinfo->display);
10255 dpyinfo->connection = connection;
10256 dpyinfo->gray 10179 dpyinfo->gray
10257 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, 10180 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
10258 gray_bits, gray_width, gray_height, 10181 gray_bits, gray_width, gray_height,
@@ -10264,6 +10187,8 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10264 10187
10265 xsettings_initialize (dpyinfo); 10188 xsettings_initialize (dpyinfo);
10266 10189
10190 connection = ConnectionNumber (dpyinfo->display);
10191
10267 /* This is only needed for distinguishing keyboard and process input. */ 10192 /* This is only needed for distinguishing keyboard and process input. */
10268 if (connection != 0) 10193 if (connection != 0)
10269 add_keyboard_wait_descriptor (connection); 10194 add_keyboard_wait_descriptor (connection);
@@ -10364,8 +10289,6 @@ x_delete_display (struct x_display_info *dpyinfo)
10364 break; 10289 break;
10365 } 10290 }
10366 10291
10367 delete_keyboard_wait_descriptor (dpyinfo->connection);
10368
10369 /* Discard this display from x_display_name_list and x_display_list. 10292 /* Discard this display from x_display_name_list and x_display_list.
10370 We can't use Fdelq because that can quit. */ 10293 We can't use Fdelq because that can quit. */
10371 if (! NILP (x_display_name_list) 10294 if (! NILP (x_display_name_list)
@@ -10466,13 +10389,7 @@ static struct redisplay_interface x_redisplay_interface =
10466 x_after_update_window_line, 10389 x_after_update_window_line,
10467 x_update_window_begin, 10390 x_update_window_begin,
10468 x_update_window_end, 10391 x_update_window_end,
10469 x_cursor_to,
10470 x_flush,
10471#ifdef XFlush
10472 x_flush, 10392 x_flush,
10473#else
10474 0, /* flush_display_optional */
10475#endif
10476 x_clear_window_mouse_face, 10393 x_clear_window_mouse_face,
10477 x_get_glyph_overhangs, 10394 x_get_glyph_overhangs,
10478 x_fix_overlapping_area, 10395 x_fix_overlapping_area,
@@ -10494,6 +10411,7 @@ void
10494x_delete_terminal (struct terminal *terminal) 10411x_delete_terminal (struct terminal *terminal)
10495{ 10412{
10496 struct x_display_info *dpyinfo = terminal->display_info.x; 10413 struct x_display_info *dpyinfo = terminal->display_info.x;
10414 int connection = -1;
10497 10415
10498 /* Protect against recursive calls. delete_frame in 10416 /* Protect against recursive calls. delete_frame in
10499 delete_terminal calls us back when it deletes our last frame. */ 10417 delete_terminal calls us back when it deletes our last frame. */
@@ -10512,6 +10430,8 @@ x_delete_terminal (struct terminal *terminal)
10512 and dpyinfo->display was set to 0 to indicate that. */ 10430 and dpyinfo->display was set to 0 to indicate that. */
10513 if (dpyinfo->display) 10431 if (dpyinfo->display)
10514 { 10432 {
10433 connection = ConnectionNumber (dpyinfo->display);
10434
10515 x_destroy_all_bitmaps (dpyinfo); 10435 x_destroy_all_bitmaps (dpyinfo);
10516 XSetCloseDownMode (dpyinfo->display, DestroyAll); 10436 XSetCloseDownMode (dpyinfo->display, DestroyAll);
10517 10437
@@ -10552,6 +10472,10 @@ x_delete_terminal (struct terminal *terminal)
10552#endif /* ! USE_GTK */ 10472#endif /* ! USE_GTK */
10553 } 10473 }
10554 10474
10475 /* No more input on this descriptor. */
10476 if (connection != -1)
10477 delete_keyboard_wait_descriptor (connection);
10478
10555 /* Mark as dead. */ 10479 /* Mark as dead. */
10556 dpyinfo->display = NULL; 10480 dpyinfo->display = NULL;
10557 x_delete_display (dpyinfo); 10481 x_delete_display (dpyinfo);
@@ -10579,11 +10503,11 @@ x_create_terminal (struct x_display_info *dpyinfo)
10579 terminal->delete_glyphs_hook = x_delete_glyphs; 10503 terminal->delete_glyphs_hook = x_delete_glyphs;
10580 terminal->ring_bell_hook = XTring_bell; 10504 terminal->ring_bell_hook = XTring_bell;
10581 terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer; 10505 terminal->toggle_invisible_pointer_hook = XTtoggle_invisible_pointer;
10582 terminal->reset_terminal_modes_hook = XTreset_terminal_modes; 10506 terminal->reset_terminal_modes_hook = NULL;
10583 terminal->set_terminal_modes_hook = XTset_terminal_modes; 10507 terminal->set_terminal_modes_hook = NULL;
10584 terminal->update_begin_hook = x_update_begin; 10508 terminal->update_begin_hook = x_update_begin;
10585 terminal->update_end_hook = x_update_end; 10509 terminal->update_end_hook = x_update_end;
10586 terminal->set_terminal_window_hook = XTset_terminal_window; 10510 terminal->set_terminal_window_hook = NULL;
10587 terminal->read_socket_hook = XTread_socket; 10511 terminal->read_socket_hook = XTread_socket;
10588 terminal->frame_up_to_date_hook = XTframe_up_to_date; 10512 terminal->frame_up_to_date_hook = XTframe_up_to_date;
10589 terminal->mouse_position_hook = XTmouse_position; 10513 terminal->mouse_position_hook = XTmouse_position;
diff --git a/src/xterm.h b/src/xterm.h
index 723550c57c4..883a249629d 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -20,8 +20,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20#ifndef XTERM_H 20#ifndef XTERM_H
21#define XTERM_H 21#define XTERM_H
22 22
23#include "dispextern.h"
24
25#include <X11/Xlib.h> 23#include <X11/Xlib.h>
26#include <X11/cursorfont.h> 24#include <X11/cursorfont.h>
27 25
@@ -73,14 +71,13 @@ typedef GtkWidget *xt_or_gtk_widget;
73#define USE_GTK_TOOLTIP 71#define USE_GTK_TOOLTIP
74#endif 72#endif
75 73
76
77/* Bookkeeping to distinguish X versions. */
78
79
80#ifdef HAVE_X_I18N 74#ifdef HAVE_X_I18N
81#include <X11/Xlocale.h> 75#include <X11/Xlocale.h>
82#endif 76#endif
83 77
78#include "dispextern.h"
79#include "termhooks.h"
80
84#define BLACK_PIX_DEFAULT(f) BlackPixel (FRAME_X_DISPLAY (f), \ 81#define BLACK_PIX_DEFAULT(f) BlackPixel (FRAME_X_DISPLAY (f), \
85 XScreenNumberOfScreen (FRAME_X_SCREEN (f))) 82 XScreenNumberOfScreen (FRAME_X_SCREEN (f)))
86#define WHITE_PIX_DEFAULT(f) WhitePixel (FRAME_X_DISPLAY (f), \ 83#define WHITE_PIX_DEFAULT(f) WhitePixel (FRAME_X_DISPLAY (f), \
@@ -141,9 +138,6 @@ struct x_display_info
141 /* The generic display parameters corresponding to this X display. */ 138 /* The generic display parameters corresponding to this X display. */
142 struct terminal *terminal; 139 struct terminal *terminal;
143 140
144 /* Connection number (normally a file descriptor number). */
145 int connection;
146
147 /* This says how to access this display in Xlib. */ 141 /* This says how to access this display in Xlib. */
148 Display *display; 142 Display *display;
149 143
@@ -409,9 +403,6 @@ extern bool x_display_ok (const char *);
409 403
410extern void select_visual (struct x_display_info *); 404extern void select_visual (struct x_display_info *);
411 405
412
413struct font;
414
415/* Each X frame object points to its own struct x_output object 406/* Each X frame object points to its own struct x_output object
416 in the output_data.x field. The x_output structure contains 407 in the output_data.x field. The x_output structure contains
417 the information that is specific to X windows. */ 408 the information that is specific to X windows. */
@@ -632,11 +623,6 @@ struct x_output
632 int move_offset_top; 623 int move_offset_top;
633 int move_offset_left; 624 int move_offset_left;
634 625
635 /* The frame's left/top offsets before we call XMoveWindow. See
636 x_check_expected_move. */
637 int left_before_move;
638 int top_before_move;
639
640 /* Non-zero if _NET_WM_STATE_HIDDEN is set for this frame. */ 626 /* Non-zero if _NET_WM_STATE_HIDDEN is set for this frame. */
641 unsigned net_wm_state_hidden_seen : 1; 627 unsigned net_wm_state_hidden_seen : 1;
642}; 628};
@@ -812,8 +798,8 @@ struct scroll_bar
812 /* If the scroll bar handle is currently being dragged by the user, 798 /* If the scroll bar handle is currently being dragged by the user,
813 this is the number of pixels from the top of the handle to the 799 this is the number of pixels from the top of the handle to the
814 place where the user grabbed it. If the handle isn't currently 800 place where the user grabbed it. If the handle isn't currently
815 being dragged, this is Qnil. */ 801 being dragged, this is -1. */
816 Lisp_Object dragging; 802 int dragging;
817 803
818 /* 1 if the background of the fringe that is adjacent to a scroll 804 /* 1 if the background of the fringe that is adjacent to a scroll
819 bar is extended to the gap between the fringe and the bar. */ 805 bar is extended to the gap between the fringe and the bar. */
@@ -919,14 +905,6 @@ struct selection_input_event
919#define SELECTION_EVENT_TIME(eventp) \ 905#define SELECTION_EVENT_TIME(eventp) \
920 (((struct selection_input_event *) (eventp))->time) 906 (((struct selection_input_event *) (eventp))->time)
921 907
922
923struct window;
924struct glyph_matrix;
925struct frame;
926struct input_event;
927struct face;
928struct image;
929
930/* From xselect.c. */ 908/* From xselect.c. */
931 909
932void x_handle_selection_notify (XSelectionEvent *); 910void x_handle_selection_notify (XSelectionEvent *);
@@ -968,7 +946,7 @@ extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
968#endif 946#endif
969extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *); 947extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
970extern void x_query_color (struct frame *f, XColor *); 948extern void x_query_color (struct frame *f, XColor *);
971extern void x_clear_area (Display *, Window, int, int, int, int, int); 949extern void x_clear_area (Display *, Window, int, int, int, int);
972#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK 950#if defined HAVE_MENUS && !defined USE_X_TOOLKIT && !defined USE_GTK
973extern void x_mouse_leave (struct x_display_info *); 951extern void x_mouse_leave (struct x_display_info *);
974#endif 952#endif