]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #17892 with mode/header line and display margins.
authorEli Zaretskii <eliz@gnu.org>
Tue, 1 Jul 2014 17:07:24 +0000 (20:07 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 1 Jul 2014 17:07:24 +0000 (20:07 +0300)
 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.

src/ChangeLog
src/dispextern.h
src/dispnew.c
src/window.h
src/xdisp.c

index 4d3037d683c3c48359a316e7af30ebd2a2539da9..f84fe133c7edc21ea42844501e1e4aebf6b42788 100644 (file)
@@ -1,3 +1,16 @@
+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).
index 6027d5ee7ed89affb564f3ce14c42693af0b8b41..46ed99844e7debcdb75806241f6f6b84f69be191 100644 (file)
@@ -3473,7 +3473,7 @@ void increment_matrix_positions (struct glyph_matrix *,
 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);
index 163780952a6e0c0facf0fd7f0e7b3962d840378d..e20d592e19e5a47232671900ccd241c3ef6ae5bc 100644 (file)
@@ -449,7 +449,8 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
               + 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]
@@ -492,8 +493,9 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
                = 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]
@@ -1049,13 +1051,16 @@ find_glyph_row_slice (struct glyph_matrix *window_matrix,
 
 #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)
     {
@@ -1065,6 +1070,39 @@ prepare_desired_row (struct glyph_row *row)
       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;
+    }
 }
 
 
index bdc5dddb7e52c64b8b07ae1fa3c7e1ebadfeb0d9..b9c2b1f5ba83873d25f08113e75cab1ec6efe74d 100644 (file)
@@ -271,8 +271,10 @@ struct window
     int left_fringe_width;
     int right_fringe_width;
 
-    /* Width of left and right marginal areas in columns.
-       A value of 0 means no margin.  */
+    /* Requested width of left and right marginal areas in columns.  A
+       value of 0 means no margin.  The actual values are recorded in
+       the window's glyph matrix, in the left_margin_glyphs and
+       right_margin_glyphs members.  */
     int left_margin_cols;
     int right_margin_cols;
 
index 1106e6fe25f447ca9b4152cb6362a1593a470952..459edf4367fc7ef42003afab9aeef6a25a36863c 100644 (file)
@@ -19896,7 +19896,7 @@ display_line (struct it *it)
     }
 
   /* Clear the result glyph row and enable it.  */
-  prepare_desired_row (row);
+  prepare_desired_row (it->w, row, false);
 
   row->y = it->current_y;
   row->start = it->start;
@@ -21535,7 +21535,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
   /* Don't extend on a previously drawn mode-line.
      This may happen if called from pos_visible_p.  */
   it.glyph_row->enabled_p = false;
-  prepare_desired_row (it.glyph_row);
+  prepare_desired_row (w, it.glyph_row, true);
 
   it.glyph_row->mode_line_p = 1;