comparison src/xterm.c @ 44881:d1160796ccc1

(x_draw_phys_cursor_glyph): Undo last change. Compute phys_cursor_width from the x position returned by x_draw_glyhs, which is cheaper. (x_display_and_set_cursor): Compute the buffer-local value of `cursor-in-non-selected-windows' only when needed.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 26 Apr 2002 17:55:46 +0000
parents b2c04d1e30ff
children cc9283570d1b
comparison
equal deleted inserted replaced
44880:e772dea9fb2e 44881:d1160796ccc1
11466 happen in mini-buffer windows when switching between echo area 11466 happen in mini-buffer windows when switching between echo area
11467 glyphs and mini-buffer. */ 11467 glyphs and mini-buffer. */
11468 if (w->phys_cursor.hpos < row->used[TEXT_AREA]) 11468 if (w->phys_cursor.hpos < row->used[TEXT_AREA])
11469 { 11469 {
11470 int on_p = w->phys_cursor_on_p; 11470 int on_p = w->phys_cursor_on_p;
11471 int x1;
11471 11472
11472 x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, 11473 x1 = x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
11473 w->phys_cursor.hpos, w->phys_cursor.hpos + 1, 11474 w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
11474 hl, 0); 11475 hl, 0);
11475 w->phys_cursor_on_p = on_p; 11476 w->phys_cursor_on_p = on_p;
11476 11477
11477 if (hl == DRAW_CURSOR) 11478 if (hl == DRAW_CURSOR)
11478 { 11479 w->phys_cursor_width = x1 - w->phys_cursor.x;
11479 struct glyph *cursor_glyph = get_phys_cursor_glyph (w);
11480 if (cursor_glyph)
11481 {
11482 if (x_stretch_cursor_p)
11483 w->phys_cursor_width = cursor_glyph->pixel_width;
11484 else
11485 w->phys_cursor_width = min (CANON_X_UNIT (XFRAME (w->frame)),
11486 cursor_glyph->pixel_width);
11487 }
11488 }
11489 11480
11490 /* When we erase the cursor, and ROW is overlapped by other 11481 /* When we erase the cursor, and ROW is overlapped by other
11491 rows, make sure that these overlapping parts of other rows 11482 rows, make sure that these overlapping parts of other rows
11492 are redrawn. */ 11483 are redrawn. */
11493 else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p) 11484 else if (hl == DRAW_NORMAL_TEXT && row->overlapped_p)
11642 int new_cursor_type; 11633 int new_cursor_type;
11643 int new_cursor_width; 11634 int new_cursor_width;
11644 struct glyph_matrix *current_glyphs; 11635 struct glyph_matrix *current_glyphs;
11645 struct glyph_row *glyph_row; 11636 struct glyph_row *glyph_row;
11646 struct glyph *glyph; 11637 struct glyph *glyph;
11647 int cursor_non_selected;
11648 11638
11649 /* This is pointless on invisible frames, and dangerous on garbaged 11639 /* This is pointless on invisible frames, and dangerous on garbaged
11650 windows and frames; in the latter case, the frame or window may 11640 windows and frames; in the latter case, the frame or window may
11651 be in the midst of changing its size, and x and y may be off the 11641 be in the midst of changing its size, and x and y may be off the
11652 window. */ 11642 window. */
11678 mini-buffer window, we want the cursor only to appear if we are 11668 mini-buffer window, we want the cursor only to appear if we are
11679 reading input from this window. For the selected window, we want 11669 reading input from this window. For the selected window, we want
11680 the cursor type given by the frame parameter. If explicitly 11670 the cursor type given by the frame parameter. If explicitly
11681 marked off, draw no cursor. In all other cases, we want a hollow 11671 marked off, draw no cursor. In all other cases, we want a hollow
11682 box cursor. */ 11672 box cursor. */
11683 cursor_non_selected
11684 = !NILP (Fbuffer_local_value (Qcursor_in_non_selected_windows,
11685 w->buffer));
11686 new_cursor_width = -1; 11673 new_cursor_width = -1;
11687 if (cursor_in_echo_area 11674 if (cursor_in_echo_area
11688 && FRAME_HAS_MINIBUF_P (f) 11675 && FRAME_HAS_MINIBUF_P (f)
11689 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window)) 11676 && EQ (FRAME_MINIBUF_WINDOW (f), echo_area_window))
11690 { 11677 {
11691 if (w == XWINDOW (echo_area_window)) 11678 if (w == XWINDOW (echo_area_window))
11692 new_cursor_type = FRAME_DESIRED_CURSOR (f); 11679 new_cursor_type = FRAME_DESIRED_CURSOR (f);
11693 else if (cursor_non_selected) 11680 else if (!NILP (Fbuffer_local_value (Qcursor_in_non_selected_windows,
11681 w->buffer)))
11694 new_cursor_type = HOLLOW_BOX_CURSOR; 11682 new_cursor_type = HOLLOW_BOX_CURSOR;
11695 else 11683 else
11696 new_cursor_type = NO_CURSOR; 11684 new_cursor_type = NO_CURSOR;
11697 } 11685 }
11698 else 11686 else
11699 { 11687 {
11700 if (f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame 11688 if (f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame
11701 || w != XWINDOW (f->selected_window)) 11689 || w != XWINDOW (f->selected_window))
11702 { 11690 {
11703 if ((MINI_WINDOW_P (w) && minibuf_level == 0) 11691 if ((MINI_WINDOW_P (w) && minibuf_level == 0)
11704 || !cursor_non_selected 11692 || NILP (Fbuffer_local_value (Qcursor_in_non_selected_windows,
11693 w->buffer))
11705 || NILP (XBUFFER (w->buffer)->cursor_type)) 11694 || NILP (XBUFFER (w->buffer)->cursor_type))
11706 new_cursor_type = NO_CURSOR; 11695 new_cursor_type = NO_CURSOR;
11707 else 11696 else
11708 new_cursor_type = HOLLOW_BOX_CURSOR; 11697 new_cursor_type = HOLLOW_BOX_CURSOR;
11709 } 11698 }
11738 || new_cursor_type != w->phys_cursor_type 11727 || new_cursor_type != w->phys_cursor_type
11739 || (new_cursor_type == BAR_CURSOR 11728 || (new_cursor_type == BAR_CURSOR
11740 && new_cursor_width != w->phys_cursor_width))) 11729 && new_cursor_width != w->phys_cursor_width)))
11741 x_erase_phys_cursor (w); 11730 x_erase_phys_cursor (w);
11742 11731
11743 /* If the cursor is now invisible and we want it to be visible, 11732 /* Don't check phys_cursor_on_p here because that flag is only set
11744 display it. */ 11733 to zero in some cases where we know that the cursor has been
11745 if (on && !w->phys_cursor_on_p) 11734 completely erased, to avoid the extra work of erasing the cursor
11735 twice. In other words, phys_cursor_on_p can be 1 and the cursor
11736 still not be visible, or it has only been partly erased. */
11737 if (on)
11746 { 11738 {
11747 w->phys_cursor_ascent = glyph_row->ascent; 11739 w->phys_cursor_ascent = glyph_row->ascent;
11748 w->phys_cursor_height = glyph_row->height; 11740 w->phys_cursor_height = glyph_row->height;
11749 11741
11750 /* Set phys_cursor_.* before x_draw_.* is called because some 11742 /* Set phys_cursor_.* before x_draw_.* is called because some