]> git.eshelyaron.com Git - emacs.git/commitdiff
Change interface of prepare_desired_root_row
authorGerd Möllmann <gerd@gnu.org>
Sun, 10 Nov 2024 15:19:40 +0000 (16:19 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 23 Dec 2024 14:54:24 +0000 (15:54 +0100)
* src/dispnew.c (prepare_desired_root_row): Return NULL if we can't
prepare the row.
(produce_box_line, copy_child_glyphs): Callers changed accordingly.

(cherry picked from commit 437ccbe612b377fd5ac492572702978ec75ea0df)

src/dispnew.c

index 62339604f4e2050b5a3b7c594f5f6b86b01dd4a6..06666e31873082acdc06af5e0931e30d0c211da7 100644 (file)
@@ -3516,28 +3516,32 @@ make_matrix_current (struct frame *f)
        make_current (f, NULL, i);
 }
 
-/* Prepare ROOT's desired row at index Y for copying child
-   frame contents to it.  */
+/* Prepare ROOT's desired row at index Y for copying child frame
+   contents to it.  Value is the prepared desired row or NULL if we
+   don't have, and can't contruct a desired row.  */
 
 static struct glyph_row *
 prepare_desired_root_row (struct frame *root, int y)
 {
-  /* Start with the root's desired matrix row.  If that hasn't been
-     redisplayed, copy from the root's current matrix.  */
-  struct glyph_row *root_row = MATRIX_ROW (root->desired_matrix, y);
+  /* If we have a desired row that has been displayed, use that.  */
+  struct glyph_row *desired_row = MATRIX_ROW (root->desired_matrix, y);
+  if (desired_row->enabled_p)
+    return desired_row;
+
+  /* If we have a current row that is up to date, copy that to the
+     desired row and use that.  */
   /* Don't copy rows that aren't enabled, in particuler because they
      might not have the 'frame' member of glyphs set.  */
-  if (!root_row->enabled_p)
+  struct glyph_row *current_row = MATRIX_ROW (root->current_matrix, y);
+  if (current_row->enabled_p)
     {
-      struct glyph_row *from = MATRIX_ROW (root->current_matrix, y);
-      if (from->enabled_p)
-       {
-         memcpy (root_row->glyphs[0], from->glyphs[0],
-                 root->current_matrix->matrix_w * sizeof (struct glyph));
-         root_row->enabled_p = true;
-       }
+      memcpy (desired_row->glyphs[0], current_row->glyphs[0],
+             root->current_matrix->matrix_w * sizeof (struct glyph));
+      desired_row->enabled_p = true;
+      return desired_row;
     }
-  return root_row;
+
+  return NULL;
 }
 
 /* Change GLYPH to be a space glyph.  */
@@ -3664,6 +3668,8 @@ produce_box_line (struct frame *root, struct frame *child, int x, int y, int w,
                  bool first)
 {
   struct glyph_row *root_row = prepare_desired_root_row (root, y);
+  if (root_row == NULL)
+    return;
   if (first)
     produce_box_sides (BOX_DOWN_RIGHT, BOX_DOWN_LEFT, root_row, x, w, root, child);
   else
@@ -3700,8 +3706,9 @@ copy_child_glyphs (struct frame *root, struct frame *child)
       for (int y = r.y; y < r.y + r.h; ++y)
        {
          struct glyph_row *root_row = prepare_desired_root_row (root, y);
-         produce_box_sides (BOX_VERTICAL, BOX_VERTICAL, root_row, r.x, r.w,
-                            root, child);
+         if (root_row)
+           produce_box_sides (BOX_VERTICAL, BOX_VERTICAL, root_row, r.x, r.w,
+                              root, child);
        }
 
       /* Horizontal line below.  */
@@ -3719,6 +3726,8 @@ copy_child_glyphs (struct frame *root, struct frame *child)
   for (int y = r.y; y < r.y + r.h; ++y, ++child_y)
     {
       struct glyph_row *root_row = prepare_desired_root_row (root, y);
+      if (root_row == NULL)
+       continue;
 
       /* Deal with wide characters unless already done as part of
         drawing a box around the child frame.  */