From 07a2a67e3bfd674daad7a7d8947a0ab67b4e13e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerd=20M=C3=B6llmann?= Date: Fri, 24 Jan 2025 11:18:54 +0100 Subject: [PATCH] Disable more redisplay optimizations when child frames are visible * src/xdisp.c (redisplay_internal): Disable more optimizations on a tty root frame displaying a child frame. (try_cursor_movement,(try_window_reusing_current_matrix) (try_window_id): Don't use on tty root frames displaying a child frame. --- src/xdisp.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index ba8ba1b72e3..0497490928f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -17214,7 +17214,11 @@ redisplay_internal (void) /* All text outside that line, including its final newline, must be unchanged. */ && text_outside_line_unchanged_p (w, CHARPOS (tlbufpos), - CHARPOS (tlendpos))) + CHARPOS (tlendpos)) + /* If this is a window on a tty root frame displaying a child frame, + the current matrix of W may contain glyphs of that child frame. + Don't try shortcuts that might use the current matrix in this case. */ + && !is_tty_root_frame_with_visible_child (XFRAME (w->frame))) { if (CHARPOS (tlbufpos) > BEGV && FETCH_BYTE (BYTEPOS (tlbufpos) - 1) != '\n' @@ -17279,11 +17283,7 @@ redisplay_internal (void) line and this line is the current one, because display_line above is not informed about the current-line's vpos, and cannot DTRT in that case. */ - && !hscrolling_current_line_p (w) - /* A root frame may have visible children displayed in its - current matrix, so that we can't do the below with its - current matrix. */ - && !is_tty_root_frame_with_visible_child (it.f)) + && !hscrolling_current_line_p (w)) { /* If this is not the window's last line, we must adjust the charstarts of the lines below. */ @@ -19430,6 +19430,13 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp, struct frame *f = XFRAME (w->frame); int rc = CURSOR_MOVEMENT_CANNOT_BE_USED; + + /* If this is a window on a tty root frame displaying a child frame, + the current matrix of W may contain glyphs of that child frame, + so this method is not safe to use. */ + if (is_tty_root_frame_with_visible_child (f)) + return rc; + #ifdef GLYPH_DEBUG if (inhibit_try_cursor_movement) return rc; @@ -21333,6 +21340,13 @@ static bool try_window_reusing_current_matrix (struct window *w) { struct frame *f = XFRAME (w->frame); + + /* If this is a window on a tty root frame displaying a child frame, + the current matrix of W may contain glyphs of that child frame, + so this method is not safe to use. */ + if (is_tty_root_frame_with_visible_child (f)) + return false; + struct glyph_row *bottom_row; struct it it; struct run run; @@ -22120,6 +22134,13 @@ static int try_window_id (struct window *w) { struct frame *f = XFRAME (w->frame); + + /* If this is a window on a tty root frame displaying a child frame, + the current matrix of W may contain glyphs of that child frame, + so this method is not safe to use. */ + if (is_tty_root_frame_with_visible_child (f)) + return 0; + struct glyph_matrix *current_matrix = w->current_matrix; struct glyph_matrix *desired_matrix = w->desired_matrix; struct glyph_row *last_unchanged_at_beg_row;