+2014-07-01 Eli Zaretskii <eliz@gnu.org>
+
+ * 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.
+ (Bug#17892)
+
+ * xdisp.c (display_line, display_mode_line): Call
+ prepare_desired_row with additional arguments, as appropriate.
+
+ * dispextern.h (prepare_desired_row): Adjust prototype.
+
2014-07-01 Dmitry Antipov <dmantipov@yandex.ru>
* xfaces.c (init_frame_faces): Always realize basic faces (Bug#17889).
void blank_row (struct window *, struct glyph_row *, int);
void clear_glyph_matrix_rows (struct glyph_matrix *, int, int);
void clear_glyph_row (struct glyph_row *);
-void prepare_desired_row (struct glyph_row *);
+void prepare_desired_row (struct window *, struct glyph_row *, bool);
void update_single_window (struct window *, bool);
void do_pending_window_change (bool);
void change_frame_size (struct frame *, int, int, bool, bool, bool, bool);
+ x);
if (w == NULL
- || row == matrix->rows + dim.height - 1
+ || (row == matrix->rows + dim.height - 1
+ && WINDOW_WANTS_MODELINE_P (w))
|| (row == matrix->rows && matrix->header_line_p))
{
row->glyphs[TEXT_AREA]
= xnrealloc (row->glyphs[LEFT_MARGIN_AREA],
dim.width, sizeof (struct glyph));
- /* The mode line never has marginal areas. */
- if (row == matrix->rows + dim.height - 1
+ /* The mode line, if displayed, never has marginal areas. */
+ if ((row == matrix->rows + dim.height - 1
+ && !(w && WINDOW_WANTS_MODELINE_P (w)))
|| (row == matrix->rows && matrix->header_line_p))
{
row->glyphs[TEXT_AREA]
#endif /* 0 */
-/* Prepare ROW for display. Desired rows are cleared lazily,
- i.e. they are only marked as to be cleared by setting their
+/* Prepare ROW for display in windows W. Desired rows are cleared
+ lazily, i.e. they are only marked as to be cleared by setting their
enabled_p flag to zero. When a row is to be displayed, a prior
- call to this function really clears it. */
+ call to this function really clears it. In addition, this function
+ makes sure the marginal areas of ROW are in sync with the window's
+ display margins. MODE_LINE_P non-zero means we are preparing a
+ glyph row for header line or mode line. */
void
-prepare_desired_row (struct glyph_row *row)
+prepare_desired_row (struct window *w, struct glyph_row *row, bool mode_line_p)
{
if (!row->enabled_p)
{
row->enabled_p = true;
row->reversed_p = rp;
}
+ if (mode_line_p)
+ {
+ /* Mode and header lines, if displayed, never have marginal
+ areas. If we are called with MODE_LINE_P non-zero, we are
+ displaying the mode/header line in this widnow, and so the
+ marginal areas of this glyph row should be eliminated. This
+ is needed when the mode/header line is switched on in a
+ window that has display margins. */
+ if (w->left_margin_cols > 0)
+ row->glyphs[TEXT_AREA] = row->glyphs[LEFT_MARGIN_AREA];
+ if (w->right_margin_cols > 0)
+ row->glyphs[RIGHT_MARGIN_AREA] = row->glyphs[LAST_AREA];
+ }
+ else if (row == MATRIX_MODE_LINE_ROW (w->desired_matrix)
+ || row == MATRIX_HEADER_LINE_ROW (w->desired_matrix))
+ {
+ /* The real number of glyphs reserved for the margins is
+ recorded in the glyph matrix, and can be different from
+ window's left_margin_cols and right_margin_cols; see
+ margin_glyphs_to_reserve for when that happens. */
+ int left = w->desired_matrix->left_margin_glyphs;
+ int right = w->desired_matrix->right_margin_glyphs;
+
+ /* Make sure the marginal areas of this row are in sync with
+ what the window wants, when the 1st/last row of the matrix
+ actually displays text and not header/mode line. */
+ if (w->left_margin_cols > 0
+ && (left != row->glyphs[TEXT_AREA] - row->glyphs[LEFT_MARGIN_AREA]))
+ row->glyphs[TEXT_AREA] = row->glyphs[LEFT_MARGIN_AREA] + left;
+ if (w->right_margin_cols > 0
+ && (right != row->glyphs[LAST_AREA] - row->glyphs[RIGHT_MARGIN_AREA]))
+ row->glyphs[RIGHT_MARGIN_AREA] = row->glyphs[LAST_AREA] - right;
+ }
}