]> git.eshelyaron.com Git - emacs.git/commitdiff
Further fixes for cursor positioning (bug#75056)
authorGerd Möllmann <gerd@gnu.org>
Wed, 29 Jan 2025 12:42:40 +0000 (13:42 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 Jan 2025 18:13:36 +0000 (19:13 +0100)
* 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.

(cherry picked from commit 782be196e52f8912c3e26c646f04fe48cf703aca)

src/dispnew.c

index cd5f2468f93141ced6c33f44e4cf5db4a8504b73..627a9daf0bbd3bebd8504ae8f3962bad9fe62907 100644 (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
@@ -3991,10 +3993,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.  */
@@ -4063,22 +4074,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);
 
@@ -5655,13 +5664,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))
@@ -5686,10 +5694,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.  */