diff --git a/src/xdisp.c b/src/xdisp.c index 4087ff975ee..52f3ebf6f2e 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -18228,6 +18228,32 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, comes from a text property, not from an overlay. */ bool string_from_text_prop = false; + /* is_tty_selected is true iff the following hold + - W is the selected window. + - There exists at least one visible child frame whose root is the + same frame as the root of W's frame. Such a frame could overlap + the position of point in W in which case we (1) don't want to + show the cursor and (2) make sure that if point is not overlapped + by that frame, the cursor is shown. */ + bool is_tty_selected = false; + struct frame *f = WINDOW_XFRAME (w); + struct frame *r = root_frame (WINDOW_XFRAME (w)); + + Lisp_Object tail, other; + + if (w == XWINDOW (selected_window)) + FOR_EACH_FRAME (tail, other) + { + struct frame *o = XFRAME (other); + + if (FRAME_LIVE_P (o) && is_tty_child_frame (o) + && FRAME_VISIBLE_P (o) && root_frame (o) == r) + { + is_tty_selected = true; + break; + } + } + /* Don't even try doing anything if called for a mode-line or header-line or tab-line row, since the rest of the code isn't prepared to deal with such calamities. */ @@ -18309,12 +18335,17 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, while (/* not marched to end of glyph row */ glyph < end /* glyph was not inserted by redisplay for internal purposes */ - && !NILP (glyph->object)) + && (!NILP (glyph->object) || is_tty_selected)) { - if (BUFFERP (glyph->object)) + if (is_tty_selected && f != glyph->frame) + ; + else if (BUFFERP (glyph->object)) { ptrdiff_t dpos = glyph->charpos - pt_old; + if (is_tty_selected && dpos > 0) /* Overshot. */ + break; + if (glyph->charpos > bpos_max) bpos_max = glyph->charpos; if (glyph->charpos < bpos_min) @@ -18473,7 +18504,9 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, GLYPH_BEFORE and GLYPH_AFTER. */ if (!((row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end) && BUFFERP (glyph->object) && glyph->charpos == pt_old) - && !(bpos_max <= pt_old && pt_old <= bpos_covered)) + && !(bpos_max <= pt_old && pt_old <= bpos_covered) + && (!is_tty_selected + || !(row->reversed_p ? glyph > glyphs_end : glyph < glyphs_end))) { /* An empty line has a single glyph whose OBJECT is nil and whose CHARPOS is the position of a newline on that line. @@ -18786,6 +18819,13 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, } w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; w->cursor.x = x; + + if (is_tty_selected && glyph->charpos > PT) + { + w->cursor.hpos = -1; + w->cursor.x = -1; + } + w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; w->cursor.y = row->y + dy;