diff options
| author | Dmitry Antipov | 2013-09-05 20:25:20 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-09-05 20:25:20 +0400 |
| commit | b969582835bb7d6085a802322c77150fe559960e (patch) | |
| tree | be9ab059004c356ec2ba8e3dbe0bf489fcb5dd74 /src | |
| parent | 1f896cb7ede7d658797737574b2d6b00d128a592 (diff) | |
| download | emacs-b969582835bb7d6085a802322c77150fe559960e.tar.gz emacs-b969582835bb7d6085a802322c77150fe559960e.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/dispextern.h | 47 | ||||
| -rw-r--r-- | src/window.c | 1 | ||||
| -rw-r--r-- | src/window.h | 6 | ||||
| -rw-r--r-- | src/xdisp.c | 16 |
5 files changed, 50 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d4a7abefd57..898fbd8ab88 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | 2013-09-05 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-09-05 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Cache current header and mode line height for each window. | ||
| 4 | * window.h (struct window): New fields mode_line_height | ||
| 5 | and header_line_height. | ||
| 6 | * window.c (make_window): Initialize them. | ||
| 7 | * dispextern.h (CURRENT_MODE_LINE_HEIGHT) | ||
| 8 | (CURRENT_HEADER_LINE_HEIGHT): Use them. Adjust comment. | ||
| 9 | (current_mode_line_height, current_header_line_height): | ||
| 10 | Remove declaration. | ||
| 11 | * xdisp.c (current_mode_line_height, current_header_line_height): | ||
| 12 | Remove. | ||
| 13 | (pos_visible_p, init_xdisp): Adjust user. | ||
| 14 | (redisplay_window): Invalidate mode_line_height and | ||
| 15 | header_line_height if current and desired matrices do not agree. | ||
| 16 | |||
| 17 | 2013-09-05 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 18 | |||
| 3 | * fontset.c, window.c, xdisp.c (toplevel): Use TERM_HEADER. | 19 | * fontset.c, window.c, xdisp.c (toplevel): Use TERM_HEADER. |
| 4 | * xfaces.c (toplevel) [HAVE_X_WINDOWS]: Do not include xterm.h twice. | 20 | * xfaces.c (toplevel) [HAVE_X_WINDOWS]: Do not include xterm.h twice. |
| 5 | 21 | ||
diff --git a/src/dispextern.h b/src/dispextern.h index 947e50fa4dd..ebb07c1d37f 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -1428,31 +1428,31 @@ struct glyph_string | |||
| 1428 | #define CURRENT_MODE_LINE_FACE_ID(W) \ | 1428 | #define CURRENT_MODE_LINE_FACE_ID(W) \ |
| 1429 | (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W))) | 1429 | (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W))) |
| 1430 | 1430 | ||
| 1431 | /* Return the current height of the mode line of window W. If not | 1431 | /* Return the current height of the mode line of window W. If not known |
| 1432 | known from current_mode_line_height, look at W's current glyph | 1432 | from W->mode_line_height, look at W's current glyph matrix, or return |
| 1433 | matrix, or return a default based on the height of the font of the | 1433 | a default based on the height of the font of the face `mode-line'. */ |
| 1434 | face `mode-line'. */ | 1434 | |
| 1435 | 1435 | #define CURRENT_MODE_LINE_HEIGHT(W) \ | |
| 1436 | #define CURRENT_MODE_LINE_HEIGHT(W) \ | 1436 | (W->mode_line_height >= 0 \ |
| 1437 | (current_mode_line_height >= 0 \ | 1437 | ? W->mode_line_height \ |
| 1438 | ? current_mode_line_height \ | 1438 | : (W->mode_line_height \ |
| 1439 | : (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ | 1439 | = (MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \ |
| 1440 | ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix) \ | 1440 | ? MATRIX_MODE_LINE_HEIGHT (W->current_matrix) \ |
| 1441 | : estimate_mode_line_height (XFRAME ((W)->frame), \ | 1441 | : estimate_mode_line_height \ |
| 1442 | CURRENT_MODE_LINE_FACE_ID (W)))) | 1442 | (XFRAME (W->frame), CURRENT_MODE_LINE_FACE_ID (W))))) |
| 1443 | 1443 | ||
| 1444 | /* Return the current height of the header line of window W. If not | 1444 | /* Return the current height of the header line of window W. If not known |
| 1445 | known from current_header_line_height, look at W's current glyph | 1445 | from W->header_line_height, look at W's current glyph matrix, or return |
| 1446 | matrix, or return an estimation based on the height of the font of | 1446 | an estimation based on the height of the font of the face `header-line'. */ |
| 1447 | the face `header-line'. */ | ||
| 1448 | 1447 | ||
| 1449 | #define CURRENT_HEADER_LINE_HEIGHT(W) \ | 1448 | #define CURRENT_HEADER_LINE_HEIGHT(W) \ |
| 1450 | (current_header_line_height >= 0 \ | 1449 | (W->header_line_height >= 0 \ |
| 1451 | ? current_header_line_height \ | 1450 | ? W->header_line_height \ |
| 1452 | : (MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \ | 1451 | : (W->header_line_height \ |
| 1453 | ? MATRIX_HEADER_LINE_HEIGHT ((W)->current_matrix) \ | 1452 | = (MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \ |
| 1454 | : estimate_mode_line_height (XFRAME ((W)->frame), \ | 1453 | ? MATRIX_HEADER_LINE_HEIGHT (W->current_matrix) \ |
| 1455 | HEADER_LINE_FACE_ID))) | 1454 | : estimate_mode_line_height \ |
| 1455 | (XFRAME (W->frame), HEADER_LINE_FACE_ID)))) | ||
| 1456 | 1456 | ||
| 1457 | /* Return the height of the desired mode line of window W. */ | 1457 | /* Return the height of the desired mode line of window W. */ |
| 1458 | 1458 | ||
| @@ -3201,7 +3201,6 @@ int frame_mode_line_height (struct frame *); | |||
| 3201 | extern Lisp_Object Qtool_bar; | 3201 | extern Lisp_Object Qtool_bar; |
| 3202 | extern bool redisplaying_p; | 3202 | extern bool redisplaying_p; |
| 3203 | extern int help_echo_showing_p; | 3203 | extern int help_echo_showing_p; |
| 3204 | extern int current_mode_line_height, current_header_line_height; | ||
| 3205 | extern Lisp_Object help_echo_string, help_echo_window; | 3204 | extern Lisp_Object help_echo_string, help_echo_window; |
| 3206 | extern Lisp_Object help_echo_object, previous_help_echo_string; | 3205 | extern Lisp_Object help_echo_object, previous_help_echo_string; |
| 3207 | extern ptrdiff_t help_echo_pos; | 3206 | extern ptrdiff_t help_echo_pos; |
diff --git a/src/window.c b/src/window.c index d8a6976e090..253e6233fc1 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3419,6 +3419,7 @@ make_window (void) | |||
| 3419 | non-Lisp data, so do it only for slots which should not be zero. */ | 3419 | non-Lisp data, so do it only for slots which should not be zero. */ |
| 3420 | w->nrows_scale_factor = w->ncols_scale_factor = 1; | 3420 | w->nrows_scale_factor = w->ncols_scale_factor = 1; |
| 3421 | w->left_fringe_width = w->right_fringe_width = -1; | 3421 | w->left_fringe_width = w->right_fringe_width = -1; |
| 3422 | w->mode_line_height = w->header_line_height = -1; | ||
| 3422 | w->phys_cursor_type = -1; | 3423 | w->phys_cursor_type = -1; |
| 3423 | w->phys_cursor_width = -1; | 3424 | w->phys_cursor_width = -1; |
| 3424 | w->scroll_bar_width = -1; | 3425 | w->scroll_bar_width = -1; |
diff --git a/src/window.h b/src/window.h index efe03737052..f5ae81149b3 100644 --- a/src/window.h +++ b/src/window.h | |||
| @@ -264,6 +264,12 @@ struct window | |||
| 264 | A value of -1 means use frame values. */ | 264 | A value of -1 means use frame values. */ |
| 265 | int scroll_bar_width; | 265 | int scroll_bar_width; |
| 266 | 266 | ||
| 267 | /* Effective height of the mode line, or -1 if not known. */ | ||
| 268 | int mode_line_height; | ||
| 269 | |||
| 270 | /* Effective height of the header line, or -1 if not known. */ | ||
| 271 | int header_line_height; | ||
| 272 | |||
| 267 | /* Z - the buffer position of the last glyph in the current | 273 | /* Z - the buffer position of the last glyph in the current |
| 268 | matrix of W. Only valid if window_end_valid is nonzero. */ | 274 | matrix of W. Only valid if window_end_valid is nonzero. */ |
| 269 | ptrdiff_t window_end_pos; | 275 | ptrdiff_t window_end_pos; |
diff --git a/src/xdisp.c b/src/xdisp.c index c096fcd340f..74491a40d74 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -573,12 +573,6 @@ static int last_height; | |||
| 573 | 573 | ||
| 574 | int help_echo_showing_p; | 574 | int help_echo_showing_p; |
| 575 | 575 | ||
| 576 | /* If >= 0, computed, exact values of mode-line and header-line height | ||
| 577 | to use in the macros CURRENT_MODE_LINE_HEIGHT and | ||
| 578 | CURRENT_HEADER_LINE_HEIGHT. */ | ||
| 579 | |||
| 580 | int current_mode_line_height, current_header_line_height; | ||
| 581 | |||
| 582 | /* The maximum distance to look ahead for text properties. Values | 576 | /* The maximum distance to look ahead for text properties. Values |
| 583 | that are too small let us call compute_char_face and similar | 577 | that are too small let us call compute_char_face and similar |
| 584 | functions too often which is expensive. Values that are too large | 578 | 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, | |||
| 1349 | 1343 | ||
| 1350 | /* Compute exact mode line heights. */ | 1344 | /* Compute exact mode line heights. */ |
| 1351 | if (WINDOW_WANTS_MODELINE_P (w)) | 1345 | if (WINDOW_WANTS_MODELINE_P (w)) |
| 1352 | current_mode_line_height | 1346 | w->mode_line_height |
| 1353 | = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w), | 1347 | = display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w), |
| 1354 | BVAR (current_buffer, mode_line_format)); | 1348 | BVAR (current_buffer, mode_line_format)); |
| 1355 | 1349 | ||
| 1356 | if (WINDOW_WANTS_HEADER_LINE_P (w)) | 1350 | if (WINDOW_WANTS_HEADER_LINE_P (w)) |
| 1357 | current_header_line_height | 1351 | w->header_line_height |
| 1358 | = display_mode_line (w, HEADER_LINE_FACE_ID, | 1352 | = display_mode_line (w, HEADER_LINE_FACE_ID, |
| 1359 | BVAR (current_buffer, header_line_format)); | 1353 | BVAR (current_buffer, header_line_format)); |
| 1360 | 1354 | ||
| @@ -1647,8 +1641,6 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y, | |||
| 1647 | if (old_buffer) | 1641 | if (old_buffer) |
| 1648 | set_buffer_internal_1 (old_buffer); | 1642 | set_buffer_internal_1 (old_buffer); |
| 1649 | 1643 | ||
| 1650 | current_header_line_height = current_mode_line_height = -1; | ||
| 1651 | |||
| 1652 | if (visible_p && w->hscroll > 0) | 1644 | if (visible_p && w->hscroll > 0) |
| 1653 | *x -= | 1645 | *x -= |
| 1654 | window_hscroll_limited (w, WINDOW_XFRAME (w)) | 1646 | window_hscroll_limited (w, WINDOW_XFRAME (w)) |
| @@ -16107,6 +16099,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 16107 | && CURRENT_MODE_LINE_HEIGHT (w) != DESIRED_MODE_LINE_HEIGHT (w)) | 16099 | && CURRENT_MODE_LINE_HEIGHT (w) != DESIRED_MODE_LINE_HEIGHT (w)) |
| 16108 | { | 16100 | { |
| 16109 | fonts_changed_p = 1; | 16101 | fonts_changed_p = 1; |
| 16102 | w->mode_line_height = -1; | ||
| 16110 | MATRIX_MODE_LINE_ROW (w->current_matrix)->height | 16103 | MATRIX_MODE_LINE_ROW (w->current_matrix)->height |
| 16111 | = DESIRED_MODE_LINE_HEIGHT (w); | 16104 | = DESIRED_MODE_LINE_HEIGHT (w); |
| 16112 | } | 16105 | } |
| @@ -16117,6 +16110,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 16117 | && CURRENT_HEADER_LINE_HEIGHT (w) != DESIRED_HEADER_LINE_HEIGHT (w)) | 16110 | && CURRENT_HEADER_LINE_HEIGHT (w) != DESIRED_HEADER_LINE_HEIGHT (w)) |
| 16118 | { | 16111 | { |
| 16119 | fonts_changed_p = 1; | 16112 | fonts_changed_p = 1; |
| 16113 | w->header_line_height = -1; | ||
| 16120 | MATRIX_HEADER_LINE_ROW (w->current_matrix)->height | 16114 | MATRIX_HEADER_LINE_ROW (w->current_matrix)->height |
| 16121 | = DESIRED_HEADER_LINE_HEIGHT (w); | 16115 | = DESIRED_HEADER_LINE_HEIGHT (w); |
| 16122 | } | 16116 | } |
| @@ -29686,8 +29680,6 @@ Its value should be an ASCII acronym string, `hex-code', `empty-box', or | |||
| 29686 | void | 29680 | void |
| 29687 | init_xdisp (void) | 29681 | init_xdisp (void) |
| 29688 | { | 29682 | { |
| 29689 | current_header_line_height = current_mode_line_height = -1; | ||
| 29690 | |||
| 29691 | CHARPOS (this_line_start_pos) = 0; | 29683 | CHARPOS (this_line_start_pos) = 0; |
| 29692 | 29684 | ||
| 29693 | if (!noninteractive) | 29685 | if (!noninteractive) |