Commit 02455cb6 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* window.h (struct window): Convert window_end_pos and

window_end_vpos from Lisp_Object to ptrdiff_t and int, respectively.
(wset_window_end_pos, wset_window_end_vpos): Remove.
* dispnew.c (adjust_glyph_matrix):
* window.c (Fwindow_end, replace_window, set_window_buffer)
(make_window):
* xdisp.c (check_window_end, move_it_to, redisplay_internal)
(set_vertical_scroll_bar, redisplay_window, try_window)
(try_window_reusing_current_matrix, find_first_unchanged_at_end_row)
(try_window_id, decode_mode_spec, mouse_face_from_buffer_pos)
(note_mouse_highlight): Adjust users.
(try_cursor_movement): Likewise.  Convert old precondition to eassert.
Add comment.
parent da5707e8
2013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
* window.h (struct window): Convert window_end_pos and
window_end_vpos from Lisp_Object to ptrdiff_t and int, respectively.
(wset_window_end_pos, wset_window_end_vpos): Remove.
* dispnew.c (adjust_glyph_matrix):
* window.c (Fwindow_end, replace_window, set_window_buffer)
(make_window):
* xdisp.c (check_window_end, move_it_to, redisplay_internal)
(set_vertical_scroll_bar, redisplay_window, try_window)
(try_window_reusing_current_matrix, find_first_unchanged_at_end_row)
(try_window_id, decode_mode_spec, mouse_face_from_buffer_pos)
(note_mouse_highlight): Adjust users.
(try_cursor_movement): Likewise. Convert old precondition to eassert.
Add comment.
2013-08-14 Dmitry Antipov <dmantipov@yandex.ru> 2013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
Fix --enable-gcc-warnings errors introduced in 2013-08-13 commit. Fix --enable-gcc-warnings errors introduced in 2013-08-13 commit.
......
...@@ -598,8 +598,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y ...@@ -598,8 +598,7 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
/* Window end is invalid, if inside of the rows that /* Window end is invalid, if inside of the rows that
are invalidated below. */ are invalidated below. */
if (INTEGERP (w->window_end_vpos) if (w->window_end_vpos >= i)
&& XFASTINT (w->window_end_vpos) >= i)
w->window_end_valid = 0; w->window_end_valid = 0;
while (i < matrix->nrows) while (i < matrix->nrows)
......
...@@ -1539,7 +1539,7 @@ if it isn't already recorded. */) ...@@ -1539,7 +1539,7 @@ if it isn't already recorded. */)
set_buffer_internal (old_buffer); set_buffer_internal (old_buffer);
} }
else else
XSETINT (value, BUF_Z (b) - XFASTINT (w->window_end_pos)); XSETINT (value, BUF_Z (b) - w->window_end_pos);
return value; return value;
} }
...@@ -2033,8 +2033,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag) ...@@ -2033,8 +2033,8 @@ replace_window (Lisp_Object old, Lisp_Object new, int setflag)
n->phys_cursor_width = -1; n->phys_cursor_width = -1;
n->must_be_updated_p = 0; n->must_be_updated_p = 0;
n->pseudo_window_p = 0; n->pseudo_window_p = 0;
wset_window_end_vpos (n, make_number (0)); n->window_end_vpos = 0;
wset_window_end_pos (n, make_number (0)); n->window_end_pos = 0;
n->window_end_valid = 0; n->window_end_valid = 0;
} }
...@@ -3170,8 +3170,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, ...@@ -3170,8 +3170,8 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1)); bset_display_count (b, make_number (XINT (BVAR (b, display_count)) + 1));
bset_display_time (b, Fcurrent_time ()); bset_display_time (b, Fcurrent_time ());
wset_window_end_pos (w, make_number (0)); w->window_end_pos = 0;
wset_window_end_vpos (w, make_number (0)); w->window_end_vpos = 0;
memset (&w->last_cursor, 0, sizeof w->last_cursor); memset (&w->last_cursor, 0, sizeof w->last_cursor);
if (!(keep_margins_p && samebuf)) if (!(keep_margins_p && samebuf))
...@@ -3437,8 +3437,6 @@ make_window (void) ...@@ -3437,8 +3437,6 @@ make_window (void)
wset_start (w, Fmake_marker ()); wset_start (w, Fmake_marker ());
wset_pointm (w, Fmake_marker ()); wset_pointm (w, Fmake_marker ());
wset_vertical_scroll_bar_type (w, Qt); wset_vertical_scroll_bar_type (w, Qt);
wset_window_end_pos (w, make_number (0));
wset_window_end_vpos (w, make_number (0));
/* These Lisp fields are marked specially so they're not set to nil by /* These Lisp fields are marked specially so they're not set to nil by
allocate_window. */ allocate_window. */
wset_prev_buffers (w, Qnil); wset_prev_buffers (w, Qnil);
......
...@@ -145,14 +145,6 @@ struct window ...@@ -145,14 +145,6 @@ struct window
no scroll bar. A value of t means use frame value. */ no scroll bar. A value of t means use frame value. */
Lisp_Object vertical_scroll_bar_type; Lisp_Object vertical_scroll_bar_type;
/* Z - the buffer position of the last glyph in the current
matrix of W. Only valid if window_end_valid is nonzero. */
Lisp_Object window_end_pos;
/* Glyph matrix row of the last glyph in the current matrix
of W. Only valid if window_end_valid is nonzero. */
Lisp_Object window_end_vpos;
/* Display-table to use for displaying chars in this window. /* Display-table to use for displaying chars in this window.
Nil means use the buffer's own display-table. */ Nil means use the buffer's own display-table. */
Lisp_Object display_table; Lisp_Object display_table;
...@@ -269,6 +261,14 @@ struct window ...@@ -269,6 +261,14 @@ struct window
A value of -1 means use frame values. */ A value of -1 means use frame values. */
int scroll_bar_width; int scroll_bar_width;
/* Z - the buffer position of the last glyph in the current
matrix of W. Only valid if window_end_valid is nonzero. */
ptrdiff_t window_end_pos;
/* Glyph matrix row of the last glyph in the current matrix
of W. Only valid if window_end_valid is nonzero. */
int window_end_vpos;
/* Non-zero if this window is a minibuffer window. */ /* Non-zero if this window is a minibuffer window. */
unsigned mini : 1; unsigned mini : 1;
...@@ -366,16 +366,6 @@ wset_vertical_scroll_bar (struct window *w, Lisp_Object val) ...@@ -366,16 +366,6 @@ wset_vertical_scroll_bar (struct window *w, Lisp_Object val)
w->vertical_scroll_bar = val; w->vertical_scroll_bar = val;
} }
WINDOW_INLINE void WINDOW_INLINE void
wset_window_end_pos (struct window *w, Lisp_Object val)
{
w->window_end_pos = val;
}
WINDOW_INLINE void
wset_window_end_vpos (struct window *w, Lisp_Object val)
{
w->window_end_vpos = val;
}
WINDOW_INLINE void
wset_prev_buffers (struct window *w, Lisp_Object val) wset_prev_buffers (struct window *w, Lisp_Object val)
{ {
w->prev_buffers = val; w->prev_buffers = val;
......
...@@ -2597,8 +2597,7 @@ check_window_end (struct window *w) ...@@ -2597,8 +2597,7 @@ check_window_end (struct window *w)
if (!MINI_WINDOW_P (w) && w->window_end_valid) if (!MINI_WINDOW_P (w) && w->window_end_valid)
{ {
struct glyph_row *row; struct glyph_row *row;
eassert ((row = MATRIX_ROW (w->current_matrix, eassert ((row = MATRIX_ROW (w->current_matrix, w->window_end_vpos),
XFASTINT (w->window_end_vpos)),
!row->enabled_p !row->enabled_p
|| MATRIX_ROW_DISPLAYS_TEXT_P (row) || MATRIX_ROW_DISPLAYS_TEXT_P (row)
|| MATRIX_ROW_VPOS (row, w->current_matrix) == 0)); || MATRIX_ROW_VPOS (row, w->current_matrix) == 0));
...@@ -9054,7 +9053,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos ...@@ -9054,7 +9053,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int to_x, int to_y, int to_vpos
&& it->current_x == it->last_visible_x - 1 && it->current_x == it->last_visible_x - 1
&& it->c != '\n' && it->c != '\n'
&& it->c != '\t' && it->c != '\t'
&& it->vpos < XFASTINT (it->w->window_end_vpos)) && it->vpos < it->w->window_end_vpos)
{ {
it->continuation_lines_width += it->current_x; it->continuation_lines_width += it->current_x;
it->current_x = it->hpos = it->max_ascent = it->max_descent = 0; it->current_x = it->hpos = it->max_ascent = it->max_descent = 0;
...@@ -13268,12 +13267,12 @@ redisplay_internal (void) ...@@ -13268,12 +13267,12 @@ redisplay_internal (void)
adjusted. */ adjusted. */
if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1)) if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1))
{ {
if (XFASTINT (w->window_end_vpos) < this_line_vpos) if (w->window_end_vpos < this_line_vpos)
wset_window_end_vpos (w, make_number (this_line_vpos)); w->window_end_vpos = this_line_vpos;
} }
else if (XFASTINT (w->window_end_vpos) == this_line_vpos else if (w->window_end_vpos == this_line_vpos
&& this_line_vpos > 0) && this_line_vpos > 0)
wset_window_end_vpos (w, make_number (this_line_vpos - 1)); w->window_end_vpos = this_line_vpos - 1;
w->window_end_valid = 0; w->window_end_valid = 0;
   
/* Update hint: No need to try to scroll in update_window. */ /* Update hint: No need to try to scroll in update_window. */
...@@ -14956,6 +14955,10 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste ...@@ -14956,6 +14955,10 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
if-statement below. Now, this field is converted to if-statement below. Now, this field is converted to
ptrdiff_t, thus zero means invalid position in a buffer. */ ptrdiff_t, thus zero means invalid position in a buffer. */
eassert (w->last_point > 0); eassert (w->last_point > 0);
/* Likewise there was a check whether window_end_vpos is nil or larger
than the window. Now window_end_vpos is int and so never nil, but
let's leave eassert to check whether it fits in the window. */
eassert (w->window_end_vpos < w->current_matrix->nrows);
   
/* Handle case where text has not changed, only point, and it has /* Handle case where text has not changed, only point, and it has
not moved off the frame. */ not moved off the frame. */
...@@ -14983,13 +14986,6 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste ...@@ -14983,13 +14986,6 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, int *scroll_ste
since the handling of this_line_start_pos, etc., in redisplay since the handling of this_line_start_pos, etc., in redisplay
handles the same cases. */ handles the same cases. */
&& !EQ (window, minibuf_window) && !EQ (window, minibuf_window)
/* When splitting windows or for new windows, it happens that
redisplay is called with a nil window_end_vpos or one being
larger than the window. This should really be fixed in
window.c. I don't have this on my list, now, so we do
approximately the same as the old redisplay code. --gerd. */
&& INTEGERP (w->window_end_vpos)
&& XFASTINT (w->window_end_vpos) < w->current_matrix->nrows
&& (FRAME_WINDOW_P (f) && (FRAME_WINDOW_P (f)
|| !overlay_arrow_in_current_buffer_p ())) || !overlay_arrow_in_current_buffer_p ()))
{ {
...@@ -15303,7 +15299,7 @@ set_vertical_scroll_bar (struct window *w) ...@@ -15303,7 +15299,7 @@ set_vertical_scroll_bar (struct window *w)
start = marker_position (w->start) - BUF_BEGV (buf); start = marker_position (w->start) - BUF_BEGV (buf);
/* I don't think this is guaranteed to be right. For the /* I don't think this is guaranteed to be right. For the
moment, we'll pretend it is. */ moment, we'll pretend it is. */
end = BUF_Z (buf) - XFASTINT (w->window_end_pos) - BUF_BEGV (buf); end = BUF_Z (buf) - w->window_end_pos - BUF_BEGV (buf);
   
if (end < start) if (end < start)
end = start; end = start;
...@@ -15993,7 +15989,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) ...@@ -15993,7 +15989,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
line.) */ line.) */
if (w->cursor.vpos < 0) if (w->cursor.vpos < 0)
{ {
if (w->window_end_valid && PT >= Z - XFASTINT (w->window_end_pos)) if (w->window_end_valid && PT >= Z - w->window_end_pos)
{ {
clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->desired_matrix);
move_it_by_lines (&it, 1); move_it_by_lines (&it, 1);
...@@ -16286,8 +16282,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) ...@@ -16286,8 +16282,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
} }
   
/* If bottom moved off end of frame, change mode line percentage. */ /* If bottom moved off end of frame, change mode line percentage. */
if (XFASTINT (w->window_end_pos) <= 0 if (w->window_end_pos <= 0 && Z != IT_CHARPOS (it))
&& Z != IT_CHARPOS (it))
w->update_mode_line = 1; w->update_mode_line = 1;
   
/* Set window_end_pos to the offset of the last character displayed /* Set window_end_pos to the offset of the last character displayed
...@@ -16296,21 +16291,18 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) ...@@ -16296,21 +16291,18 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
if (last_text_row) if (last_text_row)
{ {
eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row)); eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row));
w->window_end_bytepos w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
wset_window_end_pos w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row)));
wset_window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix)));
eassert eassert
(MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix, (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
XFASTINT (w->window_end_vpos)))); w->window_end_vpos)));
} }
else else
{ {
w->window_end_bytepos = Z_BYTE - ZV_BYTE; w->window_end_bytepos = Z_BYTE - ZV_BYTE;
wset_window_end_pos (w, make_number (Z - ZV)); w->window_end_pos = Z - ZV;
wset_window_end_vpos (w, make_number (0)); w->window_end_vpos = 0;
} }
   
/* But that is not valid info until redisplay finishes. */ /* But that is not valid info until redisplay finishes. */
...@@ -16537,29 +16529,26 @@ try_window_reusing_current_matrix (struct window *w) ...@@ -16537,29 +16529,26 @@ try_window_reusing_current_matrix (struct window *w)
{ {
w->window_end_bytepos w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row); = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row);
wset_window_end_pos w->window_end_pos
(w, make_number (Z = Z - MATRIX_ROW_END_CHARPOS (last_reused_text_row);
- MATRIX_ROW_END_CHARPOS (last_reused_text_row))); w->window_end_vpos
wset_window_end_vpos = MATRIX_ROW_VPOS (last_reused_text_row, w->current_matrix);
(w, make_number (MATRIX_ROW_VPOS (last_reused_text_row,
w->current_matrix)));
} }
else if (last_text_row) else if (last_text_row)
{ {
w->window_end_bytepos w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
wset_window_end_pos w->window_end_pos
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
wset_window_end_vpos w->window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row, = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
w->desired_matrix)));
} }
else else
{ {
/* This window must be completely empty. */ /* This window must be completely empty. */
w->window_end_bytepos = Z_BYTE - ZV_BYTE; w->window_end_bytepos = Z_BYTE - ZV_BYTE;
wset_window_end_pos (w, make_number (Z - ZV)); w->window_end_pos = Z - ZV;
wset_window_end_vpos (w, make_number (0)); w->window_end_vpos = 0;
} }
w->window_end_valid = 0; w->window_end_valid = 0;
   
...@@ -16747,17 +16736,13 @@ try_window_reusing_current_matrix (struct window *w) ...@@ -16747,17 +16736,13 @@ try_window_reusing_current_matrix (struct window *w)
{ {
w->window_end_bytepos w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
wset_window_end_pos w->window_end_pos
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
wset_window_end_vpos w->window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row, = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
w->desired_matrix)));
} }
else else
{ w->window_end_vpos -= nrows_scrolled;
wset_window_end_vpos
(w, make_number (XFASTINT (w->window_end_vpos) - nrows_scrolled));
}
   
w->window_end_valid = 0; w->window_end_valid = 0;
w->desired_matrix->no_scrolling_p = 1; w->desired_matrix->no_scrolling_p = 1;
...@@ -16897,11 +16882,11 @@ find_first_unchanged_at_end_row (struct window *w, ...@@ -16897,11 +16882,11 @@ find_first_unchanged_at_end_row (struct window *w,
/* A value of window_end_pos >= END_UNCHANGED means that the window /* A value of window_end_pos >= END_UNCHANGED means that the window
end is in the range of changed text. If so, there is no end is in the range of changed text. If so, there is no
unchanged row at the end of W's current matrix. */ unchanged row at the end of W's current matrix. */
if (XFASTINT (w->window_end_pos) >= END_UNCHANGED) if (w->window_end_pos >= END_UNCHANGED)
return NULL; return NULL;
   
/* Set row to the last row in W's current matrix displaying text. */ /* Set row to the last row in W's current matrix displaying text. */
row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); row = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
   
/* If matrix is entirely empty, no unchanged row exists. */ /* If matrix is entirely empty, no unchanged row exists. */
if (MATRIX_ROW_DISPLAYS_TEXT_P (row)) if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
...@@ -16912,7 +16897,7 @@ find_first_unchanged_at_end_row (struct window *w, ...@@ -16912,7 +16897,7 @@ find_first_unchanged_at_end_row (struct window *w,
buffer positions in the current matrix to current buffer buffer positions in the current matrix to current buffer
positions for characters not in changed text. */ positions for characters not in changed text. */
ptrdiff_t Z_old = ptrdiff_t Z_old =
MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); MATRIX_ROW_END_CHARPOS (row) + w->window_end_pos;
ptrdiff_t Z_BYTE_old = ptrdiff_t Z_BYTE_old =
MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
ptrdiff_t last_unchanged_pos, last_unchanged_pos_old; ptrdiff_t last_unchanged_pos, last_unchanged_pos_old;
...@@ -17246,7 +17231,7 @@ try_window_id (struct window *w) ...@@ -17246,7 +17231,7 @@ try_window_id (struct window *w)
This case happens with stealth-fontification. Note that although This case happens with stealth-fontification. Note that although
the display is unchanged, glyph positions in the matrix have to the display is unchanged, glyph positions in the matrix have to
be adjusted, of course. */ be adjusted, of course. */
row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); row = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
if (MATRIX_ROW_DISPLAYS_TEXT_P (row) if (MATRIX_ROW_DISPLAYS_TEXT_P (row)
&& ((last_changed_charpos < CHARPOS (start) && ((last_changed_charpos < CHARPOS (start)
&& CHARPOS (start) == BEGV) && CHARPOS (start) == BEGV)
...@@ -17258,7 +17243,7 @@ try_window_id (struct window *w) ...@@ -17258,7 +17243,7 @@ try_window_id (struct window *w)
   
/* Compute how many chars/bytes have been added to or removed /* Compute how many chars/bytes have been added to or removed
from the buffer. */ from the buffer. */
Z_old = MATRIX_ROW_END_CHARPOS (row) + XFASTINT (w->window_end_pos); Z_old = MATRIX_ROW_END_CHARPOS (row) + w->window_end_pos;
Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos; Z_BYTE_old = MATRIX_ROW_END_BYTEPOS (row) + w->window_end_bytepos;
Z_delta = Z - Z_old; Z_delta = Z - Z_old;
Z_delta_bytes = Z_BYTE - Z_BYTE_old; Z_delta_bytes = Z_BYTE - Z_BYTE_old;
...@@ -17329,10 +17314,8 @@ try_window_id (struct window *w) ...@@ -17329,10 +17314,8 @@ try_window_id (struct window *w)
{ {
/* We have to compute the window end anew since text /* We have to compute the window end anew since text
could have been added/removed after it. */ could have been added/removed after it. */
wset_window_end_pos w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
   
/* Set the cursor. */ /* Set the cursor. */
row = row_containing_pos (w, PT, r0, NULL, 0); row = row_containing_pos (w, PT, r0, NULL, 0);
...@@ -17365,7 +17348,7 @@ try_window_id (struct window *w) ...@@ -17365,7 +17348,7 @@ try_window_id (struct window *w)
   
/* Give up if the window ends in strings. Overlay strings /* Give up if the window ends in strings. Overlay strings
at the end are difficult to handle, so don't try. */ at the end are difficult to handle, so don't try. */
row = MATRIX_ROW (current_matrix, XFASTINT (w->window_end_vpos)); row = MATRIX_ROW (current_matrix, w->window_end_vpos);
if (MATRIX_ROW_START_CHARPOS (row) == MATRIX_ROW_END_CHARPOS (row)) if (MATRIX_ROW_START_CHARPOS (row) == MATRIX_ROW_END_CHARPOS (row))
GIVE_UP (20); GIVE_UP (20);
   
...@@ -17711,7 +17694,7 @@ try_window_id (struct window *w) ...@@ -17711,7 +17694,7 @@ try_window_id (struct window *w)
/* Set last_row to the glyph row in the current matrix where the /* Set last_row to the glyph row in the current matrix where the
window end line is found. It has been moved up or down in window end line is found. It has been moved up or down in
the matrix by dvpos. */ the matrix by dvpos. */
int last_vpos = XFASTINT (w->window_end_vpos) + dvpos; int last_vpos = w->window_end_vpos + dvpos;
struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos); struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos);
   
/* If last_row is the window end line, it should display text. */ /* If last_row is the window end line, it should display text. */
...@@ -17755,8 +17738,7 @@ try_window_id (struct window *w) ...@@ -17755,8 +17738,7 @@ try_window_id (struct window *w)
} }
   
/* Update window_end_pos and window_end_vpos. */ /* Update window_end_pos and window_end_vpos. */
if (first_unchanged_at_end_row if (first_unchanged_at_end_row && !last_text_row_at_end)
&& !last_text_row_at_end)
{ {
/* Window end line if one of the preserved rows from the current /* Window end line if one of the preserved rows from the current
matrix. Set row to the last row displaying text in current matrix. Set row to the last row displaying text in current
...@@ -17767,22 +17749,20 @@ try_window_id (struct window *w) ...@@ -17767,22 +17749,20 @@ try_window_id (struct window *w)
first_unchanged_at_end_row); first_unchanged_at_end_row);
eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row)); eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
   
wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
wset_window_end_vpos w->window_end_vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
(w, make_number (MATRIX_ROW_VPOS (row, w->current_matrix)));
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
IF_DEBUG (debug_method_add (w, "A")); IF_DEBUG (debug_method_add (w, "A"));
} }
else if (last_text_row_at_end) else if (last_text_row_at_end)
{ {
wset_window_end_pos w->window_end_pos
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end))); = Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end);
w->window_end_bytepos w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end); = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end);
wset_window_end_vpos w->window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row_at_end, = MATRIX_ROW_VPOS (last_text_row_at_end, desired_matrix);
desired_matrix)));
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
IF_DEBUG (debug_method_add (w, "B")); IF_DEBUG (debug_method_add (w, "B"));
} }
...@@ -17791,12 +17771,11 @@ try_window_id (struct window *w) ...@@ -17791,12 +17771,11 @@ try_window_id (struct window *w)
/* We have displayed either to the end of the window or at the /* We have displayed either to the end of the window or at the
end of the window, i.e. the last row with text is to be found end of the window, i.e. the last row with text is to be found
in the desired matrix. */ in the desired matrix. */
wset_window_end_pos w->window_end_pos
(w, make_number (Z - MATRIX_ROW_END_CHARPOS (last_text_row))); = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
w->window_end_bytepos w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
wset_window_end_vpos w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, desired_matrix);
(w, make_number (MATRIX_ROW_VPOS (last_text_row, desired_matrix)));
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
} }
else if (first_unchanged_at_end_row == NULL else if (first_unchanged_at_end_row == NULL
...@@ -17806,7 +17785,7 @@ try_window_id (struct window *w) ...@@ -17806,7 +17785,7 @@ try_window_id (struct window *w)
/* Displayed to end of window, but no line containing text was /* Displayed to end of window, but no line containing text was
displayed. Lines were deleted at the end of the window. */ displayed. Lines were deleted at the end of the window. */
int first_vpos = WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0; int first_vpos = WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0;
int vpos = XFASTINT (w->window_end_vpos); int vpos = w->window_end_vpos;
struct glyph_row *current_row = current_matrix->rows + vpos; struct glyph_row *current_row = current_matrix->rows + vpos;
struct glyph_row *desired_row = desired_matrix->rows + vpos; struct glyph_row *desired_row = desired_matrix->rows + vpos;
   
...@@ -17824,8 +17803,8 @@ try_window_id (struct window *w) ...@@ -17824,8 +17803,8 @@ try_window_id (struct window *w)
} }
   
eassert (row != NULL); eassert (row != NULL);
wset_window_end_vpos (w, make_number (vpos + 1)); w->window_end_vpos = vpos + 1;
wset_window_end_pos (w, make_number (Z - MATRIX_ROW_END_CHARPOS (row))); w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row); w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
IF_DEBUG (debug_method_add (w, "C")); IF_DEBUG (debug_method_add (w, "C"));
...@@ -17833,8 +17812,8 @@ try_window_id (struct window *w) ...@@ -17833,8 +17812,8 @@ try_window_id (struct window *w)
else else
emacs_abort (); emacs_abort ();
   
IF_DEBUG (debug_end_pos = XFASTINT (w->window_end_pos); IF_DEBUG (debug_end_pos = w->window_end_pos;
debug_end_vpos = XFASTINT (w->window_end_vpos)); debug_end_vpos = w->window_end_vpos);
   
/* Record that display has not been completed. */ /* Record that display has not been completed. */
w->window_end_valid = 0; w->window_end_valid = 0;
...@@ -22002,7 +21981,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, ...@@ -22002,7 +21981,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
ptrdiff_t pos = marker_position (w->start); ptrdiff_t pos = marker_position (w->start);
ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b); ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b);
   
if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b)) if (w->window_end_pos <= BUF_Z (b) - BUF_ZV (b))
{ {
if (pos <= BUF_BEGV (b)) if (pos <= BUF_BEGV (b))
return "All"; return "All";
...@@ -22031,7 +22010,7 @@ decode_mode_spec (struct window *w, register int c, int field_width, ...@@ -22031,7 +22010,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
case 'P': case 'P':
{ {
ptrdiff_t toppos = marker_position (w->start); ptrdiff_t toppos = marker_position (w->start);
ptrdiff_t botpos = BUF_Z (b) - XFASTINT (w->window_end_pos); ptrdiff_t botpos = BUF_Z (b) - w->window_end_pos;
ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b); ptrdiff_t total = BUF_ZV (b) - BUF_BEGV (b);
   
if (botpos >= BUF_ZV (b)) if (botpos >= BUF_ZV (b))
...@@ -27040,7 +27019,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, ...@@ -27040,7 +27019,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
/* Find the rows corresponding to START_CHARPOS and END_CHARPOS. */ /* Find the rows corresponding to START_CHARPOS and END_CHARPOS. */
rows_from_pos_range (w, start_charpos, end_charpos, disp_string, &r1, &r2); rows_from_pos_range (w, start_charpos, end_charpos, disp_string, &r1, &r2);
if (r1 == NULL) if (r1 == NULL)
r1 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); r1 = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
/* If the before-string or display-string contains newlines, /* If the before-string or display-string contains newlines,
rows_from_pos_range skips to its last row. Move back. */ rows_from_pos_range skips to its last row. Move back. */
if (!NILP (before_string) || !NILP (disp_string)) if (!NILP (before_string) || !NILP (disp_string))
...@@ -27062,7 +27041,7 @@ mouse_face_from_buffer_pos (Lisp_Object window, ...@@ -27062,7 +27041,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
} }
if (r2 == NULL) if (r2 == NULL)
{ {
r2 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); r2 = MATRIX_ROW (w->current_matrix, w->window_end_vpos);
hlinfo->mouse_face_past_end = 1; hlinfo->mouse_face_past_end = 1;