diff options
| author | Kim F. Storm | 2006-07-01 23:29:04 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-07-01 23:29:04 +0000 |
| commit | dd6cfb49fc2f4713ab3ff82d63c92203034ba21b (patch) | |
| tree | 120cbb87689150849b43810282a8aace7fc9da3f /src | |
| parent | 8cb72de5a6be7947a3493d1978e35c498d44da07 (diff) | |
| download | emacs-dd6cfb49fc2f4713ab3ff82d63c92203034ba21b.tar.gz emacs-dd6cfb49fc2f4713ab3ff82d63c92203034ba21b.zip | |
(display_tool_bar_line): Skip glyphs which are too big
to ever fit the tool-bar,
(MAX_FRAME_TOOL_BAR_HEIGHT): New macro.
(tool_bar_lines_needed): Use unused mode-line row as temp_row.
(redisplay_tool_bar): Only clear desired matrix if we actually
change the tool-bar window height. Only try to make the tool-bar
window bigger if there is actually room for it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 55ee9fc20e7..d37f142e604 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -9608,6 +9608,12 @@ display_tool_bar_line (it, height) | |||
| 9608 | /* Glyph doesn't fit on line. Backtrack. */ | 9608 | /* Glyph doesn't fit on line. Backtrack. */ |
| 9609 | row->used[TEXT_AREA] = n_glyphs_before; | 9609 | row->used[TEXT_AREA] = n_glyphs_before; |
| 9610 | *it = it_before; | 9610 | *it = it_before; |
| 9611 | /* If this is the only glyph on this line, it will never fit on the | ||
| 9612 | toolbar, so skip it. But ensure there is at least one glyph, | ||
| 9613 | so we don't accidentally disable the tool-bar. */ | ||
| 9614 | if (n_glyphs_before == 0 | ||
| 9615 | && (it->vpos > 0 || IT_STRING_CHARPOS (*it) < it->end_charpos-1)) | ||
| 9616 | break; | ||
| 9611 | goto out; | 9617 | goto out; |
| 9612 | } | 9618 | } |
| 9613 | 9619 | ||
| @@ -9666,6 +9672,11 @@ display_tool_bar_line (it, height) | |||
| 9666 | } | 9672 | } |
| 9667 | 9673 | ||
| 9668 | 9674 | ||
| 9675 | /* Max tool-bar height. */ | ||
| 9676 | |||
| 9677 | #define MAX_FRAME_TOOL_BAR_HEIGHT(f) \ | ||
| 9678 | ((FRAME_LINE_HEIGHT (f) * FRAME_LINES (f))) | ||
| 9679 | |||
| 9669 | /* Value is the number of screen lines needed to make all tool-bar | 9680 | /* Value is the number of screen lines needed to make all tool-bar |
| 9670 | items of frame F visible. The number of actual rows needed is | 9681 | items of frame F visible. The number of actual rows needed is |
| 9671 | returned in *N_ROWS if non-NULL. */ | 9682 | returned in *N_ROWS if non-NULL. */ |
| @@ -9677,7 +9688,10 @@ tool_bar_lines_needed (f, n_rows) | |||
| 9677 | { | 9688 | { |
| 9678 | struct window *w = XWINDOW (f->tool_bar_window); | 9689 | struct window *w = XWINDOW (f->tool_bar_window); |
| 9679 | struct it it; | 9690 | struct it it; |
| 9680 | struct glyph_row *temp_row = w->desired_matrix->rows; | 9691 | /* tool_bar_lines_needed is called from redisplay_tool_bar after building |
| 9692 | the desired matrix, so use (unused) mode-line row as temporary row to | ||
| 9693 | avoid destroying the first tool-bar row. */ | ||
| 9694 | struct glyph_row *temp_row = MATRIX_MODE_LINE_ROW (w->desired_matrix); | ||
| 9681 | 9695 | ||
| 9682 | /* Initialize an iterator for iteration over | 9696 | /* Initialize an iterator for iteration over |
| 9683 | F->desired_tool_bar_string in the tool-bar window of frame F. */ | 9697 | F->desired_tool_bar_string in the tool-bar window of frame F. */ |
| @@ -9783,13 +9797,13 @@ redisplay_tool_bar (f) | |||
| 9783 | int old_height = WINDOW_TOTAL_LINES (w); | 9797 | int old_height = WINDOW_TOTAL_LINES (w); |
| 9784 | 9798 | ||
| 9785 | XSETFRAME (frame, f); | 9799 | XSETFRAME (frame, f); |
| 9786 | clear_glyph_matrix (w->desired_matrix); | ||
| 9787 | Fmodify_frame_parameters (frame, | 9800 | Fmodify_frame_parameters (frame, |
| 9788 | Fcons (Fcons (Qtool_bar_lines, | 9801 | Fcons (Fcons (Qtool_bar_lines, |
| 9789 | make_number (nlines)), | 9802 | make_number (nlines)), |
| 9790 | Qnil)); | 9803 | Qnil)); |
| 9791 | if (WINDOW_TOTAL_LINES (w) != old_height) | 9804 | if (WINDOW_TOTAL_LINES (w) != old_height) |
| 9792 | { | 9805 | { |
| 9806 | clear_glyph_matrix (w->desired_matrix); | ||
| 9793 | fonts_changed_p = 1; | 9807 | fonts_changed_p = 1; |
| 9794 | return 1; | 9808 | return 1; |
| 9795 | } | 9809 | } |
| @@ -9841,17 +9855,20 @@ redisplay_tool_bar (f) | |||
| 9841 | 9855 | ||
| 9842 | if (auto_resize_tool_bars_p) | 9856 | if (auto_resize_tool_bars_p) |
| 9843 | { | 9857 | { |
| 9844 | int nlines; | 9858 | int nlines, nrows; |
| 9859 | int max_tool_bar_height = MAX_FRAME_TOOL_BAR_HEIGHT (f); | ||
| 9845 | 9860 | ||
| 9846 | /* If we couldn't display everything, change the tool-bar's | 9861 | /* If we couldn't display everything, change the tool-bar's |
| 9847 | height. */ | 9862 | height if there is room for more. */ |
| 9848 | if (IT_STRING_CHARPOS (it) < it.end_charpos) | 9863 | if (IT_STRING_CHARPOS (it) < it.end_charpos |
| 9864 | && it.current_y < max_tool_bar_height) | ||
| 9849 | change_height_p = 1; | 9865 | change_height_p = 1; |
| 9850 | 9866 | ||
| 9867 | row = it.glyph_row - 1; | ||
| 9868 | |||
| 9851 | /* If there are blank lines at the end, except for a partially | 9869 | /* If there are blank lines at the end, except for a partially |
| 9852 | visible blank line at the end that is smaller than | 9870 | visible blank line at the end that is smaller than |
| 9853 | FRAME_LINE_HEIGHT, change the tool-bar's height. */ | 9871 | FRAME_LINE_HEIGHT, change the tool-bar's height. */ |
| 9854 | row = it.glyph_row - 1; | ||
| 9855 | if (!row->displays_text_p | 9872 | if (!row->displays_text_p |
| 9856 | && row->height >= FRAME_LINE_HEIGHT (f)) | 9873 | && row->height >= FRAME_LINE_HEIGHT (f)) |
| 9857 | change_height_p = 1; | 9874 | change_height_p = 1; |
| @@ -9859,13 +9876,14 @@ redisplay_tool_bar (f) | |||
| 9859 | /* If row displays tool-bar items, but is partially visible, | 9876 | /* If row displays tool-bar items, but is partially visible, |
| 9860 | change the tool-bar's height. */ | 9877 | change the tool-bar's height. */ |
| 9861 | if (row->displays_text_p | 9878 | if (row->displays_text_p |
| 9862 | && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y) | 9879 | && MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y |
| 9880 | && MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height) | ||
| 9863 | change_height_p = 1; | 9881 | change_height_p = 1; |
| 9864 | 9882 | ||
| 9865 | /* Resize windows as needed by changing the `tool-bar-lines' | 9883 | /* Resize windows as needed by changing the `tool-bar-lines' |
| 9866 | frame parameter. */ | 9884 | frame parameter. */ |
| 9867 | if (change_height_p | 9885 | if (change_height_p |
| 9868 | && (nlines = tool_bar_lines_needed (f, &f->n_tool_bar_rows), | 9886 | && (nlines = tool_bar_lines_needed (f, &nrows), |
| 9869 | nlines != WINDOW_TOTAL_LINES (w))) | 9887 | nlines != WINDOW_TOTAL_LINES (w))) |
| 9870 | { | 9888 | { |
| 9871 | extern Lisp_Object Qtool_bar_lines; | 9889 | extern Lisp_Object Qtool_bar_lines; |
| @@ -9873,13 +9891,16 @@ redisplay_tool_bar (f) | |||
| 9873 | int old_height = WINDOW_TOTAL_LINES (w); | 9891 | int old_height = WINDOW_TOTAL_LINES (w); |
| 9874 | 9892 | ||
| 9875 | XSETFRAME (frame, f); | 9893 | XSETFRAME (frame, f); |
| 9876 | clear_glyph_matrix (w->desired_matrix); | ||
| 9877 | Fmodify_frame_parameters (frame, | 9894 | Fmodify_frame_parameters (frame, |
| 9878 | Fcons (Fcons (Qtool_bar_lines, | 9895 | Fcons (Fcons (Qtool_bar_lines, |
| 9879 | make_number (nlines)), | 9896 | make_number (nlines)), |
| 9880 | Qnil)); | 9897 | Qnil)); |
| 9881 | if (WINDOW_TOTAL_LINES (w) != old_height) | 9898 | if (WINDOW_TOTAL_LINES (w) != old_height) |
| 9882 | fonts_changed_p = 1; | 9899 | { |
| 9900 | clear_glyph_matrix (w->desired_matrix); | ||
| 9901 | f->n_tool_bar_rows = nrows; | ||
| 9902 | fonts_changed_p = 1; | ||
| 9903 | } | ||
| 9883 | } | 9904 | } |
| 9884 | } | 9905 | } |
| 9885 | 9906 | ||