From bccee4f282fc53c3cd181903e322b8d531bb0db4 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Mon, 15 Jan 2001 13:46:41 +0000 Subject: [PATCH] (save_or_restore_current_matrices): Function removed. (save_current_matrix, restore_current_matrix): New functions. (adjust_frame_glyphs_for_frame_redisplay): Use them to save and restore the frame's current matrix. Due to the glyph pointer setup done in adjust_glyph_matrix, there is no easy way to make saving the current matrix in the desired matrix generally correct, so don't try it. --- src/ChangeLog | 10 +++++++ src/dispnew.c | 73 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index eb485d740b..1bea2b4239 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2001-01-15 Gerd Moellmann + + * dispnew.c (save_or_restore_current_matrices): Function removed. + (save_current_matrix, restore_current_matrix): New functions. + (adjust_frame_glyphs_for_frame_redisplay): Use them to save and + restore the frame's current matrix. Due to the glyph pointer + setup done in adjust_glyph_matrix, there is no easy way to make + saving the current matrix in the desired matrix generally correct, + so don't try it. + 2001-01-15 Kenichi Handa * xdisp.c (insert_left_trunc_glyphs): Overwrite padding glyphs by diff --git a/src/dispnew.c b/src/dispnew.c index dff5c91719..b4a1dabc69 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -120,7 +120,8 @@ struct dim /* Function prototypes. */ -static void save_or_restore_current_matrix P_ ((struct frame *, int)); +static struct glyph_matrix *save_current_matrix P_ ((struct frame *)); +static void restore_current_matrix P_ ((struct frame *, struct glyph_matrix *)); static void fake_current_matrices P_ ((Lisp_Object)); static void redraw_overlapping_rows P_ ((struct window *, int)); static void redraw_overlapped_rows P_ ((struct window *, int)); @@ -2153,38 +2154,63 @@ fake_current_matrices (window) } -/* Save or restore the contents of frame F's current frame matrix. - SAVE_P non-zero means save it. */ +/* Save away the contents of frame F's current frame matrix. Value is + a glyph matrix holding the contents of F's current frame matrix. '*/ -static void -save_or_restore_current_matrix (f, save_p) +static struct glyph_matrix * +save_current_matrix (f) struct frame *f; - int save_p; { - struct glyph_row *from, *to, *end; + int i; + struct glyph_matrix *saved; - if (save_p) - { - from = f->current_matrix->rows; - end = from + f->current_matrix->nrows; - to = f->desired_matrix->rows; - } - else + saved = (struct glyph_matrix *) xmalloc (sizeof *saved); + bzero (saved, sizeof *saved); + saved->nrows = f->current_matrix->nrows; + saved->rows = (struct glyph_row *) xmalloc (saved->nrows + * sizeof *saved->rows); + bzero (saved->rows, saved->nrows * sizeof *saved->rows); + + for (i = 0; i < saved->nrows; ++i) { - from = f->desired_matrix->rows; - end = from + f->desired_matrix->nrows; - to = f->current_matrix->rows; + struct glyph_row *from = f->current_matrix->rows + i; + struct glyph_row *to = saved->rows + i; + size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); + to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); + bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); + to->used[TEXT_AREA] = from->used[TEXT_AREA]; } - - for (; from < end; ++from, ++to) + + return saved; +} + + +/* Restore the contents of frame F's current frame matrix from SAVED, + and free memory associated with SAVED. */ + +static void +restore_current_matrix (f, saved) + struct frame *f; + struct glyph_matrix *saved; +{ + int i; + + for (i = 0; i < saved->nrows; ++i) { + struct glyph_row *from = saved->rows + i; + struct glyph_row *to = f->current_matrix->rows + i; size_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); bcopy (from->glyphs[TEXT_AREA], to->glyphs[TEXT_AREA], nbytes); to->used[TEXT_AREA] = from->used[TEXT_AREA]; + xfree (from->glyphs[TEXT_AREA]); } + + xfree (saved->rows); + xfree (saved); } + /* Allocate/reallocate glyph matrices of a single frame F for frame-based redisplay. */ @@ -2256,9 +2282,6 @@ adjust_frame_glyphs_for_frame_redisplay (f) xassert (matrix_dim.width == FRAME_WIDTH (f) && matrix_dim.height == FRAME_HEIGHT (f)); - /* Resize frame matrices. */ - adjust_glyph_matrix (NULL, f->desired_matrix, 0, 0, matrix_dim); - /* Pointers to glyph memory in glyph rows are exchanged during the update phase of redisplay, which means in general that a frame's current matrix consists of pointers into both the @@ -2273,13 +2296,15 @@ adjust_frame_glyphs_for_frame_redisplay (f) && matrix_dim.width == f->current_matrix->matrix_w && matrix_dim.height == f->current_matrix->matrix_h) { - save_or_restore_current_matrix (f, 1); + struct glyph_matrix *copy = save_current_matrix (f); + adjust_glyph_matrix (NULL, f->desired_matrix, 0, 0, matrix_dim); adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); - save_or_restore_current_matrix (f, 0); + restore_current_matrix (f, copy); fake_current_matrices (FRAME_ROOT_WINDOW (f)); } else { + adjust_glyph_matrix (NULL, f->desired_matrix, 0, 0, matrix_dim); adjust_glyph_matrix (NULL, f->current_matrix, 0, 0, matrix_dim); SET_FRAME_GARBAGED (f); } -- 2.20.1