+2013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Cache current header and mode line height for each window.
+ * window.h (struct window): New fields mode_line_height
+ and header_line_height.
+ * window.c (make_window): Initialize them.
+ * dispextern.h (CURRENT_MODE_LINE_HEIGHT)
+ (CURRENT_HEADER_LINE_HEIGHT): Use them. Adjust comment.
+ (current_mode_line_height, current_header_line_height):
+ Remove declaration.
+ * xdisp.c (current_mode_line_height, current_header_line_height):
+ Remove.
+ (pos_visible_p, init_xdisp): Adjust user.
+ (redisplay_window): Invalidate mode_line_height and
+ header_line_height if current and desired matrices do not agree.
+
2013-09-05 Dmitry Antipov <dmantipov@yandex.ru>
* fontset.c, window.c, xdisp.c (toplevel): Use TERM_HEADER.
#define CURRENT_MODE_LINE_FACE_ID(W) \
(CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W)))
-/* Return the current height of the mode line of window W. If not
- known from current_mode_line_height, look at W's current glyph
- matrix, or return a default based on the height of the font of the
- face `mode-line'. */
-
-#define CURRENT_MODE_LINE_HEIGHT(W) \
- (current_mode_line_height >= 0 \
- ? current_mode_line_height \
- : (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
- ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \
- : estimate_mode_line_height (XFRAME ((W)->frame), \
- CURRENT_MODE_LINE_FACE_ID (W))))
-
-/* Return the current height of the header line of window W. If not
- known from current_header_line_height, look at W's current glyph
- matrix, or return an estimation based on the height of the font of
- the face `header-line'. */
+/* Return the current height of the mode line of window W. If not known
+ from W->mode_line_height, look at W's current glyph matrix, or return
+ a default based on the height of the font of the face `mode-line'. */
+
+#define CURRENT_MODE_LINE_HEIGHT(W) \
+ (W->mode_line_height >= 0 \
+ ? W->mode_line_height \
+ : (W->mode_line_height \
+ = (MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \
+ ? MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \
+ : estimate_mode_line_height \
+ (XFRAME (W->frame), CURRENT_MODE_LINE_FACE_ID (W)))))
+
+/* Return the current height of the header line of window W. If not known
+ from W->header_line_height, look at W's current glyph matrix, or return
+ an estimation based on the height of the font of the face `header-line'. */
#define CURRENT_HEADER_LINE_HEIGHT(W) \
- (current_header_line_height >= 0 \
- ? current_header_line_height \
- : (MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
- ? MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \
- : estimate_mode_line_height (XFRAME ((W)->frame), \
- HEADER_LINE_FACE_ID)))
+ (W->header_line_height >= 0 \
+ ? W->header_line_height \
+ : (W->header_line_height \
+ = (MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \
+ ? MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \
+ : estimate_mode_line_height \
+ (XFRAME (W->frame), HEADER_LINE_FACE_ID))))
/* Return the height of the desired mode line of window W. */
extern Lisp_Object Qtool_bar;
extern bool redisplaying_p;
extern int help_echo_showing_p;
-extern int current_mode_line_height, current_header_line_height;
extern Lisp_Object help_echo_string, help_echo_window;
extern Lisp_Object help_echo_object, previous_help_echo_string;
extern ptrdiff_t help_echo_pos;
non-Lisp data, so do it only for slots which should not be zero. */
w->nrows_scale_factor = w->ncols_scale_factor = 1;
w->left_fringe_width = w->right_fringe_width = -1;
+ w->mode_line_height = w->header_line_height = -1;
w->phys_cursor_type = -1;
w->phys_cursor_width = -1;
w->scroll_bar_width = -1;
A value of -1 means use frame values. */
int scroll_bar_width;
+ /* Effective height of the mode line, or -1 if not known. */
+ int mode_line_height;
+
+ /* Effective height of the header line, or -1 if not known. */
+ int header_line_height;
+
/* 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;
int help_echo_showing_p;
-/* If >= 0, computed, exact values of mode-line and header-line height
- to use in the macros CURRENT_MODE_LINE_HEIGHT and
- CURRENT_HEADER_LINE_HEIGHT. */
-
-int current_mode_line_height, current_header_line_height;
-
/* The maximum distance to look ahead for text properties. Values
that are too small let us call compute_char_face and similar
functions too often which is expensive. Values that are too large
/* Compute exact mode line heights. */
if (WINDOW_WANTS_MODELINE_P (w))
- current_mode_line_height
+ w->mode_line_height
= display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
BVAR (current_buffer, mode_line_format));
if (WINDOW_WANTS_HEADER_LINE_P (w))
- current_header_line_height
+ w->header_line_height
= display_mode_line (w, HEADER_LINE_FACE_ID,
BVAR (current_buffer, header_line_format));
if (old_buffer)
set_buffer_internal_1 (old_buffer);
- current_header_line_height = current_mode_line_height = -1;
-
if (visible_p && w->hscroll > 0)
*x -=
window_hscroll_limited (w, WINDOW_XFRAME (w))
&& CURRENT_MODE_LINE_HEIGHT (w) != DESIRED_MODE_LINE_HEIGHT (w))
{
fonts_changed_p = 1;
+ w->mode_line_height = -1;
MATRIX_MODE_LINE_ROW (w->current_matrix)->height
= DESIRED_MODE_LINE_HEIGHT (w);
}
&& CURRENT_HEADER_LINE_HEIGHT (w) != DESIRED_HEADER_LINE_HEIGHT (w))
{
fonts_changed_p = 1;
+ w->header_line_height = -1;
MATRIX_HEADER_LINE_ROW (w->current_matrix)->height
= DESIRED_HEADER_LINE_HEIGHT (w);
}
void
init_xdisp (void)
{
- current_header_line_height = current_mode_line_height = -1;
-
CHARPOS (this_line_start_pos) = 0;
if (!noninteractive)