]> git.eshelyaron.com Git - emacs.git/commitdiff
Cache current header and mode line height for each window.
authorDmitry Antipov <dmantipov@yandex.ru>
Thu, 5 Sep 2013 16:25:20 +0000 (20:25 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Thu, 5 Sep 2013 16:25:20 +0000 (20:25 +0400)
* 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.

src/ChangeLog
src/dispextern.h
src/window.c
src/window.h
src/xdisp.c

index d4a7abefd57ee050c3c618772ee2bf9f6213e11f..898fbd8ab88539041fdb3d07b72bd3be19231ee1 100644 (file)
@@ -1,3 +1,19 @@
+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.
index 947e50fa4ddaaf83d559cbbc663b16e7e2b1bb01..ebb07c1d37f4531ebb77d6a53d66a52b0fffcfee 100644 (file)
@@ -1428,31 +1428,31 @@ struct glyph_string
 #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.  */
 
@@ -3201,7 +3201,6 @@ int frame_mode_line_height (struct frame *);
 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;
index d8a6976e090ce9885bbfa10668f6365a3ba18874..253e6233fc14bcb8d9c5ab637f46365dbeb634a9 100644 (file)
@@ -3419,6 +3419,7 @@ make_window (void)
      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;
index efe0373705210d8954deeae302ccf7e7453ed1c9..f5ae81149b3decd0637fadfc5a5b8d08718fa0ca 100644 (file)
@@ -264,6 +264,12 @@ struct window
        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;
index c096fcd340fc2d77ecf543d56e646cd301607a00..74491a40d74ae72d2156297ea308949fa3727412 100644 (file)
@@ -573,12 +573,6 @@ static int last_height;
 
 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
@@ -1349,12 +1343,12 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
 
   /* 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));
 
@@ -1647,8 +1641,6 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
   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))
@@ -16107,6 +16099,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
          && 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);
        }
@@ -16117,6 +16110,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p)
          && 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);
        }
@@ -29686,8 +29680,6 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or
 void
 init_xdisp (void)
 {
-  current_header_line_height = current_mode_line_height = -1;
-
   CHARPOS (this_line_start_pos) = 0;
 
   if (!noninteractive)