Further fixes for cursor positioning (bug#75056)

* src/dispnew.c (write_matrix): Don't set the cursor here. Parameter to
set the cursor or not removed.
(combine_updates_for_frame): Call tty_set_cursor here, depending on
whether or not the selected frame is related to the updated frame.
(update_frame_with_menu): Adapt to change of write_matrix.
This commit is contained in:
Gerd Möllmann 2025-01-29 13:42:40 +01:00
parent 7aacefba6b
commit 782be196e5

View file

@ -95,12 +95,14 @@ static void check_matrix_pointers (struct glyph_matrix *,
static void mirror_line_dance (struct window *, int, int, int *, char *);
static void update_window_tree (struct window *);
static void update_window (struct window *);
static void write_matrix (struct frame *, bool, bool, bool);
static void write_matrix (struct frame *, bool, bool);
static void scrolling (struct frame *);
static void set_window_cursor_after_update (struct window *);
static void adjust_frame_glyphs_for_window_redisplay (struct frame *);
static void adjust_frame_glyphs_for_frame_redisplay (struct frame *);
static void set_window_update_flags (struct window *w, bool on_p);
static void tty_set_cursor (struct frame *f);
#if 0 /* Please leave this in as a debugging aid. */
static void
@ -3994,10 +3996,19 @@ combine_updates_for_frame (struct frame *f, bool inhibit_scrolling)
}
update_begin (root);
write_matrix (root, inhibit_scrolling, 1, false);
write_matrix (root, inhibit_scrolling, false);
make_matrix_current (root);
update_end (root);
/* The selected frame determines where the cursor on ttys goes, except
when it is a frame that is completely unrelated to the frame being
displayed. This can happen with multi-tty, when the selected frame
can be a window-system frame. */
if (frame_ancestor_p (root, SELECTED_FRAME ()))
tty_set_cursor (SELECTED_FRAME ());
else
tty_set_cursor (root);
/* If a child is displayed, and the cursor is displayed in another
frame, the child might lay above the cursor, so that it appears to
"shine through" the child. Avoid that because it's confusing. */
@ -4066,22 +4077,20 @@ void
update_frame_with_menu (struct frame *f, int row, int col)
{
struct window *root_window = XWINDOW (f->root_window);
bool cursor_at_point_p;
eassert (FRAME_TERMCAP_P (f));
/* Update the display. */
update_begin (f);
cursor_at_point_p = !(row >= 0 && col >= 0);
/* Do not stop due to pending input, and do not try scrolling. This
means that write_glyphs will always return false. */
write_matrix (f, 1, cursor_at_point_p, true);
write_matrix (f, true, true);
make_matrix_current (f);
clear_desired_matrices (f);
/* ROW and COL tell us where in the menu to position the cursor, so
that screen readers know the active region on the screen. */
if (!cursor_at_point_p)
if (row >= 0 && col >= 0)
cursor_to (f, row, col);
else
tty_set_cursor (f);
update_end (f);
flush_terminal (f);
@ -5658,13 +5667,12 @@ tty_set_cursor (struct frame *f)
}
}
/* Write desired matix of tty frame F and make it current.
/* Write desired matrix of tty frame F and make it current.
INHIBIT_ID_P means that scrolling by insert/delete should not be tried.
SET_CURSOR_P false means do not set cursor at point in selected window. */
UPDATING_MENU_P true means we are called for updating a tty menu. */
static void
write_matrix (struct frame *f, bool inhibit_id_p,
bool set_cursor_p, bool updating_menu_p)
write_matrix (struct frame *f, bool inhibit_id_p, bool updating_menu_p)
{
/* If we cannot insert/delete lines, it's no use trying it. */
if (!FRAME_LINE_INS_DEL_OK (f))
@ -5689,10 +5697,6 @@ write_matrix (struct frame *f, bool inhibit_id_p,
for (int i = first_row; i < last_row; ++i)
if (MATRIX_ROW_ENABLED_P (f->desired_matrix, i))
write_row (f, i, updating_menu_p);
/* Now just clean up termcap drivers and set cursor, etc. */
if (set_cursor_p)
tty_set_cursor (f);
}
/* Do line insertions/deletions on frame F for frame-based redisplay. */