@@ -449,7 +449,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
449
449
+ x );
450
450
451
451
if (w == NULL
452
- || row == matrix -> rows + dim .height - 1
452
+ || (row == matrix -> rows + dim .height - 1
453
+ && WINDOW_WANTS_MODELINE_P (w ))
453
454
|| (row == matrix -> rows && matrix -> header_line_p ))
454
455
{
455
456
row -> glyphs [TEXT_AREA ]
@@ -492,8 +493,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
492
493
= xnrealloc (row -> glyphs [LEFT_MARGIN_AREA ],
493
494
dim .width , sizeof (struct glyph ));
494
495
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 )))
497
499
|| (row == matrix -> rows && matrix -> header_line_p ))
498
500
{
499
501
row -> glyphs [TEXT_AREA ]
@@ -1049,13 +1051,16 @@ find_glyph_row_slice (struct glyph_matrix *window_matrix,
1049
1051
1050
1052
#endif /* 0 */
1051
1053
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
1054
1056
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. */
1056
1061
1057
1062
void
1058
- prepare_desired_row (struct glyph_row * row )
1063
+ prepare_desired_row (struct window * w , struct glyph_row * row , bool mode_line_p )
1059
1064
{
1060
1065
if (!row -> enabled_p )
1061
1066
{
@@ -1065,6 +1070,39 @@ prepare_desired_row (struct glyph_row *row)
1065
1070
row -> enabled_p = true;
1066
1071
row -> reversed_p = rp ;
1067
1072
}
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
+ }
1068
1106
}
1069
1107
1070
1108
0 commit comments