aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog21
-rw-r--r--src/dispnew.c3
-rw-r--r--src/window.c12
-rw-r--r--src/window.h26
-rw-r--r--src/xdisp.c162
5 files changed, 92 insertions, 132 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cf73204c55c..88df9f13762 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,26 @@
12013-08-14 Dmitry Antipov <dmantipov@yandex.ru> 12013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 * xdisp.c (adjust_window_ends): Move duplicated code to new function.
4 (try_window, try_window_reusing_current_matrix, try_window_id): Use it.
5
62013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
7
8 * window.h (struct window): Convert window_end_pos and
9 window_end_vpos from Lisp_Object to ptrdiff_t and int, respectively.
10 (wset_window_end_pos, wset_window_end_vpos): Remove.
11 * dispnew.c (adjust_glyph_matrix):
12 * window.c (Fwindow_end, replace_window, set_window_buffer)
13 (make_window):
14 * xdisp.c (check_window_end, move_it_to, redisplay_internal)
15 (set_vertical_scroll_bar, redisplay_window, try_window)
16 (try_window_reusing_current_matrix, find_first_unchanged_at_end_row)
17 (try_window_id, decode_mode_spec, mouse_face_from_buffer_pos)
18 (note_mouse_highlight): Adjust users.
19 (try_cursor_movement): Likewise. Convert old precondition to eassert.
20 Add comment.
21
222013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
23
3 Fix --enable-gcc-warnings errors introduced in 2013-08-13 commit. 24 Fix --enable-gcc-warnings errors introduced in 2013-08-13 commit.
4 * image.c (imagemagick_filename_hint): Use `const char *' and 25 * image.c (imagemagick_filename_hint): Use `const char *' and
5 prefer SSDATA to SDATA to avoid warnings. 26 prefer SSDATA to SDATA to avoid warnings.
diff --git a/src/dispnew.c b/src/dispnew.c
index cb38726ba2d..54d7a7461a0 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -600,8 +600,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
600 600
601 /* Window end is invalid, if inside of the rows that 601 /* Window end is invalid, if inside of the rows that
602 are invalidated below. */ 602 are invalidated below. */
603 if (INTEGERP (w->window_end_vpos) 603 if (w->window_end_vpos >= i)
604 && XFASTINT (w->window_end_vpos) >= i)
605 w->window_end_valid = 0; 604 w->window_end_valid = 0;
606 605
607 while (i < matrix->nrows) 606 while (i < matrix->nrows)
diff --git a/src/window.c b/src/window.c
index c61a02aeb01..887c3a92ab7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1542,7 +1542,7 @@ if it isn't already recorded. */)
1542 set_buffer_internal (old_buffer); 1542 set_buffer_internal (old_buffer);
1543 } 1543 }
1544 else 1544 else
1545 XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos)); 1545 XSETINT (value, BUF_Z (b) - w->window_end_pos);
1546 1546
1547 return value; 1547 return value;
1548} 1548}
@@ -2036,8 +2036,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
2036 n->phys_cursor_width = -1; 2036 n->phys_cursor_width = -1;
2037 n->must_be_updated_p = 0; 2037 n->must_be_updated_p = 0;
2038 n->pseudo_window_p = 0; 2038 n->pseudo_window_p = 0;
2039 wset_window_end_vpos (n, make_number (0)); 2039 n->window_end_vpos = 0;
2040 wset_window_end_pos (n, make_number (0)); 2040 n->window_end_pos = 0;
2041 n->window_end_valid = 0; 2041 n->window_end_valid = 0;
2042 } 2042 }
2043 2043
@@ -3173,8 +3173,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
3173 bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); 3173 bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1));
3174 bset_display_time (b, Fcurrent_time ()); 3174 bset_display_time (b, Fcurrent_time ());
3175 3175
3176 wset_window_end_pos (w, make_number (0)); 3176 w->window_end_pos = 0;
3177 wset_window_end_vpos (w, make_number (0)); 3177 w->window_end_vpos = 0;
3178 memset (&w->last_cursor, 0, sizeof w->last_cursor); 3178 memset (&w->last_cursor, 0, sizeof w->last_cursor);
3179 3179
3180 if (!(keep_margins_p && samebuf)) 3180 if (!(keep_margins_p && samebuf))
@@ -3440,8 +3440,6 @@ make_window (void)
3440 wset_start (w, Fmake_marker ()); 3440 wset_start (w, Fmake_marker ());
3441 wset_pointm (w, Fmake_marker ()); 3441 wset_pointm (w, Fmake_marker ());
3442 wset_vertical_scroll_bar_type (w, Qt); 3442 wset_vertical_scroll_bar_type (w, Qt);
3443 wset_window_end_pos (w, make_number (0));
3444 wset_window_end_vpos (w, make_number (0));
3445 /* These Lisp fields are marked specially so they're not set to nil by 3443 /* These Lisp fields are marked specially so they're not set to nil by
3446 allocate_window. */ 3444 allocate_window. */
3447 wset_prev_buffers (w, Qnil); 3445 wset_prev_buffers (w, Qnil);
diff --git a/src/window.h b/src/window.h
index 823fe678c43..585697f0805 100644
--- a/src/window.h
+++ b/src/window.h
@@ -145,14 +145,6 @@ struct window
145 no scroll bar. A value of t means use frame value. */ 145 no scroll bar. A value of t means use frame value. */
146 Lisp_Object vertical_scroll_bar_type; 146 Lisp_Object vertical_scroll_bar_type;
147 147
148 /* Z - the buffer position of the last glyph in the current
149 matrix of W. Only valid if window_end_valid is nonzero. */
150 Lisp_Object window_end_pos;
151
152 /* Glyph matrix row of the last glyph in the current matrix
153 of W. Only valid if window_end_valid is nonzero. */
154 Lisp_Object window_end_vpos;
155
156 /* Display-table to use for displaying chars in this window. 148 /* Display-table to use for displaying chars in this window.
157 Nil means use the buffer's own display-table. */ 149 Nil means use the buffer's own display-table. */
158 Lisp_Object display_table; 150 Lisp_Object display_table;
@@ -269,6 +261,14 @@ struct window
269 A value of -1 means use frame values. */ 261 A value of -1 means use frame values. */
270 int scroll_bar_width; 262 int scroll_bar_width;
271 263
264 /* Z - the buffer position of the last glyph in the current
265 matrix of W. Only valid if window_end_valid is nonzero. */
266 ptrdiff_t window_end_pos;
267
268 /* Glyph matrix row of the last glyph in the current matrix
269 of W. Only valid if window_end_valid is nonzero. */
270 int window_end_vpos;
271
272 /* Non-zero if this window is a minibuffer window. */ 272 /* Non-zero if this window is a minibuffer window. */
273 unsigned mini : 1; 273 unsigned mini : 1;
274 274
@@ -366,16 +366,6 @@ wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
366 w->vertical_scroll_bar = val; 366 w->vertical_scroll_bar = val;
367} 367}
368WINDOW_INLINE void 368WINDOW_INLINE void
369wset_window_end_pos (struct window *w, Lisp_Object val)
370{
371 w->window_end_pos = val;
372}
373WINDOW_INLINE void
374wset_window_end_vpos (struct window *w, Lisp_Object val)
375{
376 w->window_end_vpos = val;
377}
378WINDOW_INLINE void
379wset_prev_buffers (struct window *w, Lisp_Object val) 369wset_prev_buffers (struct window *w, Lisp_Object val)
380{ 370{
381 w->prev_buffers = val; 371 w->prev_buffers = val;
diff --git a/src/xdisp.c b/src/xdisp.c
index 490c1f3440f..b30d9d57578 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2468,7 +2468,16 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
2468 2468
2469#endif /* HAVE_WINDOW_SYSTEM */ 2469#endif /* HAVE_WINDOW_SYSTEM */
2470 2470
2471 2471static void
2472adjust_window_ends (struct window *w, struct glyph_row *row, bool current)
2473{
2474 eassert (w);
2475 w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
2476 w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
2477 w->window_end_vpos
2478 = MATRIX_ROW_VPOS (row, current ? w->current_matrix : w->desired_matrix);
2479}
2480
2472/*********************************************************************** 2481/***********************************************************************
2473 Lisp form evaluation 2482 Lisp form evaluation
2474 ***********************************************************************/ 2483 ***********************************************************************/
@@ -2604,8 +2613,7 @@ check_window_end (struct window *w)
2604 if (!MINI_WINDOW_P (w) && w->window_end_valid) 2613 if (!MINI_WINDOW_P (w) && w->window_end_valid)
2605 { 2614 {
2606 struct glyph_row *row; 2615 struct glyph_row *row;
2607 eassert ((row = MATRIX_ROW (w->current_matrix, 2616 eassert ((row = MATRIX_ROW (w->current_matrix, w->window_end_vpos),
2608 XFASTINT (w->window_end_vpos)),
2609 !row->enabled_p 2617 !row->enabled_p
2610 || MATRIX_ROW_DISPLAYS_TEXT_P (row) 2618 || MATRIX_ROW_DISPLAYS_TEXT_P (row)
2611 || MATRIX_ROW_VPOS (row, w->current_matrix) == 0)); 2619 || MATRIX_ROW_VPOS (row, w->current_matrix) == 0));
@@ -9110,7 +9118,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
9110 && it->current_x == it->last_visible_x - 1 9118 && it->current_x == it->last_visible_x - 1
9111 && it->c != '\n' 9119 && it->c != '\n'
9112 && it->c != '\t' 9120 && it->c != '\t'
9113 && it->vpos < XFASTINT (it->w->window_end_vpos)) 9121 && it->vpos < it->w->window_end_vpos)
9114 { 9122 {
9115 it->continuation_lines_width += it->current_x; 9123 it->continuation_lines_width += it->current_x;
9116 it->current_x = it->hpos = it->max_ascent = it->max_descent = 0; 9124 it->current_x = it->hpos = it->max_ascent = it->max_descent = 0;
@@ -13324,12 +13332,12 @@ redisplay_internal (void)
13324 adjusted. */ 13332 adjusted. */
13325 if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1)) 13333 if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1))
13326 { 13334 {
13327 if (XFASTINT (w->window_end_vpos) < this_line_vpos) 13335 if (w->window_end_vpos < this_line_vpos)
13328 wset_window_end_vpos (w, make_number (this_line_vpos)); 13336 w->window_end_vpos = this_line_vpos;
13329 } 13337 }
13330 else if (XFASTINT (w->window_end_vpos) == this_line_vpos 13338 else if (w->window_end_vpos == this_line_vpos
13331 && this_line_vpos > 0) 13339 && this_line_vpos > 0)
13332 wset_window_end_vpos (w, make_number (this_line_vpos - 1)); 13340 w->window_end_vpos = this_line_vpos - 1;
13333 w->window_end_valid = 0; 13341 w->window_end_valid = 0;
13334 13342
13335 /* Update hint: No need to try to scroll in update_window. */ 13343 /* Update hint: No need to try to scroll in update_window. */
@@ -15019,6 +15027,10 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15019 if-statement below. Now, this field is converted to 15027 if-statement below. Now, this field is converted to
15020 ptrdiff_t, thus zero means invalid position in a buffer. */ 15028 ptrdiff_t, thus zero means invalid position in a buffer. */
15021 eassert (w->last_point > 0); 15029 eassert (w->last_point > 0);
15030 /* Likewise there was a check whether window_end_vpos is nil or larger
15031 than the window. Now window_end_vpos is int and so never nil, but
15032 let's leave eassert to check whether it fits in the window. */
15033 eassert (w->window_end_vpos < w->current_matrix->nrows);
15022 15034
15023 /* Handle case where text has not changed, only point, and it has 15035 /* Handle case where text has not changed, only point, and it has
15024 not moved off the frame. */ 15036 not moved off the frame. */
@@ -15046,13 +15058,6 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
15046 since the handling of this_line_start_pos, etc., in redisplay 15058 since the handling of this_line_start_pos, etc., in redisplay
15047 handles the same cases. */ 15059 handles the same cases. */
15048 && !EQ (window, minibuf_window) 15060 && !EQ (window, minibuf_window)
15049 /* When splitting windows or for new windows, it happens that
15050 redisplay is called with a nil window_end_vpos or one being
15051 larger than the window. This should really be fixed in
15052 window.c. I don't have this on my list, now, so we do
15053 approximately the same as the old redisplay code. --gerd. */
15054 && INTEGERP (w->window_end_vpos)
15055 && XFASTINT (w->window_end_vpos) < w->current_matrix->nrows
15056 && (FRAME_WINDOW_P (f) 15061 && (FRAME_WINDOW_P (f)
15057 || !overlay_arrow_in_current_buffer_p ())) 15062 || !overlay_arrow_in_current_buffer_p ()))
15058 { 15063 {
@@ -15366,7 +15371,7 @@ set_vertical_scroll_bar (struct window *w)
15366 start = marker_position (w->start) - BUF_BEGV (buf); 15371 start = marker_position (w->start) - BUF_BEGV (buf);
15367 /* I don't think this is guaranteed to be right. For the 15372 /* I don't think this is guaranteed to be right. For the
15368 moment, we'll pretend it is. */ 15373 moment, we'll pretend it is. */
15369 end = BUF_Z (buf) - XFASTINT (w->window_end_pos) - BUF_BEGV (buf); 15374 end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf);
15370 15375
15371 if (end < start) 15376 if (end < start)
15372 end = start; 15377 end = start;
@@ -16056,7 +16061,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
16056 line.) */ 16061 line.) */
16057 if (w->cursor.vpos < 0) 16062 if (w->cursor.vpos < 0)
16058 { 16063 {
16059 if (w->window_end_valid && PT >= Z - XFASTINT (w->window_end_pos)) 16064 if (w->window_end_valid && PT >= Z - w->window_end_pos)
16060 { 16065 {
16061 clear_glyph_matrix (w->desired_matrix); 16066 clear_glyph_matrix (w->desired_matrix);
16062 move_it_by_lines (&it, 1); 16067 move_it_by_lines (&it, 1);
@@ -16356,8 +16361,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16356 } 16361 }
16357 16362
16358 /* If bottom moved off end of frame, change mode line percentage. */ 16363 /* If bottom moved off end of frame, change mode line percentage. */
16359 if (XFASTINT (w->window_end_pos) <= 0 16364 if (w->window_end_pos <= 0 && Z != IT_CHARPOS (it))
16360 && Z != IT_CHARPOS (it))
16361 w->update_mode_line = 1; 16365 w->update_mode_line = 1;
16362 16366
16363 /* Set window_end_pos to the offset of the last character displayed 16367 /* Set window_end_pos to the offset of the last character displayed
@@ -16366,21 +16370,16 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
16366 if (last_text_row) 16370 if (last_text_row)
16367 { 16371 {
16368 eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row)); 16372 eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row));
16369 w->window_end_bytepos 16373 adjust_window_ends (w, last_text_row, 0);
16370 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
16371 wset_window_end_pos
16372 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row)));
16373 wset_window_end_vpos
16374 (w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix)));
16375 eassert 16374 eassert
16376 (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix, 16375 (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
16377 XFASTINT (w->window_end_vpos)))); 16376 w->window_end_vpos)));
16378 } 16377 }
16379 else 16378 else
16380 { 16379 {
16381 w->window_end_bytepos = Z_BYTE - ZV_BYTE; 16380 w->window_end_bytepos = Z_BYTE - ZV_BYTE;
16382 wset_window_end_pos (w, make_number (Z - ZV)); 16381 w->window_end_pos = Z - ZV;
16383 wset_window_end_vpos (w, make_number (0)); 16382 w->window_end_vpos = 0;
16384 } 16383 }
16385 16384
16386 /* But that is not valid info until redisplay finishes. */ 16385 /* But that is not valid info until redisplay finishes. */
@@ -16611,32 +16610,15 @@ try_window_reusing_current_matrix (struct window *w)
16611 The value of last_text_row is the last displayed line 16610 The value of last_text_row is the last displayed line
16612 containing text. */ 16611 containing text. */
16613 if (last_reused_text_row) 16612 if (last_reused_text_row)
16614 { 16613 adjust_window_ends (w, last_reused_text_row, 1);
16615 w->window_end_bytepos
16616 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row);
16617 wset_window_end_pos
16618 (w, make_number (Z
16619 - MATRIX_ROW_END_CHARPOS (last_reused_text_row)));
16620 wset_window_end_vpos
16621 (w, make_number (MATRIX_ROW_VPOS (last_reused_text_row,
16622 w->current_matrix)));
16623 }
16624 else if (last_text_row) 16614 else if (last_text_row)
16625 { 16615 adjust_window_ends (w, last_text_row, 0);
16626 w->window_end_bytepos
16627 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
16628 wset_window_end_pos
16629 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row)));
16630 wset_window_end_vpos
16631 (w, make_number (MATRIX_ROW_VPOS (last_text_row,
16632 w->desired_matrix)));
16633 }
16634 else 16616 else
16635 { 16617 {
16636 /* This window must be completely empty. */ 16618 /* This window must be completely empty. */
16637 w->window_end_bytepos = Z_BYTE - ZV_BYTE; 16619 w->window_end_bytepos = Z_BYTE - ZV_BYTE;
16638 wset_window_end_pos (w, make_number (Z - ZV)); 16620 w->window_end_pos = Z - ZV;
16639 wset_window_end_vpos (w, make_number (0)); 16621 w->window_end_vpos = 0;
16640 } 16622 }
16641 w->window_end_valid = 0; 16623 w->window_end_valid = 0;
16642 16624
@@ -16821,20 +16803,9 @@ try_window_reusing_current_matrix (struct window *w)
16821 the window end is in reused rows which in turn means that 16803 the window end is in reused rows which in turn means that
16822 only its vpos can have changed. */ 16804 only its vpos can have changed. */
16823 if (last_text_row) 16805 if (last_text_row)
16824 { 16806 adjust_window_ends (w, last_text_row, 0);
16825 w->window_end_bytepos
16826 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
16827 wset_window_end_pos
16828 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row)));
16829 wset_window_end_vpos
16830 (w, make_number (MATRIX_ROW_VPOS (last_text_row,
16831 w->desired_matrix)));
16832 }
16833 else 16807 else
16834 { 16808 w->window_end_vpos -= nrows_scrolled;
16835 wset_window_end_vpos
16836 (w, make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled));
16837 }
16838 16809
16839 w->window_end_valid = 0; 16810 w->window_end_valid = 0;
16840 w->desired_matrix->no_scrolling_p = 1; 16811 w->desired_matrix->no_scrolling_p = 1;
@@ -16974,11 +16945,11 @@ find_first_unchanged_at_end_row (struct window *w,
16974 /* A value of window_end_pos >= END_UNCHANGED means that the window 16945 /* A value of window_end_pos >= END_UNCHANGED means that the window
16975 end is in the range of changed text. If so, there is no 16946 end is in the range of changed text. If so, there is no
16976 unchanged row at the end of W's current matrix. */ 16947 unchanged row at the end of W's current matrix. */
16977 if (XFASTINT (w->window_end_pos) >= END_UNCHANGED) 16948 if (w->window_end_pos >= END_UNCHANGED)
16978 return NULL; 16949 return NULL;
16979 16950
16980 /* Set row to the last row in W's current matrix displaying text. */ 16951 /* Set row to the last row in W's current matrix displaying text. */
16981 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 16952 row = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
16982 16953
16983 /* If matrix is entirely empty, no unchanged row exists. */ 16954 /* If matrix is entirely empty, no unchanged row exists. */
16984 if (MATRIX_ROW_DISPLAYS_TEXT_P (row)) 16955 if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
@@ -16989,7 +16960,7 @@ find_first_unchanged_at_end_row (struct window *w,
16989 buffer positions in the current matrix to current buffer 16960 buffer positions in the current matrix to current buffer
16990 positions for characters not in changed text. */ 16961 positions for characters not in changed text. */
16991 ptrdiff_t Z_old = 16962 ptrdiff_t Z_old =
16992 MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); 16963 MATRIX_ROW_END_CHARPOS (row) + w->window_end_pos;
16993 ptrdiff_t Z_BYTE_old = 16964 ptrdiff_t Z_BYTE_old =
16994 MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; 16965 MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
16995 ptrdiff_t last_unchanged_pos, last_unchanged_pos_old; 16966 ptrdiff_t last_unchanged_pos, last_unchanged_pos_old;
@@ -17330,7 +17301,7 @@ try_window_id (struct window *w)
17330 This case happens with stealth-fontification. Note that although 17301 This case happens with stealth-fontification. Note that although
17331 the display is unchanged, glyph positions in the matrix have to 17302 the display is unchanged, glyph positions in the matrix have to
17332 be adjusted, of course. */ 17303 be adjusted, of course. */
17333 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 17304 row = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
17334 if (MATRIX_ROW_DISPLAYS_TEXT_P (row) 17305 if (MATRIX_ROW_DISPLAYS_TEXT_P (row)
17335 && ((last_changed_charpos < CHARPOS (start) 17306 && ((last_changed_charpos < CHARPOS (start)
17336 && CHARPOS (start) == BEGV) 17307 && CHARPOS (start) == BEGV)
@@ -17342,7 +17313,7 @@ try_window_id (struct window *w)
17342 17313
17343 /* Compute how many chars/bytes have been added to or removed 17314 /* Compute how many chars/bytes have been added to or removed
17344 from the buffer. */ 17315 from the buffer. */
17345 Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); 17316 Z_old = MATRIX_ROW_END_CHARPOS (row) + w->window_end_pos;
17346 Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; 17317 Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
17347 Z_delta = Z - Z_old; 17318 Z_delta = Z - Z_old;
17348 Z_delta_bytes = Z_BYTE - Z_BYTE_old; 17319 Z_delta_bytes = Z_BYTE - Z_BYTE_old;
@@ -17413,10 +17384,8 @@ try_window_id (struct window *w)
17413 { 17384 {
17414 /* We have to compute the window end anew since text 17385 /* We have to compute the window end anew since text
17415 could have been added/removed after it. */ 17386 could have been added/removed after it. */
17416 wset_window_end_pos 17387 w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
17417 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); 17388 w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
17418 w->window_end_bytepos
17419 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
17420 17389
17421 /* Set the cursor. */ 17390 /* Set the cursor. */
17422 row = row_containing_pos (w, PT, r0, NULL, 0); 17391 row = row_containing_pos (w, PT, r0, NULL, 0);
@@ -17449,7 +17418,7 @@ try_window_id (struct window *w)
17449 17418
17450 /* Give up if the window ends in strings. Overlay strings 17419 /* Give up if the window ends in strings. Overlay strings
17451 at the end are difficult to handle, so don't try. */ 17420 at the end are difficult to handle, so don't try. */
17452 row = MATRIX_ROW (current_matrix, XFASTINT (w->window_end_vpos)); 17421 row = MATRIX_ROW (current_matrix, w->window_end_vpos);
17453 if (MATRIX_ROW_START_CHARPOS (row) == MATRIX_ROW_END_CHARPOS (row)) 17422 if (MATRIX_ROW_START_CHARPOS (row) == MATRIX_ROW_END_CHARPOS (row))
17454 GIVE_UP (20); 17423 GIVE_UP (20);
17455 17424
@@ -17795,7 +17764,7 @@ try_window_id (struct window *w)
17795 /* Set last_row to the glyph row in the current matrix where the 17764 /* Set last_row to the glyph row in the current matrix where the
17796 window end line is found. It has been moved up or down in 17765 window end line is found. It has been moved up or down in
17797 the matrix by dvpos. */ 17766 the matrix by dvpos. */
17798 int last_vpos = XFASTINT (w->window_end_vpos) + dvpos; 17767 int last_vpos = w->window_end_vpos + dvpos;
17799 struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos); 17768 struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos);
17800 17769
17801 /* If last_row is the window end line, it should display text. */ 17770 /* If last_row is the window end line, it should display text. */
@@ -17839,8 +17808,7 @@ try_window_id (struct window *w)
17839 } 17808 }
17840 17809
17841 /* Update window_end_pos and window_end_vpos. */ 17810 /* Update window_end_pos and window_end_vpos. */
17842 if (first_unchanged_at_end_row 17811 if (first_unchanged_at_end_row && !last_text_row_at_end)
17843 && !last_text_row_at_end)
17844 { 17812 {
17845 /* Window end line if one of the preserved rows from the current 17813 /* Window end line if one of the preserved rows from the current
17846 matrix. Set row to the last row displaying text in current 17814 matrix. Set row to the last row displaying text in current
@@ -17850,23 +17818,13 @@ try_window_id (struct window *w)
17850 row = find_last_row_displaying_text (w->current_matrix, &it, 17818 row = find_last_row_displaying_text (w->current_matrix, &it,
17851 first_unchanged_at_end_row); 17819 first_unchanged_at_end_row);
17852 eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row)); 17820 eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
17853 17821 adjust_window_ends (w, row, 1);
17854 wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row)));
17855 w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
17856 wset_window_end_vpos
17857 (w, make_number (MATRIX_ROW_VPOS (row, w->current_matrix)));
17858 eassert (w->window_end_bytepos >= 0); 17822 eassert (w->window_end_bytepos >= 0);
17859 IF_DEBUG (debug_method_add (w, "A")); 17823 IF_DEBUG (debug_method_add (w, "A"));
17860 } 17824 }
17861 else if (last_text_row_at_end) 17825 else if (last_text_row_at_end)
17862 { 17826 {
17863 wset_window_end_pos 17827 adjust_window_ends (w, last_text_row_at_end, 0);
17864 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end)));
17865 w->window_end_bytepos
17866 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end);
17867 wset_window_end_vpos
17868 (w, make_number (MATRIX_ROW_VPOS (last_text_row_at_end,
17869 desired_matrix)));
17870 eassert (w->window_end_bytepos >= 0); 17828 eassert (w->window_end_bytepos >= 0);
17871 IF_DEBUG (debug_method_add (w, "B")); 17829 IF_DEBUG (debug_method_add (w, "B"));
17872 } 17830 }
@@ -17875,12 +17833,7 @@ try_window_id (struct window *w)
17875 /* We have displayed either to the end of the window or at the 17833 /* We have displayed either to the end of the window or at the
17876 end of the window, i.e. the last row with text is to be found 17834 end of the window, i.e. the last row with text is to be found
17877 in the desired matrix. */ 17835 in the desired matrix. */
17878 wset_window_end_pos 17836 adjust_window_ends (w, last_text_row, 0);
17879 (w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row)));
17880 w->window_end_bytepos
17881 = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
17882 wset_window_end_vpos
17883 (w, make_number (MATRIX_ROW_VPOS (last_text_row, desired_matrix)));
17884 eassert (w->window_end_bytepos >= 0); 17837 eassert (w->window_end_bytepos >= 0);
17885 } 17838 }
17886 else if (first_unchanged_at_end_row == NULL 17839 else if (first_unchanged_at_end_row == NULL
@@ -17890,7 +17843,7 @@ try_window_id (struct window *w)
17890 /* Displayed to end of window, but no line containing text was 17843 /* Displayed to end of window, but no line containing text was
17891 displayed. Lines were deleted at the end of the window. */ 17844 displayed. Lines were deleted at the end of the window. */
17892 int first_vpos = WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; 17845 int first_vpos = WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0;
17893 int vpos = XFASTINT (w->window_end_vpos); 17846 int vpos = w->window_end_vpos;
17894 struct glyph_row *current_row = current_matrix->rows + vpos; 17847 struct glyph_row *current_row = current_matrix->rows + vpos;
17895 struct glyph_row *desired_row = desired_matrix->rows + vpos; 17848 struct glyph_row *desired_row = desired_matrix->rows + vpos;
17896 17849
@@ -17908,8 +17861,8 @@ try_window_id (struct window *w)
17908 } 17861 }
17909 17862
17910 eassert (row != NULL); 17863 eassert (row != NULL);
17911 wset_window_end_vpos (w, make_number (vpos + 1)); 17864 w->window_end_vpos = vpos + 1;
17912 wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); 17865 w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
17913 w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); 17866 w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
17914 eassert (w->window_end_bytepos >= 0); 17867 eassert (w->window_end_bytepos >= 0);
17915 IF_DEBUG (debug_method_add (w, "C")); 17868 IF_DEBUG (debug_method_add (w, "C"));
@@ -17917,8 +17870,8 @@ try_window_id (struct window *w)
17917 else 17870 else
17918 emacs_abort (); 17871 emacs_abort ();
17919 17872
17920 IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos); 17873 IF_DEBUG (debug_end_pos = w->window_end_pos;
17921 debug_end_vpos = XFASTINT (w->window_end_vpos)); 17874 debug_end_vpos = w->window_end_vpos);
17922 17875
17923 /* Record that display has not been completed. */ 17876 /* Record that display has not been completed. */
17924 w->window_end_valid = 0; 17877 w->window_end_valid = 0;
@@ -22109,7 +22062,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
22109 ptrdiff_t pos = marker_position (w->start); 22062 ptrdiff_t pos = marker_position (w->start);
22110 ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b); 22063 ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b);
22111 22064
22112 if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b)) 22065 if (w->window_end_pos <= BUF_Z (b) - BUF_ZV (b))
22113 { 22066 {
22114 if (pos <= BUF_BEGV (b)) 22067 if (pos <= BUF_BEGV (b))
22115 return "All"; 22068 return "All";
@@ -22138,7 +22091,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
22138 case 'P': 22091 case 'P':
22139 { 22092 {
22140 ptrdiff_t toppos = marker_position (w->start); 22093 ptrdiff_t toppos = marker_position (w->start);
22141 ptrdiff_t botpos = BUF_Z (b) - XFASTINT (w->window_end_pos); 22094 ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
22142 ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b); 22095 ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b);
22143 22096
22144 if (botpos >= BUF_ZV (b)) 22097 if (botpos >= BUF_ZV (b))
@@ -27294,7 +27247,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
27294 /* Find the rows corresponding to START_CHARPOS and END_CHARPOS. */ 27247 /* Find the rows corresponding to START_CHARPOS and END_CHARPOS. */
27295 rows_from_pos_range (w, start_charpos, end_charpos, disp_string, &r1, &r2); 27248 rows_from_pos_range (w, start_charpos, end_charpos, disp_string, &r1, &r2);
27296 if (r1 == NULL) 27249 if (r1 == NULL)
27297 r1 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 27250 r1 = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
27298 /* If the before-string or display-string contains newlines, 27251 /* If the before-string or display-string contains newlines,
27299 rows_from_pos_range skips to its last row. Move back. */ 27252 rows_from_pos_range skips to its last row. Move back. */
27300 if (!NILP (before_string) || !NILP (disp_string)) 27253 if (!NILP (before_string) || !NILP (disp_string))
@@ -27316,7 +27269,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
27316 } 27269 }
27317 if (r2 == NULL) 27270 if (r2 == NULL)
27318 { 27271 {
27319 r2 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 27272 r2 = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
27320 hlinfo->mouse_face_past_end = 1; 27273 hlinfo->mouse_face_past_end = 1;
27321 } 27274 }
27322 else if (!NILP (after_string)) 27275 else if (!NILP (after_string))
@@ -27324,7 +27277,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
27324 /* If the after-string has newlines, advance to its last row. */ 27277 /* If the after-string has newlines, advance to its last row. */
27325 struct glyph_row *next; 27278 struct glyph_row *next;
27326 struct glyph_row *last 27279 struct glyph_row *last
27327 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 27280 = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
27328 27281
27329 for (next = r2 + 1; 27282 for (next = r2 + 1;
27330 next <= last 27283 next <= last
@@ -28630,8 +28583,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
28630 : Qnil; 28583 : Qnil;
28631 Lisp_Object lim2 = 28584 Lisp_Object lim2 =
28632 NILP (BVAR (XBUFFER (buffer), bidi_display_reordering)) 28585 NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
28633 ? make_number (BUF_Z (XBUFFER (buffer)) 28586 ? make_number (BUF_Z (XBUFFER (buffer)) - w->window_end_pos)
28634 - XFASTINT (w->window_end_pos))
28635 : Qnil; 28587 : Qnil;
28636 28588
28637 if (NILP (overlay)) 28589 if (NILP (overlay))