From: Kim F. Storm Date: Thu, 27 Jan 2005 22:33:52 +0000 (+0000) Subject: (get_phys_cursor_geometry): New function to calculate X-Git-Tag: ttn-vms-21-2-B4~2575 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2049265a5b75d5d5b4899116c27dfaafdbcd13e3;p=emacs.git (get_phys_cursor_geometry): New function to calculate phys cursor position and size for hollow cursor. Position is aligned with get_glyph_string_clip_rect and ensures that a hollow cursor is shown, even when the actual glyph is not visible. --- diff --git a/src/xdisp.c b/src/xdisp.c index e83004d1741..aec14bcadde 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1876,6 +1876,64 @@ get_glyph_string_clip_rect (s, nr) #endif } + +/* EXPORT: + Return the position and height of the phys cursor in window W. + Set w->phys_cursor_width to width of phys cursor. +*/ + +int +get_phys_cursor_geometry (w, row, glyph, heightp) + struct window *w; + struct glyph_row *row; + struct glyph *glyph; + int *heightp; +{ + struct frame *f = XFRAME (WINDOW_FRAME (w)); + int x, y, wd, h, h0, y0; + + /* Compute the width of the rectangle to draw. If on a stretch + glyph, and `x-stretch-block-cursor' is nil, don't draw a + rectangle as wide as the glyph, but use a canonical character + width instead. */ + wd = glyph->pixel_width - 1; +#ifdef HAVE_NTGUI + wd++; /* Why? */ +#endif + if (glyph->type == STRETCH_GLYPH + && !x_stretch_cursor_p) + wd = min (FRAME_COLUMN_WIDTH (f), wd); + w->phys_cursor_width = wd; + + y = w->phys_cursor.y + row->ascent - glyph->ascent; + + /* If y is below window bottom, ensure that we still see a cursor. */ + h0 = min (FRAME_LINE_HEIGHT (f), row->visible_height); + + h = max (h0, glyph->ascent + glyph->descent); + h0 = min (h0, glyph->ascent + glyph->descent); + + y0 = WINDOW_HEADER_LINE_HEIGHT (w); + if (y < y0) + { + h = max (h - (y0 - y) + 1, h0); + y = y0 - 1; + } + else + { + y0 = window_text_bottom_y (w) - h0; + if (y > y0) + { + h += y - y0; + y = y0; + } + } + + *heightp = h - 1; + return WINDOW_TO_FRAME_PIXEL_Y (w, y); +} + + #endif /* HAVE_WINDOW_SYSTEM */