aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Möllmann2024-11-15 13:34:55 +0100
committerGerd Möllmann2024-12-19 11:04:04 +0100
commitf92520d009e1ab8024b03d9d71ecc9820573c040 (patch)
tree99df6ff9a70b4c06fd696ea16851e078a2dfcf44
parent8aef5d224a6fccb675729748836d5ebfdcfa1101 (diff)
downloademacs-f92520d009e1ab8024b03d9d71ecc9820573c040.tar.gz
emacs-f92520d009e1ab8024b03d9d71ecc9820573c040.zip
Don't pause display for pending input
* src/dispnew.c: Remove display_completed, redisplay_dont_pause, redisplay-dont-pause was declared obsolete in Emacs 24. Remove anything checking pending input, change function signatures accordingly, and so on. * src/keyboard.c (read_char): Don't use redisplay_dont_pause. * src/minibuf.c (read_minibuf): Use new function signatures. * src/xdisp.c: Don't check display_completed. Use new API. * lisp/subr.el (redisplay-dont-pause): Remove declaration.
-rw-r--r--lisp/subr.el1
-rw-r--r--src/dispextern.h9
-rw-r--r--src/dispnew.c543
-rw-r--r--src/keyboard.c3
-rw-r--r--src/minibuf.c4
-rw-r--r--src/xdisp.c199
6 files changed, 262 insertions, 497 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index b025e39e7ba..a9061456179 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1987,7 +1987,6 @@ be a list of the form returned by `event-start' and `event-end'."
1987 ;; It's been announced as obsolete in NEWS and in the docstring since Emacs-25, 1987 ;; It's been announced as obsolete in NEWS and in the docstring since Emacs-25,
1988 ;; but it's only been marked for compilation warnings since Emacs-29. 1988 ;; but it's only been marked for compilation warnings since Emacs-29.
1989 "25.1") 1989 "25.1")
1990(make-obsolete-variable 'redisplay-dont-pause nil "24.5")
1991(make-obsolete-variable 'operating-system-release nil "28.1") 1990(make-obsolete-variable 'operating-system-release nil "28.1")
1992(make-obsolete-variable 'inhibit-changing-match-data 'save-match-data "29.1") 1991(make-obsolete-variable 'inhibit-changing-match-data 'save-match-data "29.1")
1993 1992
diff --git a/src/dispextern.h b/src/dispextern.h
index 1bec5e24c85..20674a7c8b2 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1322,9 +1322,6 @@ struct glyph_row *matrix_row (struct glyph_matrix *, int);
1322 1322
1323extern struct glyph space_glyph; 1323extern struct glyph space_glyph;
1324 1324
1325/* True means last display completed. False means it was preempted. */
1326
1327extern bool display_completed;
1328 1325
1329/************************************************************************ 1326/************************************************************************
1330 Glyph Strings 1327 Glyph Strings
@@ -3835,7 +3832,7 @@ extern Lisp_Object marginal_area_string (struct window *, enum window_part,
3835 Lisp_Object *, 3832 Lisp_Object *,
3836 int *, int *, int *, int *); 3833 int *, int *, int *, int *);
3837extern void redraw_frame (struct frame *); 3834extern void redraw_frame (struct frame *);
3838extern bool update_frame (struct frame *, bool, bool); 3835void update_frame (struct frame *, bool);
3839extern void update_frame_with_menu (struct frame *, int, int); 3836extern void update_frame_with_menu (struct frame *, int, int);
3840extern int update_mouse_position (struct frame *, int, int); 3837extern int update_mouse_position (struct frame *, int, int);
3841extern void bitch_at_user (void); 3838extern void bitch_at_user (void);
@@ -3954,8 +3951,8 @@ Lisp_Object frames_in_reverse_z_order (struct frame *f, bool visible);
3954bool is_tty_frame (struct frame *f); 3951bool is_tty_frame (struct frame *f);
3955bool is_tty_child_frame (struct frame *f); 3952bool is_tty_child_frame (struct frame *f);
3956bool is_tty_root_frame (struct frame *f); 3953bool is_tty_root_frame (struct frame *f);
3957bool combine_updates (Lisp_Object root_frames, bool force_p, bool inhibit_id_p); 3954void combine_updates (Lisp_Object root_frames, bool inhibit_id_p);
3958bool combine_updates_for_frame (struct frame *f, bool force_p, bool inhibit_id_p); 3955void combine_updates_for_frame (struct frame *f, bool inhibit_id_p);
3959void tty_raise_lower_frame (struct frame *f, bool raise); 3956void tty_raise_lower_frame (struct frame *f, bool raise);
3960int max_child_z_order (struct frame *parent); 3957int max_child_z_order (struct frame *parent);
3961 3958
diff --git a/src/dispnew.c b/src/dispnew.c
index d473a77e3ad..37ec37b752e 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -93,10 +93,10 @@ static void check_matrix_pointers (struct glyph_matrix *,
93 struct glyph_matrix *); 93 struct glyph_matrix *);
94#endif 94#endif
95static void mirror_line_dance (struct window *, int, int, int *, char *); 95static void mirror_line_dance (struct window *, int, int, int *, char *);
96static bool update_window_tree (struct window *, bool); 96static void update_window_tree (struct window *);
97static bool update_window (struct window *, bool); 97static void update_window (struct window *);
98static bool write_matrix (struct frame *, bool, bool, bool, bool); 98static void write_matrix (struct frame *, bool, bool, bool);
99static bool scrolling (struct frame *); 99static void scrolling (struct frame *);
100static void set_window_cursor_after_update (struct window *); 100static void set_window_cursor_after_update (struct window *);
101static void adjust_frame_glyphs_for_window_redisplay (struct frame *); 101static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
102static void adjust_frame_glyphs_for_frame_redisplay (struct frame *); 102static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
@@ -116,10 +116,6 @@ check_rows (struct frame *f)
116} 116}
117#endif 117#endif
118 118
119/* True means last display completed. False means it was preempted. */
120
121bool display_completed;
122
123/* True means SIGWINCH happened when not safe. */ 119/* True means SIGWINCH happened when not safe. */
124 120
125static bool delayed_size_change; 121static bool delayed_size_change;
@@ -175,11 +171,10 @@ static uintmax_t history_tick;
175 171
176/* Add to the redisplay history how window W has been displayed. 172/* Add to the redisplay history how window W has been displayed.
177 MSG is a trace containing the information how W's glyph matrix 173 MSG is a trace containing the information how W's glyph matrix
178 has been constructed. PAUSED_P means that the update 174 has been constructed. */
179 has been interrupted for pending input. */
180 175
181static void 176static void
182add_window_display_history (struct window *w, const char *msg, bool paused_p) 177add_window_display_history (struct window *w, const char *msg)
183{ 178{
184 char *buf; 179 char *buf;
185 void *ptr = w; 180 void *ptr = w;
@@ -190,14 +185,13 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
190 ++history_idx; 185 ++history_idx;
191 186
192 snprintf (buf, sizeof redisplay_history[0].trace, 187 snprintf (buf, sizeof redisplay_history[0].trace,
193 "%"PRIuMAX": window %p (%s)%s\n%s", 188 "%"PRIuMAX": window %p %s\n%s",
194 history_tick++, 189 history_tick++,
195 ptr, 190 ptr,
196 ((BUFFERP (w->contents) 191 ((BUFFERP (w->contents)
197 && STRINGP (BVAR (XBUFFER (w->contents), name))) 192 && STRINGP (BVAR (XBUFFER (w->contents), name)))
198 ? SSDATA (BVAR (XBUFFER (w->contents), name)) 193 ? SSDATA (BVAR (XBUFFER (w->contents), name))
199 : "???"), 194 : "???"),
200 paused_p ? " ***paused***" : "",
201 msg); 195 msg);
202} 196}
203 197
@@ -2136,8 +2130,7 @@ adjust_frame_glyphs_for_frame_redisplay (struct frame *f)
2136 current matrix over a call to adjust_glyph_matrix, we must 2130 current matrix over a call to adjust_glyph_matrix, we must
2137 make a copy of the current glyphs, and restore the current 2131 make a copy of the current glyphs, and restore the current
2138 matrix' contents from that copy. */ 2132 matrix' contents from that copy. */
2139 if (display_completed 2133 if (!FRAME_GARBAGED_P (f)
2140 && !FRAME_GARBAGED_P (f)
2141 && matrix_dim.width == f->current_matrix->matrix_w 2134 && matrix_dim.width == f->current_matrix->matrix_w
2142 && matrix_dim.height == f->current_matrix->matrix_h 2135 && matrix_dim.height == f->current_matrix->matrix_h
2143 /* For some reason, the frame glyph matrix gets corrupted if 2136 /* For some reason, the frame glyph matrix gets corrupted if
@@ -2682,7 +2675,7 @@ build_frame_matrix_from_leaf_window (struct glyph_matrix *frame_matrix, struct w
2682 frame and window share glyphs. */ 2675 frame and window share glyphs. */
2683 2676
2684 strcpy (w->current_matrix->method, w->desired_matrix->method); 2677 strcpy (w->current_matrix->method, w->desired_matrix->method);
2685 add_window_display_history (w, w->current_matrix->method, 0); 2678 add_window_display_history (w, w->current_matrix->method);
2686#endif 2679#endif
2687 } 2680 }
2688 2681
@@ -3778,7 +3771,7 @@ update_bar_window (Lisp_Object window, Lisp_Object *current,
3778 struct window *w = XWINDOW (window); 3771 struct window *w = XWINDOW (window);
3779 if (w->must_be_updated_p) 3772 if (w->must_be_updated_p)
3780 { 3773 {
3781 update_window (w, true); 3774 update_window (w);
3782 w->must_be_updated_p = false; 3775 w->must_be_updated_p = false;
3783 Lisp_Object tem = *current; 3776 Lisp_Object tem = *current;
3784 *current = *desired; 3777 *current = *desired;
@@ -3808,8 +3801,8 @@ update_tool_bar (struct frame *f)
3808#endif 3801#endif
3809} 3802}
3810 3803
3811static bool 3804static void
3812update_window_frame (struct frame *f, bool force_p) 3805update_window_frame (struct frame *f)
3813{ 3806{
3814 eassert (FRAME_WINDOW_P (f)); 3807 eassert (FRAME_WINDOW_P (f));
3815 update_begin (f); 3808 update_begin (f);
@@ -3817,19 +3810,17 @@ update_window_frame (struct frame *f, bool force_p)
3817 update_tab_bar (f); 3810 update_tab_bar (f);
3818 update_tool_bar (f); 3811 update_tool_bar (f);
3819 struct window *root_window = XWINDOW (f->root_window); 3812 struct window *root_window = XWINDOW (f->root_window);
3820 bool paused_p = update_window_tree (root_window, force_p); 3813 update_window_tree (root_window);
3821 update_end (f); 3814 update_end (f);
3822 set_window_update_flags (root_window, false); 3815 set_window_update_flags (root_window, false);
3823 return paused_p;
3824} 3816}
3825 3817
3826static bool 3818static void
3827update_initial_frame (struct frame *f, bool force_p) 3819update_initial_frame (struct frame *f)
3828{ 3820{
3829 build_frame_matrix (f); 3821 build_frame_matrix (f);
3830 struct window *root_window = XWINDOW (f->root_window); 3822 struct window *root_window = XWINDOW (f->root_window);
3831 set_window_update_flags (root_window, false); 3823 set_window_update_flags (root_window, false);
3832 return false;
3833} 3824}
3834 3825
3835static void 3826static void
@@ -3840,11 +3831,10 @@ flush_terminal (struct frame *f)
3840 fflush (FRAME_TTY (f)->output); 3831 fflush (FRAME_TTY (f)->output);
3841} 3832}
3842 3833
3843static bool 3834static void
3844update_tty_frame (struct frame *f, bool force_p) 3835update_tty_frame (struct frame *f)
3845{ 3836{
3846 build_frame_matrix (f); 3837 build_frame_matrix (f);
3847 return false;
3848} 3838}
3849 3839
3850/* Return the cursor position of the selected window of frame F, in 3840/* Return the cursor position of the selected window of frame F, in
@@ -3952,8 +3942,8 @@ terminal_cursor_magic (struct frame *root, struct frame *topmost_child)
3952 } 3942 }
3953} 3943}
3954 3944
3955bool 3945void
3956combine_updates_for_frame (struct frame *f, bool force_p, bool inhibit_scrolling) 3946combine_updates_for_frame (struct frame *f, bool inhibit_scrolling)
3957{ 3947{
3958 struct frame *root = root_frame (f); 3948 struct frame *root = root_frame (f);
3959 eassert (FRAME_VISIBLE_P (root)); 3949 eassert (FRAME_VISIBLE_P (root));
@@ -3969,13 +3959,12 @@ combine_updates_for_frame (struct frame *f, bool force_p, bool inhibit_scrolling
3969 } 3959 }
3970 3960
3971 update_begin (root); 3961 update_begin (root);
3972 bool paused = write_matrix (root, force_p, inhibit_scrolling, 1, false); 3962 write_matrix (root, inhibit_scrolling, 1, false);
3973 if (!paused) 3963 make_matrix_current (root);
3974 make_matrix_current (root);
3975 update_end (root); 3964 update_end (root);
3976 3965
3977 /* If a child is displayed, and the cursor is displayed in another 3966 /* If a child is displayed, and the cursor is displayed in another
3978 frame, the child might lay above the cursor, so that it appers to 3967 frame, the child might lay above the cursor, so that it appears to
3979 "shine through" the child. Avoid that because it's confusing. */ 3968 "shine through" the child. Avoid that because it's confusing. */
3980 if (topmost_child) 3969 if (topmost_child)
3981 terminal_cursor_magic (root, topmost_child); 3970 terminal_cursor_magic (root, topmost_child);
@@ -3992,66 +3981,33 @@ combine_updates_for_frame (struct frame *f, bool force_p, bool inhibit_scrolling
3992 add_frame_display_history (f, false); 3981 add_frame_display_history (f, false);
3993#endif 3982#endif
3994 } 3983 }
3995
3996 return paused;
3997} 3984}
3998 3985
3999/* Update on the screen all root frames ROOTS. Called from 3986/* Update on the screen all root frames ROOTS. Called from
4000 redisplay_internal as the last step of redisplaying. */ 3987 redisplay_internal as the last step of redisplaying. */
4001 3988
4002bool 3989void
4003combine_updates (Lisp_Object roots, bool force_p, bool inhibit_scrolling) 3990combine_updates (Lisp_Object roots, bool inhibit_scrolling)
4004{ 3991{
4005 if (redisplay_dont_pause)
4006 force_p = true;
4007
4008 for (; CONSP (roots); roots = XCDR (roots)) 3992 for (; CONSP (roots); roots = XCDR (roots))
4009 { 3993 {
4010 struct frame *root = XFRAME (XCAR (roots)); 3994 struct frame *root = XFRAME (XCAR (roots));
4011 if (combine_updates_for_frame (root, force_p, inhibit_scrolling)) 3995 combine_updates_for_frame (root, inhibit_scrolling);
4012 {
4013 display_completed = false;
4014 return true;
4015 }
4016 } 3996 }
4017
4018 display_completed = true;
4019 return false;
4020} 3997}
4021 3998
4022/* Update frame F based on the data in desired matrices. 3999/* Update frame F based on the data in desired matrices.
4000 If INHIBIT_SCROLLING, don't try scrolling. */
4023 4001
4024 If FORCE_P, don't let redisplay be stopped by detecting pending input. 4002void
4025 If INHIBIT_SCROLLING, don't try scrolling. 4003update_frame (struct frame *f, bool inhibit_scrolling)
4026
4027 Value is true if redisplay was stopped due to pending input. */
4028
4029bool
4030update_frame (struct frame *f, bool force_p, bool inhibit_scrolling)
4031{ 4004{
4032 struct window *root_window = XWINDOW (f->root_window);
4033
4034 if (redisplay_dont_pause)
4035 force_p = true;
4036 else if (!force_p && detect_input_pending_ignore_squeezables ())
4037 {
4038 /* Reset flags indicating that a window should be updated. */
4039 set_window_update_flags (root_window, false);
4040 display_completed = false;
4041 return true;
4042 }
4043
4044 bool paused;
4045 if (FRAME_WINDOW_P (f)) 4005 if (FRAME_WINDOW_P (f))
4046 paused = update_window_frame (f, force_p); 4006 update_window_frame (f);
4047 else if (FRAME_INITIAL_P (f)) 4007 else if (FRAME_INITIAL_P (f))
4048 paused = update_initial_frame (f, force_p); 4008 update_initial_frame (f);
4049 else 4009 else
4050 paused = update_tty_frame (f, force_p); 4010 update_tty_frame (f);
4051
4052 if (paused)
4053 display_completed = false;
4054 return paused;
4055} 4011}
4056 4012
4057/* Update a TTY frame F that has a menu dropped down over some of its 4013/* Update a TTY frame F that has a menu dropped down over some of its
@@ -4077,7 +4033,7 @@ update_frame_with_menu (struct frame *f, int row, int col)
4077 cursor_at_point_p = !(row >= 0 && col >= 0); 4033 cursor_at_point_p = !(row >= 0 && col >= 0);
4078 /* Do not stop due to pending input, and do not try scrolling. This 4034 /* Do not stop due to pending input, and do not try scrolling. This
4079 means that write_glyphs will always return false. */ 4035 means that write_glyphs will always return false. */
4080 write_matrix (f, 1, 1, cursor_at_point_p, true); 4036 write_matrix (f, 1, cursor_at_point_p, true);
4081 make_matrix_current (f); 4037 make_matrix_current (f);
4082 clear_desired_matrices (f); 4038 clear_desired_matrices (f);
4083 /* ROW and COL tell us where in the menu to position the cursor, so 4039 /* ROW and COL tell us where in the menu to position the cursor, so
@@ -4100,7 +4056,6 @@ update_frame_with_menu (struct frame *f, int row, int col)
4100 4056
4101 /* Reset flags indicating that a window should be updated. */ 4057 /* Reset flags indicating that a window should be updated. */
4102 set_window_update_flags (root_window, false); 4058 set_window_update_flags (root_window, false);
4103 display_completed = true;
4104} 4059}
4105 4060
4106/* Update the mouse position for a frame F. This handles both 4061/* Update the mouse position for a frame F. This handles both
@@ -4156,30 +4111,24 @@ properties or updating the help echo text. */)
4156 Window-based updates 4111 Window-based updates
4157 ************************************************************************/ 4112 ************************************************************************/
4158 4113
4159/* Perform updates in window tree rooted at W. 4114/* Perform updates in window tree rooted at W. */
4160 If FORCE_P, don't stop updating if input is pending. */
4161 4115
4162static bool 4116static void
4163update_window_tree (struct window *w, bool force_p) 4117update_window_tree (struct window *w)
4164{ 4118{
4165 bool paused_p = 0; 4119 while (w)
4166
4167 while (w && !paused_p)
4168 { 4120 {
4169 if (WINDOWP (w->contents)) 4121 if (WINDOWP (w->contents))
4170 paused_p |= update_window_tree (XWINDOW (w->contents), force_p); 4122 update_window_tree (XWINDOW (w->contents));
4171 else if (w->must_be_updated_p) 4123 else if (w->must_be_updated_p)
4172 paused_p |= update_window (w, force_p); 4124 update_window (w);
4173 4125
4174 w = NILP (w->next) ? 0 : XWINDOW (w->next); 4126 w = NILP (w->next) ? 0 : XWINDOW (w->next);
4175 } 4127 }
4176
4177 return paused_p;
4178} 4128}
4179 4129
4180 4130
4181/* Update window W if its flag must_be_updated_p is set. 4131/* Update window W if its flag must_be_updated_p is set. */
4182 If FORCE_P, don't stop updating if input is pending. */
4183 4132
4184void 4133void
4185update_single_window (struct window *w) 4134update_single_window (struct window *w)
@@ -4190,7 +4139,7 @@ update_single_window (struct window *w)
4190 4139
4191 /* Update W. */ 4140 /* Update W. */
4192 update_begin (f); 4141 update_begin (f);
4193 update_window (w, true); 4142 update_window (w);
4194 update_end (f); 4143 update_end (f);
4195 4144
4196 /* Reset flag in W. */ 4145 /* Reset flag in W. */
@@ -4330,15 +4279,12 @@ check_current_matrix_flags (struct window *w)
4330#endif /* GLYPH_DEBUG */ 4279#endif /* GLYPH_DEBUG */
4331 4280
4332 4281
4333/* Update display of window W. 4282/* Update display of window W. */
4334 If FORCE_P, don't stop updating when input is pending. */
4335 4283
4336static bool 4284static void
4337update_window (struct window *w, bool force_p) 4285update_window (struct window *w)
4338{ 4286{
4339 struct glyph_matrix *desired_matrix = w->desired_matrix; 4287 struct glyph_matrix *desired_matrix = w->desired_matrix;
4340 bool paused_p;
4341 int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX);
4342#ifdef HAVE_WINDOW_SYSTEM 4288#ifdef HAVE_WINDOW_SYSTEM
4343 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w))); 4289 struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
4344#endif 4290#endif
@@ -4347,224 +4293,200 @@ update_window (struct window *w, bool force_p)
4347 eassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w)))); 4293 eassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w))));
4348#endif 4294#endif
4349 4295
4350 /* Check pending input the first time so that we can quickly return. */
4351 if (!force_p)
4352 detect_input_pending_ignore_squeezables ();
4353
4354 /* If forced to complete the update, no input is pending, or we are 4296 /* If forced to complete the update, no input is pending, or we are
4355 tracking the mouse, do the update. */ 4297 tracking the mouse, do the update. */
4356 if (force_p || !input_pending || !NILP (track_mouse)) 4298 struct glyph_row *row, *end;
4357 { 4299 struct glyph_row *mode_line_row;
4358 struct glyph_row *row, *end; 4300 struct glyph_row *tab_line_row;
4359 struct glyph_row *mode_line_row; 4301 struct glyph_row *header_line_row;
4360 struct glyph_row *tab_line_row; 4302 int yb;
4361 struct glyph_row *header_line_row; 4303 bool changed_p = 0, mouse_face_overwritten_p = 0;
4362 int yb; 4304 bool invisible_rows_marked = false;
4363 bool changed_p = 0, mouse_face_overwritten_p = 0;
4364 int n_updated = 0;
4365 bool invisible_rows_marked = false;
4366 4305
4367#ifdef HAVE_WINDOW_SYSTEM 4306#ifdef HAVE_WINDOW_SYSTEM
4368 gui_update_window_begin (w); 4307 gui_update_window_begin (w);
4369#else 4308#else
4370 (void) changed_p; 4309 (void) changed_p;
4371#endif 4310#endif
4372 yb = window_text_bottom_y (w); 4311 yb = window_text_bottom_y (w);
4373 row = MATRIX_ROW (desired_matrix, 0); 4312 row = MATRIX_ROW (desired_matrix, 0);
4374 end = MATRIX_MODE_LINE_ROW (desired_matrix); 4313 end = MATRIX_MODE_LINE_ROW (desired_matrix);
4375 4314
4376 /* Take note of the tab line, if there is one. We will 4315 /* Take note of the tab line, if there is one. We will
4377 update it below, after updating all of the window's lines. */ 4316 update it below, after updating all of the window's lines. */
4378 if (row->mode_line_p && row->tab_line_p) 4317 if (row->mode_line_p && row->tab_line_p)
4379 { 4318 {
4380 tab_line_row = row; 4319 tab_line_row = row;
4381 ++row; 4320 ++row;
4382 } 4321 }
4383 else 4322 else
4384 tab_line_row = NULL; 4323 tab_line_row = NULL;
4385 4324
4386 /* Take note of the header line, if there is one. We will 4325 /* Take note of the header line, if there is one. We will
4387 update it below, after updating all of the window's lines. */ 4326 update it below, after updating all of the window's lines. */
4388 if (row->mode_line_p) 4327 if (row->mode_line_p)
4389 { 4328 {
4390 header_line_row = row; 4329 header_line_row = row;
4391 ++row; 4330 ++row;
4392 } 4331 }
4393 else 4332 else
4394 header_line_row = NULL; 4333 header_line_row = NULL;
4395 4334
4396 /* Update the mode line, if necessary. */ 4335 /* Update the mode line, if necessary. */
4397 mode_line_row = MATRIX_MODE_LINE_ROW (desired_matrix); 4336 mode_line_row = MATRIX_MODE_LINE_ROW (desired_matrix);
4398 if (mode_line_row->mode_line_p && mode_line_row->enabled_p) 4337 if (mode_line_row->mode_line_p && mode_line_row->enabled_p)
4399 { 4338 {
4400 mode_line_row->y = yb + WINDOW_SCROLL_BAR_AREA_HEIGHT (w); 4339 mode_line_row->y = yb + WINDOW_SCROLL_BAR_AREA_HEIGHT (w);
4401 update_window_line (w, MATRIX_ROW_VPOS (mode_line_row, 4340 update_window_line (w, MATRIX_ROW_VPOS (mode_line_row,
4402 desired_matrix), 4341 desired_matrix),
4403 &mouse_face_overwritten_p); 4342 &mouse_face_overwritten_p);
4404 } 4343 }
4405 4344
4406 /* Find first enabled row. Optimizations in redisplay_internal 4345 /* Find first enabled row. Optimizations in redisplay_internal
4407 may lead to an update with only one row enabled. There may 4346 may lead to an update with only one row enabled. There may
4408 be also completely empty matrices. */ 4347 be also completely empty matrices. */
4409 while (row < end && !row->enabled_p) 4348 while (row < end && !row->enabled_p)
4410 ++row; 4349 ++row;
4411 4350
4412 /* Try reusing part of the display by copying. */ 4351 /* Try reusing part of the display by copying. */
4413 if (row < end && !desired_matrix->no_scrolling_p) 4352 if (row < end && !desired_matrix->no_scrolling_p)
4353 {
4354 int rc = scrolling_window (w, (tab_line_row != NULL ? 1 : 0)
4355 + (header_line_row != NULL ? 1 : 0));
4356 if (rc < 0)
4414 { 4357 {
4415 int rc = scrolling_window (w, (tab_line_row != NULL ? 1 : 0) 4358 /* All rows were found to be equal. */
4416 + (header_line_row != NULL ? 1 : 0)); 4359 goto set_cursor;
4417 if (rc < 0) 4360 }
4418 { 4361 else if (rc > 0)
4419 /* All rows were found to be equal. */ 4362 {
4420 paused_p = 0; 4363 /* We've scrolled the display. */
4421 goto set_cursor; 4364 changed_p = 1;
4422 }
4423 else if (rc > 0)
4424 {
4425 /* We've scrolled the display. */
4426 force_p = 1;
4427 changed_p = 1;
4428 }
4429 } 4365 }
4366 }
4430 4367
4431 /* Update the rest of the lines. */ 4368 /* Update the rest of the lines. */
4432 for (; row < end && (force_p || !input_pending); ++row) 4369 for (; row < end; ++row)
4433 /* scrolling_window resets the enabled_p flag of the rows it 4370 /* scrolling_window resets the enabled_p flag of the rows it
4434 reuses from current_matrix. */ 4371 reuses from current_matrix. */
4435 if (row->enabled_p) 4372 if (row->enabled_p)
4373 {
4374 int vpos = MATRIX_ROW_VPOS (row, desired_matrix);
4375 int i;
4376
4377 changed_p |= update_window_line (w, vpos,
4378 &mouse_face_overwritten_p);
4379
4380 /* Mark all rows below the last visible one in the current
4381 matrix as invalid. This is necessary because of
4382 variable line heights. Consider the case of three
4383 successive redisplays, where the first displays 5
4384 lines, the second 3 lines, and the third 5 lines again.
4385 If the second redisplay wouldn't mark rows in the
4386 current matrix invalid, the third redisplay might be
4387 tempted to optimize redisplay based on lines displayed
4388 in the first redisplay. */
4389 if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
4436 { 4390 {
4437 int vpos = MATRIX_ROW_VPOS (row, desired_matrix); 4391 for (i = vpos + 1; i < w->current_matrix->nrows - 1; ++i)
4438 int i; 4392 SET_MATRIX_ROW_ENABLED_P (w->current_matrix, i, false);
4439 4393 invisible_rows_marked = true;
4440 /* We'll have to play a little bit with when to
4441 detect_input_pending. If it's done too often,
4442 scrolling large windows with repeated scroll-up
4443 commands will too quickly pause redisplay. */
4444 if (!force_p && ++n_updated % preempt_count == 0)
4445 detect_input_pending_ignore_squeezables ();
4446 changed_p |= update_window_line (w, vpos,
4447 &mouse_face_overwritten_p);
4448
4449 /* Mark all rows below the last visible one in the current
4450 matrix as invalid. This is necessary because of
4451 variable line heights. Consider the case of three
4452 successive redisplays, where the first displays 5
4453 lines, the second 3 lines, and the third 5 lines again.
4454 If the second redisplay wouldn't mark rows in the
4455 current matrix invalid, the third redisplay might be
4456 tempted to optimize redisplay based on lines displayed
4457 in the first redisplay. */
4458 if (MATRIX_ROW_BOTTOM_Y (row) >= yb)
4459 {
4460 for (i = vpos + 1; i < w->current_matrix->nrows - 1; ++i)
4461 SET_MATRIX_ROW_ENABLED_P (w->current_matrix, i, false);
4462 invisible_rows_marked = true;
4463 }
4464 } 4394 }
4395 }
4465 4396
4466 /* If the window doesn't display its mode line, make sure the 4397 /* If the window doesn't display its mode line, make sure the
4467 corresponding row of the current glyph matrix is disabled, so 4398 corresponding row of the current glyph matrix is disabled, so
4468 that if and when the mode line is displayed again, it will be 4399 that if and when the mode line is displayed again, it will be
4469 cleared and completely redrawn. */ 4400 cleared and completely redrawn. */
4470 if (!window_wants_mode_line (w)) 4401 if (!window_wants_mode_line (w))
4471 SET_MATRIX_ROW_ENABLED_P (w->current_matrix, 4402 SET_MATRIX_ROW_ENABLED_P (w->current_matrix,
4472 w->current_matrix->nrows - 1, false); 4403 w->current_matrix->nrows - 1, false);
4473 4404
4474 /* Was display preempted? */ 4405 if (!invisible_rows_marked)
4475 paused_p = row < end; 4406 {
4476 4407 /* If we didn't mark the invisible rows in the current
4477 if (!paused_p && !invisible_rows_marked) 4408 matrix as invalid above, do that now. This can happen if
4409 scrolling_window updates the last visible rows of the
4410 current matrix, in which case the above loop doesn't get
4411 to examine the last visible row. */
4412 int i;
4413 for (i = 0; i < w->current_matrix->nrows - 1; ++i)
4478 { 4414 {
4479 /* If we didn't mark the invisible rows in the current 4415 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, i);
4480 matrix as invalid above, do that now. This can happen if 4416 if (current_row->enabled_p
4481 scrolling_window updates the last visible rows of the 4417 && MATRIX_ROW_BOTTOM_Y (current_row) >= yb)
4482 current matrix, in which case the above loop doesn't get
4483 to examine the last visible row. */
4484 int i;
4485 for (i = 0; i < w->current_matrix->nrows - 1; ++i)
4486 { 4418 {
4487 struct glyph_row *current_row = MATRIX_ROW (w->current_matrix, i); 4419 for (++i ; i < w->current_matrix->nrows - 1; ++i)
4488 if (current_row->enabled_p 4420 SET_MATRIX_ROW_ENABLED_P (w->current_matrix, i, false);
4489 && MATRIX_ROW_BOTTOM_Y (current_row) >= yb)
4490 {
4491 for (++i ; i < w->current_matrix->nrows - 1; ++i)
4492 SET_MATRIX_ROW_ENABLED_P (w->current_matrix, i, false);
4493 }
4494 } 4421 }
4495 } 4422 }
4423 }
4496 4424
4497 set_cursor: 4425 set_cursor:
4498 4426
4499 /* Update the tab line after scrolling because a new tab 4427 /* Update the tab line after scrolling because a new tab
4500 line would otherwise overwrite lines at the top of the window 4428 line would otherwise overwrite lines at the top of the window
4501 that can be scrolled. */ 4429 that can be scrolled. */
4502 if (tab_line_row && tab_line_row->enabled_p) 4430 if (tab_line_row && tab_line_row->enabled_p)
4503 { 4431 {
4504 tab_line_row->y = 0; 4432 tab_line_row->y = 0;
4505 update_window_line (w, 0, &mouse_face_overwritten_p); 4433 update_window_line (w, 0, &mouse_face_overwritten_p);
4506 } 4434 }
4507 4435
4508 /* Update the header line after scrolling because a new header 4436 /* Update the header line after scrolling because a new header
4509 line would otherwise overwrite lines at the top of the window 4437 line would otherwise overwrite lines at the top of the window
4510 that can be scrolled. */ 4438 that can be scrolled. */
4511 if (header_line_row && header_line_row->enabled_p) 4439 if (header_line_row && header_line_row->enabled_p)
4512 { 4440 {
4513 header_line_row->y = tab_line_row ? CURRENT_TAB_LINE_HEIGHT (w) : 0; 4441 header_line_row->y = tab_line_row ? CURRENT_TAB_LINE_HEIGHT (w) : 0;
4514 update_window_line (w, tab_line_row ? 1 : 0, &mouse_face_overwritten_p); 4442 update_window_line (w, tab_line_row ? 1 : 0, &mouse_face_overwritten_p);
4515 } 4443 }
4516 4444
4517 /* Fix the appearance of overlapping/overlapped rows. */ 4445 /* Fix the appearance of overlapping/overlapped rows. */
4518 if (!paused_p && !w->pseudo_window_p) 4446 if (!w->pseudo_window_p)
4519 { 4447 {
4520#ifdef HAVE_WINDOW_SYSTEM 4448#ifdef HAVE_WINDOW_SYSTEM
4521 if (changed_p && rif->fix_overlapping_area) 4449 if (changed_p && rif->fix_overlapping_area)
4522 { 4450 {
4523 redraw_overlapped_rows (w, yb); 4451 redraw_overlapped_rows (w, yb);
4524 redraw_overlapping_rows (w, yb); 4452 redraw_overlapping_rows (w, yb);
4525 } 4453 }
4526#endif 4454#endif
4527 4455
4528 /* Make cursor visible at cursor position of W. */ 4456 /* Make cursor visible at cursor position of W. */
4529 set_window_cursor_after_update (w); 4457 set_window_cursor_after_update (w);
4530 4458
4531#if 0 /* Check that current matrix invariants are satisfied. This is 4459#if 0 /* Check that current matrix invariants are satisfied. This is
4532 for debugging only. See the comment of check_matrix_invariants. */ 4460 for debugging only. See the comment of check_matrix_invariants. */
4533 IF_DEBUG (check_matrix_invariants (w)); 4461 IF_DEBUG (check_matrix_invariants (w));
4534#endif 4462#endif
4535 } 4463 }
4536 4464
4537#ifdef GLYPH_DEBUG 4465#ifdef GLYPH_DEBUG
4538 /* Remember the redisplay method used to display the matrix. */ 4466 /* Remember the redisplay method used to display the matrix. */
4539 strcpy (w->current_matrix->method, w->desired_matrix->method); 4467 strcpy (w->current_matrix->method, w->desired_matrix->method);
4540#endif 4468#endif
4541 4469
4542#ifdef HAVE_WINDOW_SYSTEM 4470#ifdef HAVE_WINDOW_SYSTEM
4543 update_window_fringes (w, 0); 4471 update_window_fringes (w, 0);
4544 4472
4545 /* End the update of window W. Don't set the cursor if we 4473 /* End the update of window W. Don't set the cursor if we
4546 paused updating the display because in this case, 4474 paused updating the display because in this case,
4547 set_window_cursor_after_update hasn't been called, and 4475 set_window_cursor_after_update hasn't been called, and
4548 W->output_cursor doesn't contain the cursor location. */ 4476 W->output_cursor doesn't contain the cursor location. */
4549 gui_update_window_end (w, !paused_p, mouse_face_overwritten_p); 4477 gui_update_window_end (w, true, mouse_face_overwritten_p);
4550#endif 4478#endif
4551 /* If the update wasn't interrupted, this window has been 4479 /* If the update wasn't interrupted, this window has been
4552 completely updated. */ 4480 completely updated. */
4553 if (!paused_p) 4481 w->must_be_updated_p = false;
4554 w->must_be_updated_p = false;
4555 }
4556 else
4557 paused_p = 1;
4558 4482
4559#ifdef GLYPH_DEBUG 4483#ifdef GLYPH_DEBUG
4560 /* check_current_matrix_flags (w); */ 4484 /* check_current_matrix_flags (w); */
4561 add_window_display_history (w, w->current_matrix->method, paused_p); 4485 add_window_display_history (w, w->current_matrix->method);
4562#endif 4486#endif
4563 4487
4564 xwidget_end_redisplay (w, w->current_matrix); 4488 xwidget_end_redisplay (w, w->current_matrix);
4565 clear_glyph_matrix (desired_matrix); 4489 clear_glyph_matrix (desired_matrix);
4566
4567 return paused_p;
4568} 4490}
4569 4491
4570#ifdef HAVE_WINDOW_SYSTEM 4492#ifdef HAVE_WINDOW_SYSTEM
@@ -5697,20 +5619,13 @@ tty_set_cursor (void)
5697} 5619}
5698 5620
5699/* Write desired matix of tty frame F and make it current. 5621/* Write desired matix of tty frame F and make it current.
5700
5701 FORCE_P means that the update should not be stopped by pending input.
5702 INHIBIT_ID_P means that scrolling by insert/delete should not be tried. 5622 INHIBIT_ID_P means that scrolling by insert/delete should not be tried.
5703 SET_CURSOR_P false means do not set cursor at point in selected window. 5623 SET_CURSOR_P false means do not set cursor at point in selected window. */
5704 5624
5705 Value is true if update was stopped due to pending input. */ 5625static void
5706 5626write_matrix (struct frame *f, bool inhibit_id_p,
5707static bool
5708write_matrix (struct frame *f, bool force_p, bool inhibit_id_p,
5709 bool set_cursor_p, bool updating_menu_p) 5627 bool set_cursor_p, bool updating_menu_p)
5710{ 5628{
5711 if (!force_p && detect_input_pending_ignore_squeezables ())
5712 return true;
5713
5714 /* If we cannot insert/delete lines, it's no use trying it. */ 5629 /* If we cannot insert/delete lines, it's no use trying it. */
5715 if (!FRAME_LINE_INS_DEL_OK (f)) 5630 if (!FRAME_LINE_INS_DEL_OK (f))
5716 inhibit_id_p = true; 5631 inhibit_id_p = true;
@@ -5722,7 +5637,7 @@ write_matrix (struct frame *f, bool force_p, bool inhibit_id_p,
5722 i/d line if just want cursor motion. */ 5637 i/d line if just want cursor motion. */
5723 int first_row = first_enabled_row (f->desired_matrix); 5638 int first_row = first_enabled_row (f->desired_matrix);
5724 if (!inhibit_id_p && first_row >= 0) 5639 if (!inhibit_id_p && first_row >= 0)
5725 force_p |= scrolling (f); 5640 scrolling (f);
5726 5641
5727 /* Update the individual lines as needed. Do bottom line first. This 5642 /* Update the individual lines as needed. Do bottom line first. This
5728 is done so that messages are made visible when pausing. */ 5643 is done so that messages are made visible when pausing. */
@@ -5730,36 +5645,19 @@ write_matrix (struct frame *f, bool force_p, bool inhibit_id_p,
5730 if (MATRIX_ROW_ENABLED_P (f->desired_matrix, last_row)) 5645 if (MATRIX_ROW_ENABLED_P (f->desired_matrix, last_row))
5731 write_row (f, last_row, updating_menu_p); 5646 write_row (f, last_row, updating_menu_p);
5732 5647
5733 bool pause_p = false;
5734 if (first_row >= 0) 5648 if (first_row >= 0)
5735 { 5649 for (int i = first_row; i < last_row; ++i)
5736 const int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX); 5650 if (MATRIX_ROW_ENABLED_P (f->desired_matrix, i))
5737 5651 write_row (f, i, updating_menu_p);
5738 for (int i = first_row, n = 0; i < last_row; ++i)
5739 if (MATRIX_ROW_ENABLED_P (f->desired_matrix, i))
5740 {
5741 if (!force_p && n % preempt_count == 0
5742 && detect_input_pending_ignore_squeezables ())
5743 {
5744 pause_p = true;
5745 break;
5746 }
5747
5748 write_row (f, i, updating_menu_p);
5749 ++n;
5750 }
5751 }
5752 5652
5753 /* Now just clean up termcap drivers and set cursor, etc. */ 5653 /* Now just clean up termcap drivers and set cursor, etc. */
5754 if (!pause_p && set_cursor_p) 5654 if (set_cursor_p)
5755 tty_set_cursor (); 5655 tty_set_cursor ();
5756
5757 return pause_p;
5758} 5656}
5759 5657
5760/* Do line insertions/deletions on frame F for frame-based redisplay. */ 5658/* Do line insertions/deletions on frame F for frame-based redisplay. */
5761 5659
5762static bool 5660static void
5763scrolling (struct frame *frame) 5661scrolling (struct frame *frame)
5764{ 5662{
5765 /* In fact this code should never be reached at all under 5663 /* In fact this code should never be reached at all under
@@ -5796,7 +5694,7 @@ scrolling (struct frame *frame)
5796 if (!MATRIX_ROW_ENABLED_P (current_matrix, i)) 5694 if (!MATRIX_ROW_ENABLED_P (current_matrix, i))
5797 { 5695 {
5798 SAFE_FREE (); 5696 SAFE_FREE ();
5799 return false; 5697 return;
5800 } 5698 }
5801 old_hash[i] = line_hash_code (frame, MATRIX_ROW (current_matrix, i)); 5699 old_hash[i] = line_hash_code (frame, MATRIX_ROW (current_matrix, i));
5802 if (! MATRIX_ROW_ENABLED_P (desired_matrix, i)) 5700 if (! MATRIX_ROW_ENABLED_P (desired_matrix, i))
@@ -5827,7 +5725,7 @@ scrolling (struct frame *frame)
5827 || unchanged_at_bottom == height) 5725 || unchanged_at_bottom == height)
5828 { 5726 {
5829 SAFE_FREE (); 5727 SAFE_FREE ();
5830 return true; 5728 return;
5831 } 5729 }
5832 5730
5833 window_size = (height - unchanged_at_top 5731 window_size = (height - unchanged_at_top
@@ -5857,7 +5755,6 @@ scrolling (struct frame *frame)
5857 5755
5858 SAFE_FREE (); 5756 SAFE_FREE ();
5859#endif 5757#endif
5860 return false;
5861} 5758}
5862 5759
5863 5760
@@ -6989,27 +6886,18 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
6989 6886
6990 6887
6991DEFUN ("redisplay", Fredisplay, Sredisplay, 0, 1, 0, 6888DEFUN ("redisplay", Fredisplay, Sredisplay, 0, 1, 0,
6992 doc: /* Perform redisplay. 6889 doc : /* Perform redisplay.
6993Optional arg FORCE, if non-nil, prevents redisplay from being 6890Optional arg FORCE exists for historical reasons and is ignored.
6994preempted by arriving input, even if `redisplay-dont-pause' is nil. 6891Value is t if redisplay has been performed, nil if executing a
6995If `redisplay-dont-pause' is non-nil (the default), redisplay is never 6892keyboard macro. */)
6996preempted by arriving input, so FORCE does nothing.
6997
6998Return t if redisplay was performed, nil if redisplay was preempted
6999immediately by pending input. */)
7000 (Lisp_Object force) 6893 (Lisp_Object force)
7001{ 6894{
7002 swallow_events (true); 6895 swallow_events (true);
7003 if ((detect_input_pending_run_timers (1) 6896 if (!NILP (Vexecuting_kbd_macro))
7004 && NILP (force) && !redisplay_dont_pause)
7005 || !NILP (Vexecuting_kbd_macro))
7006 return Qnil; 6897 return Qnil;
7007 6898
7008 specpdl_ref count = SPECPDL_INDEX ();
7009 if (!NILP (force) && !redisplay_dont_pause)
7010 specbind (Qredisplay_dont_pause, Qt);
7011 redisplay_preserve_echo_area (2); 6899 redisplay_preserve_echo_area (2);
7012 return unbind_to (count, Qt); 6900 return Qt;
7013} 6901}
7014 6902
7015 6903
@@ -7462,8 +7350,6 @@ syms_of_display (void)
7462 /* This is the "purpose" slot of a display table. */ 7350 /* This is the "purpose" slot of a display table. */
7463 DEFSYM (Qdisplay_table, "display-table"); 7351 DEFSYM (Qdisplay_table, "display-table");
7464 DEFSYM (Qframe__z_order_lessp, "frame--z-order-lessp"); 7352 DEFSYM (Qframe__z_order_lessp, "frame--z-order-lessp");
7465
7466 DEFSYM (Qredisplay_dont_pause, "redisplay-dont-pause");
7467 DEFSYM (Qtty_non_selected_cursor, "tty-non-selected-cursor"); 7353 DEFSYM (Qtty_non_selected_cursor, "tty-non-selected-cursor");
7468 7354
7469 DEFVAR_INT ("baud-rate", baud_rate, 7355 DEFVAR_INT ("baud-rate", baud_rate,
@@ -7545,17 +7431,6 @@ It is also used for standard output and error streams.
7545See `buffer-display-table' for more information. */); 7431See `buffer-display-table' for more information. */);
7546 Vstandard_display_table = Qnil; 7432 Vstandard_display_table = Qnil;
7547 7433
7548 DEFVAR_BOOL ("redisplay-dont-pause", redisplay_dont_pause,
7549 doc: /* Nil means display update is paused when input is detected. */);
7550 /* Contrary to expectations, a value of "false" can be detrimental to
7551 responsiveness since aborting a redisplay throws away some of the
7552 work already performed. It's usually more efficient (and gives
7553 more prompt feedback to the user) to let the redisplay terminate,
7554 and just completely skip the next command's redisplay (which is
7555 done regardless of this setting if there's pending input at the
7556 beginning of the next redisplay). */
7557 redisplay_dont_pause = true;
7558
7559 DEFVAR_LISP ("x-show-tooltip-timeout", Vx_show_tooltip_timeout, 7434 DEFVAR_LISP ("x-show-tooltip-timeout", Vx_show_tooltip_timeout,
7560 doc: /* The default timeout (in seconds) for `x-show-tip'. */); 7435 doc: /* The default timeout (in seconds) for `x-show-tip'. */);
7561 Vx_show_tooltip_timeout = make_fixnum (5); 7436 Vx_show_tooltip_timeout = make_fixnum (5);
diff --git a/src/keyboard.c b/src/keyboard.c
index bfb5fd3592b..fe485a3efd6 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2663,8 +2663,7 @@ read_char (int commandflag, Lisp_Object map,
2663 swallow_events (false); /* May clear input_pending. */ 2663 swallow_events (false); /* May clear input_pending. */
2664 2664
2665 /* Redisplay if no pending input. */ 2665 /* Redisplay if no pending input. */
2666 while (!(input_pending 2666 while (!(input_pending && input_was_pending))
2667 && (input_was_pending || !redisplay_dont_pause)))
2668 { 2667 {
2669 input_was_pending = input_pending; 2668 input_was_pending = input_pending;
2670 if (help_echo_showing_p && !BASE_EQ (selected_window, minibuf_window)) 2669 if (help_echo_showing_p && !BASE_EQ (selected_window, minibuf_window))
diff --git a/src/minibuf.c b/src/minibuf.c
index e75ac5e51df..e50913a013f 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -914,9 +914,9 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
914 XWINDOW (minibuf_window)->cursor.x = 0; 914 XWINDOW (minibuf_window)->cursor.x = 0;
915 XWINDOW (minibuf_window)->must_be_updated_p = true; 915 XWINDOW (minibuf_window)->must_be_updated_p = true;
916 struct frame *sf = XFRAME (selected_frame); 916 struct frame *sf = XFRAME (selected_frame);
917 update_frame (sf, true, true); 917 update_frame (sf, true);
918 if (is_tty_frame (sf)) 918 if (is_tty_frame (sf))
919 combine_updates_for_frame (sf, true, true); 919 combine_updates_for_frame (sf, true);
920 920
921#ifndef HAVE_NTGUI 921#ifndef HAVE_NTGUI
922 flush_frame (XFRAME (XWINDOW (minibuf_window)->frame)); 922 flush_frame (XFRAME (XWINDOW (minibuf_window)->frame));
diff --git a/src/xdisp.c b/src/xdisp.c
index 1f6fb438668..585a9f32956 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1116,7 +1116,6 @@ static void set_iterator_to_next (struct it *, bool);
1116static void mark_window_display_accurate_1 (struct window *, bool); 1116static void mark_window_display_accurate_1 (struct window *, bool);
1117static bool row_for_charpos_p (struct glyph_row *, ptrdiff_t); 1117static bool row_for_charpos_p (struct glyph_row *, ptrdiff_t);
1118static bool cursor_row_p (struct glyph_row *); 1118static bool cursor_row_p (struct glyph_row *);
1119static int redisplay_mode_lines (Lisp_Object, bool);
1120 1119
1121static void handle_line_prefix (struct it *); 1120static void handle_line_prefix (struct it *);
1122 1121
@@ -13521,24 +13520,6 @@ echo_area_display (bool update_frame_p)
13521 here could cause confusion. */ 13520 here could cause confusion. */
13522 if (update_frame_p && !redisplaying_p) 13521 if (update_frame_p && !redisplaying_p)
13523 { 13522 {
13524 int n = 0;
13525
13526 /* If the display update has been interrupted by pending
13527 input, update mode lines in the frame. Due to the
13528 pending input, it might have been that redisplay hasn't
13529 been called, so that mode lines above the echo area are
13530 garbaged. This looks odd, so we prevent it here. */
13531 if (!display_completed)
13532 {
13533 n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), false);
13534
13535#ifdef HAVE_WINDOW_SYSTEM
13536 if (FRAME_WINDOW_P (f)
13537 && FRAME_RIF (f)->clear_under_internal_border)
13538 FRAME_RIF (f)->clear_under_internal_border (f);
13539#endif
13540 }
13541
13542 if (window_height_changed_p 13523 if (window_height_changed_p
13543 /* Don't do this if Emacs is shutting down. Redisplay 13524 /* Don't do this if Emacs is shutting down. Redisplay
13544 needs to run hooks. */ 13525 needs to run hooks. */
@@ -13547,13 +13528,10 @@ echo_area_display (bool update_frame_p)
13547 /* Must update other windows. Likewise as in other 13528 /* Must update other windows. Likewise as in other
13548 cases, don't let this update be interrupted by 13529 cases, don't let this update be interrupted by
13549 pending input. */ 13530 pending input. */
13550 specpdl_ref count = SPECPDL_INDEX ();
13551 specbind (Qredisplay_dont_pause, Qt);
13552 fset_redisplay (f); 13531 fset_redisplay (f);
13553 redisplay_internal (); 13532 redisplay_internal ();
13554 unbind_to (count, Qnil);
13555 } 13533 }
13556 else if (FRAME_WINDOW_P (f) && n == 0) 13534 else if (FRAME_WINDOW_P (f))
13557 { 13535 {
13558 /* Window configuration is the same as before. 13536 /* Window configuration is the same as before.
13559 Can do with a display update of the echo area, 13537 Can do with a display update of the echo area,
@@ -13563,9 +13541,9 @@ echo_area_display (bool update_frame_p)
13563 } 13541 }
13564 else 13542 else
13565 { 13543 {
13566 update_frame (f, true, true); 13544 update_frame (f, true);
13567 if (is_tty_frame (f)) 13545 if (is_tty_frame (f))
13568 combine_updates_for_frame (f, true, true); 13546 combine_updates_for_frame (f, true);
13569 } 13547 }
13570 13548
13571 /* If cursor is in the echo area, make sure that the next 13549 /* If cursor is in the echo area, make sure that the next
@@ -16948,7 +16926,6 @@ redisplay_internal (void)
16948 struct window *w = XWINDOW (selected_window); 16926 struct window *w = XWINDOW (selected_window);
16949 struct window *sw; 16927 struct window *sw;
16950 struct frame *fr; 16928 struct frame *fr;
16951 bool pending;
16952 bool must_finish = false, match_p; 16929 bool must_finish = false, match_p;
16953 struct text_pos tlbufpos, tlendpos; 16930 struct text_pos tlbufpos, tlendpos;
16954 int number_of_visible_frames; 16931 int number_of_visible_frames;
@@ -17034,7 +17011,6 @@ redisplay_internal (void)
17034 /* Remember the currently selected window. */ 17011 /* Remember the currently selected window. */
17035 sw = w; 17012 sw = w;
17036 17013
17037 pending = false;
17038 forget_escape_and_glyphless_faces (); 17014 forget_escape_and_glyphless_faces ();
17039 17015
17040 inhibit_free_realized_faces = false; 17016 inhibit_free_realized_faces = false;
@@ -17594,7 +17570,7 @@ redisplay_internal (void)
17594 unrequest_sigio (); 17570 unrequest_sigio ();
17595 STOP_POLLING; 17571 STOP_POLLING;
17596 17572
17597 pending |= update_frame (f, false, false); 17573 update_frame (f, false);
17598 /* On some platforms (at least MS-Windows), the 17574 /* On some platforms (at least MS-Windows), the
17599 scroll_run_hook called from scrolling_window 17575 scroll_run_hook called from scrolling_window
17600 called from update_frame could set the frame's 17576 called from update_frame could set the frame's
@@ -17616,27 +17592,24 @@ redisplay_internal (void)
17616 } 17592 }
17617 17593
17618 if (CONSP (tty_root_frames)) 17594 if (CONSP (tty_root_frames))
17619 pending |= combine_updates (tty_root_frames, false, false); 17595 combine_updates (tty_root_frames, false);
17620 17596
17621 eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window)); 17597 eassert (EQ (XFRAME (selected_frame)->selected_window, selected_window));
17622 17598
17623 if (!pending) 17599 /* Do the mark_window_display_accurate after all windows have
17600 been redisplayed because this call resets flags in buffers
17601 which are needed for proper redisplay. */
17602 FOR_EACH_FRAME (tail, frame)
17624 { 17603 {
17625 /* Do the mark_window_display_accurate after all windows have 17604 struct frame *f = XFRAME (frame);
17626 been redisplayed because this call resets flags in buffers 17605 if (f->updated_p)
17627 which are needed for proper redisplay. */ 17606 {
17628 FOR_EACH_FRAME (tail, frame) 17607 f->redisplay = false;
17629 { 17608 f->garbaged = false;
17630 struct frame *f = XFRAME (frame); 17609 mark_window_display_accurate (f->root_window, true);
17631 if (f->updated_p) 17610 if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
17632 { 17611 FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
17633 f->redisplay = false; 17612 }
17634 f->garbaged = false;
17635 mark_window_display_accurate (f->root_window, true);
17636 if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
17637 FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
17638 }
17639 }
17640 } 17613 }
17641 } 17614 }
17642 else if (FRAME_REDISPLAY_P (sf)) 17615 else if (FRAME_REDISPLAY_P (sf))
@@ -17700,10 +17673,10 @@ redisplay_internal (void)
17700 } 17673 }
17701 17674
17702 XWINDOW (selected_window)->must_be_updated_p = true; 17675 XWINDOW (selected_window)->must_be_updated_p = true;
17703 pending = update_frame (sf, false, false); 17676 update_frame (sf, false);
17704 17677
17705 if (is_tty_frame (sf)) 17678 if (is_tty_frame (sf))
17706 pending |= combine_updates_for_frame (sf, false, false); 17679 combine_updates_for_frame (sf, false);
17707 17680
17708 sf->cursor_type_changed = false; 17681 sf->cursor_type_changed = false;
17709 sf->inhibit_clear_image_cache = false; 17682 sf->inhibit_clear_image_cache = false;
@@ -17720,11 +17693,11 @@ redisplay_internal (void)
17720 if (mini_frame != sf) 17693 if (mini_frame != sf)
17721 { 17694 {
17722 XWINDOW (mini_window)->must_be_updated_p = true; 17695 XWINDOW (mini_window)->must_be_updated_p = true;
17723 pending |= update_frame (mini_frame, false, false); 17696 update_frame (mini_frame, false);
17724 if (is_tty_frame (mini_frame)) 17697 if (is_tty_frame (mini_frame))
17725 pending |= combine_updates_for_frame (mini_frame, false, false); 17698 combine_updates_for_frame (mini_frame, false);
17726 mini_frame->cursor_type_changed = false; 17699 mini_frame->cursor_type_changed = false;
17727 if (!pending && hscroll_retries <= MAX_HSCROLL_RETRIES 17700 if (hscroll_retries <= MAX_HSCROLL_RETRIES
17728 && hscroll_windows (mini_window)) 17701 && hscroll_windows (mini_window))
17729 { 17702 {
17730 hscroll_retries++; 17703 hscroll_retries++;
@@ -17733,47 +17706,26 @@ redisplay_internal (void)
17733 } 17706 }
17734 } 17707 }
17735 17708
17736 /* If display was paused because of pending input, make sure we do a 17709 if (!consider_all_windows_p)
17737 thorough update the next time. */
17738 if (pending)
17739 { 17710 {
17740 /* Prevent the optimization at the beginning of 17711 /* This has already been done above if
17741 redisplay_internal that tries a single-line update of the 17712 consider_all_windows_p is set. */
17742 line containing the cursor in the selected window. */ 17713 if (XBUFFER (w->contents)->text->redisplay
17743 CHARPOS (this_line_start_pos) = 0; 17714 && buffer_window_count (XBUFFER (w->contents)) > 1)
17715 /* This can happen if b->text->redisplay was set during
17716 jit-lock. */
17717 propagate_buffer_redisplay ();
17718 mark_window_display_accurate_1 (w, true);
17744 17719
17745 /* Let the overlay arrow be updated the next time. */ 17720 /* Say overlay arrows are up to date. */
17746 update_overlay_arrows (0); 17721 update_overlay_arrows (1);
17747 17722
17748 /* If we pause after scrolling, some rows in the current 17723 if (FRAME_TERMINAL (sf)->frame_up_to_date_hook != 0)
17749 matrices of some windows are not valid. */ 17724 FRAME_TERMINAL (sf)->frame_up_to_date_hook (sf);
17750 if (!WINDOW_FULL_WIDTH_P (w)
17751 && !FRAME_WINDOW_P (XFRAME (w->frame)))
17752 update_mode_lines = 36;
17753 } 17725 }
17754 else
17755 {
17756 if (!consider_all_windows_p)
17757 {
17758 /* This has already been done above if
17759 consider_all_windows_p is set. */
17760 if (XBUFFER (w->contents)->text->redisplay
17761 && buffer_window_count (XBUFFER (w->contents)) > 1)
17762 /* This can happen if b->text->redisplay was set during
17763 jit-lock. */
17764 propagate_buffer_redisplay ();
17765 mark_window_display_accurate_1 (w, true);
17766 17726
17767 /* Say overlay arrows are up to date. */ 17727 update_mode_lines = 0;
17768 update_overlay_arrows (1); 17728 windows_or_buffers_changed = 0;
17769
17770 if (FRAME_TERMINAL (sf)->frame_up_to_date_hook != 0)
17771 FRAME_TERMINAL (sf)->frame_up_to_date_hook (sf);
17772 }
17773
17774 update_mode_lines = 0;
17775 windows_or_buffers_changed = 0;
17776 }
17777 17729
17778 /* Start SIGIO interrupts coming again. Having them off during the 17730 /* Start SIGIO interrupts coming again. Having them off during the
17779 code above makes it less likely one will discard output, but not 17731 code above makes it less likely one will discard output, but not
@@ -17789,26 +17741,23 @@ redisplay_internal (void)
17789 redisplay constructing glyphs, so simply exposing a frame won't 17741 redisplay constructing glyphs, so simply exposing a frame won't
17790 display anything in this case. So, we have to display these 17742 display anything in this case. So, we have to display these
17791 frames here explicitly. */ 17743 frames here explicitly. */
17792 if (!pending) 17744 int new_count = 0;
17793 {
17794 int new_count = 0;
17795
17796 FOR_EACH_FRAME (tail, frame)
17797 {
17798 if (FRAME_REDISPLAY_P (XFRAME (frame)))
17799 new_count++;
17800 }
17801 17745
17802 if (new_count != number_of_visible_frames) 17746 FOR_EACH_FRAME (tail, frame)
17803 windows_or_buffers_changed = 52; 17747 {
17748 if (FRAME_REDISPLAY_P (XFRAME (frame)))
17749 new_count++;
17804 } 17750 }
17805 17751
17752 if (new_count != number_of_visible_frames)
17753 windows_or_buffers_changed = 52;
17754
17806 /* Change frame size now if a change is pending. */ 17755 /* Change frame size now if a change is pending. */
17807 do_pending_window_change (true); 17756 do_pending_window_change (true);
17808 17757
17809 /* If we just did a pending size change, or have additional 17758 /* If we just did a pending size change, or have additional
17810 visible frames, or selected_window changed, redisplay again. */ 17759 visible frames, or selected_window changed, redisplay again. */
17811 if ((windows_or_buffers_changed && !pending) 17760 if (windows_or_buffers_changed
17812 || (WINDOWP (selected_window) 17761 || (WINDOWP (selected_window)
17813 && (w = XWINDOW (selected_window)) != sw)) 17762 && (w = XWINDOW (selected_window)) != sw))
17814 goto retry; 17763 goto retry;
@@ -27432,60 +27381,6 @@ display_tty_menu_item (const char *item_text, int width, int face_id,
27432 Mode Line 27381 Mode Line
27433 ***********************************************************************/ 27382 ***********************************************************************/
27434 27383
27435/* Redisplay mode lines in the window tree whose root is WINDOW.
27436 If FORCE, redisplay mode lines unconditionally.
27437 Otherwise, redisplay only mode lines that are garbaged. Value is
27438 the number of windows whose mode lines were redisplayed. */
27439
27440static int
27441redisplay_mode_lines (Lisp_Object window, bool force)
27442{
27443 int nwindows = 0;
27444
27445 while (!NILP (window))
27446 {
27447 struct window *w = XWINDOW (window);
27448
27449 if (WINDOWP (w->contents))
27450 nwindows += redisplay_mode_lines (w->contents, force);
27451 else if (force
27452 || FRAME_GARBAGED_P (XFRAME (w->frame))
27453 || !MATRIX_MODE_LINE_ROW (w->current_matrix)->enabled_p)
27454 {
27455 struct text_pos lpoint;
27456 struct buffer *old = current_buffer;
27457
27458 /* Set the window's buffer for the mode line display. */
27459 SET_TEXT_POS (lpoint, PT, PT_BYTE);
27460 set_buffer_internal_1 (XBUFFER (w->contents));
27461
27462 /* Point refers normally to the selected window. For any
27463 other window, set up appropriate value. */
27464 if (!EQ (window, selected_window))
27465 {
27466 struct text_pos pt;
27467
27468 CLIP_TEXT_POS_FROM_MARKER (pt, w->pointm);
27469 TEMP_SET_PT_BOTH (CHARPOS (pt), BYTEPOS (pt));
27470 }
27471
27472 /* Display mode lines. */
27473 clear_glyph_matrix (w->desired_matrix);
27474 if (display_mode_lines (w))
27475 ++nwindows;
27476
27477 /* Restore old settings. */
27478 set_buffer_internal_1 (old);
27479 TEMP_SET_PT_BOTH (CHARPOS (lpoint), BYTEPOS (lpoint));
27480 }
27481
27482 window = w->next;
27483 }
27484
27485 return nwindows;
27486}
27487
27488
27489/* Display the mode line, the header line, and the tab-line of window 27384/* Display the mode line, the header line, and the tab-line of window
27490 W. Value is the sum number of mode lines, header lines, and tab 27385 W. Value is the sum number of mode lines, header lines, and tab
27491 lines actually displayed. */ 27386 lines actually displayed. */