Skip to content

Commit 691d7ac

Browse files
committed
Fix bug #17892 with mode/header line and display margins.
src/dispnew.c (prepare_desired_row): Accept 2 additional arguments: the window whose glyph row is being prepared and a flag whether it is for mode/header line. Make sure the glyph row's marginal areas are in sync with what the window wants. src/xdisp.c (display_line, display_mode_line): Call prepare_desired_row with additional arguments, as appropriate. src/dispextern.h (prepare_desired_row): Adjust prototype. src/window.h: Improve commentary of the marginal columns.
1 parent bc1ee3a commit 691d7ac

File tree

5 files changed

+65
-12
lines changed

5 files changed

+65
-12
lines changed

src/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2014-07-01 Eli Zaretskii <eliz@gnu.org>
2+
3+
* dispnew.c (prepare_desired_row): Accept 2 additional arguments:
4+
the window whose glyph row is being prepared and a flag whether it
5+
is for mode/header line. Make sure the glyph row's marginal areas
6+
are in sync with what the window wants.
7+
(Bug#17892)
8+
9+
* xdisp.c (display_line, display_mode_line): Call
10+
prepare_desired_row with additional arguments, as appropriate.
11+
12+
* dispextern.h (prepare_desired_row): Adjust prototype.
13+
114
2014-07-01 Dmitry Antipov <dmantipov@yandex.ru>
215

316
* xfaces.c (init_frame_faces): Always realize basic faces (Bug#17889).

src/dispextern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3473,7 +3473,7 @@ void increment_matrix_positions (struct glyph_matrix *,
34733473
void blank_row (struct window *, struct glyph_row *, int);
34743474
void clear_glyph_matrix_rows (struct glyph_matrix *, int, int);
34753475
void clear_glyph_row (struct glyph_row *);
3476-
void prepare_desired_row (struct glyph_row *);
3476+
void prepare_desired_row (struct window *, struct glyph_row *, bool);
34773477
void update_single_window (struct window *, bool);
34783478
void do_pending_window_change (bool);
34793479
void change_frame_size (struct frame *, int, int, bool, bool, bool, bool);

src/dispnew.c

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
449449
+ x);
450450

451451
if (w == NULL
452-
|| row == matrix->rows + dim.height - 1
452+
|| (row == matrix->rows + dim.height - 1
453+
&& WINDOW_WANTS_MODELINE_P (w))
453454
|| (row == matrix->rows && matrix->header_line_p))
454455
{
455456
row->glyphs[TEXT_AREA]
@@ -492,8 +493,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
492493
= xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
493494
dim.width, sizeof (struct glyph));
494495

495-
/* The mode line never has marginal areas. */
496-
if (row == matrix->rows + dim.height - 1
496+
/* The mode line, if displayed, never has marginal areas. */
497+
if ((row == matrix->rows + dim.height - 1
498+
&& !(w && WINDOW_WANTS_MODELINE_P (w)))
497499
|| (row == matrix->rows && matrix->header_line_p))
498500
{
499501
row->glyphs[TEXT_AREA]
@@ -1049,13 +1051,16 @@ find_glyph_row_slice (struct glyph_matrix *window_matrix,
10491051

10501052
#endif /* 0 */
10511053

1052-
/* Prepare ROW for display. Desired rows are cleared lazily,
1053-
i.e. they are only marked as to be cleared by setting their
1054+
/* Prepare ROW for display in windows W. Desired rows are cleared
1055+
lazily, i.e. they are only marked as to be cleared by setting their
10541056
enabled_p flag to zero. When a row is to be displayed, a prior
1055-
call to this function really clears it. */
1057+
call to this function really clears it. In addition, this function
1058+
makes sure the marginal areas of ROW are in sync with the window's
1059+
display margins. MODE_LINE_P non-zero means we are preparing a
1060+
glyph row for header line or mode line. */
10561061

10571062
void
1058-
prepare_desired_row (struct glyph_row *row)
1063+
prepare_desired_row (struct window *w, struct glyph_row *row, bool mode_line_p)
10591064
{
10601065
if (!row->enabled_p)
10611066
{
@@ -1065,6 +1070,39 @@ prepare_desired_row (struct glyph_row *row)
10651070
row->enabled_p = true;
10661071
row->reversed_p = rp;
10671072
}
1073+
if (mode_line_p)
1074+
{
1075+
/* Mode and header lines, if displayed, never have marginal
1076+
areas. If we are called with MODE_LINE_P non-zero, we are
1077+
displaying the mode/header line in this widnow, and so the
1078+
marginal areas of this glyph row should be eliminated. This
1079+
is needed when the mode/header line is switched on in a
1080+
window that has display margins. */
1081+
if (w->left_margin_cols > 0)
1082+
row->glyphs[TEXT_AREA] = row->glyphs[LEFT_MARGIN_AREA];
1083+
if (w->right_margin_cols > 0)
1084+
row->glyphs[RIGHT_MARGIN_AREA] = row->glyphs[LAST_AREA];
1085+
}
1086+
else if (row == MATRIX_MODE_LINE_ROW (w->desired_matrix)
1087+
|| row == MATRIX_HEADER_LINE_ROW (w->desired_matrix))
1088+
{
1089+
/* The real number of glyphs reserved for the margins is
1090+
recorded in the glyph matrix, and can be different from
1091+
window's left_margin_cols and right_margin_cols; see
1092+
margin_glyphs_to_reserve for when that happens. */
1093+
int left = w->desired_matrix->left_margin_glyphs;
1094+
int right = w->desired_matrix->right_margin_glyphs;
1095+
1096+
/* Make sure the marginal areas of this row are in sync with
1097+
what the window wants, when the 1st/last row of the matrix
1098+
actually displays text and not header/mode line. */
1099+
if (w->left_margin_cols > 0
1100+
&& (left != row->glyphs[TEXT_AREA] - row->glyphs[LEFT_MARGIN_AREA]))
1101+
row->glyphs[TEXT_AREA] = row->glyphs[LEFT_MARGIN_AREA] + left;
1102+
if (w->right_margin_cols > 0
1103+
&& (right != row->glyphs[LAST_AREA] - row->glyphs[RIGHT_MARGIN_AREA]))
1104+
row->glyphs[RIGHT_MARGIN_AREA] = row->glyphs[LAST_AREA] - right;
1105+
}
10681106
}
10691107

10701108

src/window.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ struct window
271271
int left_fringe_width;
272272
int right_fringe_width;
273273

274-
/* Width of left and right marginal areas in columns.
275-
A value of 0 means no margin. */
274+
/* Requested width of left and right marginal areas in columns. A
275+
value of 0 means no margin. The actual values are recorded in
276+
the window's glyph matrix, in the left_margin_glyphs and
277+
right_margin_glyphs members. */
276278
int left_margin_cols;
277279
int right_margin_cols;
278280

src/xdisp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19896,7 +19896,7 @@ display_line (struct it *it)
1989619896
}
1989719897

1989819898
/* Clear the result glyph row and enable it. */
19899-
prepare_desired_row (row);
19899+
prepare_desired_row (it->w, row, false);
1990019900

1990119901
row->y = it->current_y;
1990219902
row->start = it->start;
@@ -21535,7 +21535,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
2153521535
/* Don't extend on a previously drawn mode-line.
2153621536
This may happen if called from pos_visible_p. */
2153721537
it.glyph_row->enabled_p = false;
21538-
prepare_desired_row (it.glyph_row);
21538+
prepare_desired_row (w, it.glyph_row, true);
2153921539

2154021540
it.glyph_row->mode_line_p = 1;
2154121541

0 commit comments

Comments
 (0)