diff options
| author | Po Lu | 2022-01-05 14:53:57 +0800 |
|---|---|---|
| committer | Po Lu | 2022-01-05 14:53:57 +0800 |
| commit | e1626257ab984c129aaeb8de6a1e4ec5ef1d2e13 (patch) | |
| tree | fa06b5f348bd707f45325b7194ff5a39ed4c04a9 /src | |
| parent | 8875ae70a435358824e7f39b0c769c459e6a067e (diff) | |
| download | emacs-e1626257ab984c129aaeb8de6a1e4ec5ef1d2e13.tar.gz emacs-e1626257ab984c129aaeb8de6a1e4ec5ef1d2e13.zip | |
Make sure mouse face doesn't stay on the cursor after it is cleared
cursor_in_mouse_face_p will still return true when the phys
cursor is drawn inside show_mouse_face when called by
clear_mouse_face, since that drawing happens before
hlinfo->mouse_face_window can be set to nil.
However, the row's mouse_face_p will be adjusted before the
cursor is drawn in show_mouse_face, so it can be used to
determine if the cursor is actually under mouse face.
* src/xdisp.c (fill_composite_glyph_string):
(fill_gstring_glyph_string):
(fill_glyphless_glyph_string):
(fill_glyph_string):
(fill_xwidget_glyph_string):
(fill_stretch_glyph_string): Only apply mouse face when
DRAW_CURSOR if the row is also mouse_face_p.
(set_glyph_string_background_width): Only adjust width if the
row holding the cursor is also mouse_face_p.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 0635cad0d19..2326df4300d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -28549,7 +28549,10 @@ fill_composite_glyph_string (struct glyph_string *s, struct face *base_face, | |||
| 28549 | } | 28549 | } |
| 28550 | 28550 | ||
| 28551 | if (s->hl == DRAW_MOUSE_FACE | 28551 | if (s->hl == DRAW_MOUSE_FACE |
| 28552 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28552 | || (s->hl == DRAW_CURSOR |
| 28553 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28554 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28555 | && cursor_in_mouse_face_p (s->w))) | ||
| 28553 | { | 28556 | { |
| 28554 | int c = COMPOSITION_GLYPH (s->cmp, 0); | 28557 | int c = COMPOSITION_GLYPH (s->cmp, 0); |
| 28555 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28558 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| @@ -28598,7 +28601,10 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, | |||
| 28598 | s->cmp_from = glyph->slice.cmp.from; | 28601 | s->cmp_from = glyph->slice.cmp.from; |
| 28599 | s->cmp_to = glyph->slice.cmp.to + 1; | 28602 | s->cmp_to = glyph->slice.cmp.to + 1; |
| 28600 | if (s->hl == DRAW_MOUSE_FACE | 28603 | if (s->hl == DRAW_MOUSE_FACE |
| 28601 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28604 | || (s->hl == DRAW_CURSOR |
| 28605 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28606 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28607 | && cursor_in_mouse_face_p (s->w))) | ||
| 28602 | { | 28608 | { |
| 28603 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28609 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28604 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28610 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -28664,7 +28670,10 @@ fill_glyphless_glyph_string (struct glyph_string *s, int face_id, | |||
| 28664 | s->face = FACE_FROM_ID (s->f, face_id); | 28670 | s->face = FACE_FROM_ID (s->f, face_id); |
| 28665 | s->font = s->face->font ? s->face->font : FRAME_FONT (s->f); | 28671 | s->font = s->face->font ? s->face->font : FRAME_FONT (s->f); |
| 28666 | if (s->hl == DRAW_MOUSE_FACE | 28672 | if (s->hl == DRAW_MOUSE_FACE |
| 28667 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28673 | || (s->hl == DRAW_CURSOR |
| 28674 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28675 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28676 | && cursor_in_mouse_face_p (s->w))) | ||
| 28668 | { | 28677 | { |
| 28669 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28678 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28670 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28679 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -28736,7 +28745,10 @@ fill_glyph_string (struct glyph_string *s, int face_id, | |||
| 28736 | s->font = s->face->font; | 28745 | s->font = s->face->font; |
| 28737 | 28746 | ||
| 28738 | if (s->hl == DRAW_MOUSE_FACE | 28747 | if (s->hl == DRAW_MOUSE_FACE |
| 28739 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28748 | || (s->hl == DRAW_CURSOR |
| 28749 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28750 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28751 | && cursor_in_mouse_face_p (s->w))) | ||
| 28740 | { | 28752 | { |
| 28741 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28753 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28742 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28754 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -28778,7 +28790,10 @@ fill_image_glyph_string (struct glyph_string *s) | |||
| 28778 | s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); | 28790 | s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); |
| 28779 | s->font = s->face->font; | 28791 | s->font = s->face->font; |
| 28780 | if (s->hl == DRAW_MOUSE_FACE | 28792 | if (s->hl == DRAW_MOUSE_FACE |
| 28781 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28793 | || (s->hl == DRAW_CURSOR |
| 28794 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28795 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28796 | && cursor_in_mouse_face_p (s->w))) | ||
| 28782 | { | 28797 | { |
| 28783 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28798 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28784 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28799 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -28801,7 +28816,10 @@ fill_xwidget_glyph_string (struct glyph_string *s) | |||
| 28801 | s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); | 28816 | s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); |
| 28802 | s->font = s->face->font; | 28817 | s->font = s->face->font; |
| 28803 | if (s->hl == DRAW_MOUSE_FACE | 28818 | if (s->hl == DRAW_MOUSE_FACE |
| 28804 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28819 | || (s->hl == DRAW_CURSOR |
| 28820 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28821 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28822 | && cursor_in_mouse_face_p (s->w))) | ||
| 28805 | { | 28823 | { |
| 28806 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28824 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28807 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28825 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -28835,7 +28853,10 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end) | |||
| 28835 | s->face = FACE_FROM_ID (s->f, face_id); | 28853 | s->face = FACE_FROM_ID (s->f, face_id); |
| 28836 | s->font = s->face->font; | 28854 | s->font = s->face->font; |
| 28837 | if (s->hl == DRAW_MOUSE_FACE | 28855 | if (s->hl == DRAW_MOUSE_FACE |
| 28838 | || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w))) | 28856 | || (s->hl == DRAW_CURSOR |
| 28857 | && MATRIX_ROW (s->w->current_matrix, | ||
| 28858 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 28859 | && cursor_in_mouse_face_p (s->w))) | ||
| 28839 | { | 28860 | { |
| 28840 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); | 28861 | Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f); |
| 28841 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); | 28862 | s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id); |
| @@ -29122,6 +29143,8 @@ set_glyph_string_background_width (struct glyph_string *s, int start, int last_x | |||
| 29122 | #ifdef HAVE_WINDOW_SYSTEM | 29143 | #ifdef HAVE_WINDOW_SYSTEM |
| 29123 | if (FRAME_WINDOW_P (s->f) | 29144 | if (FRAME_WINDOW_P (s->f) |
| 29124 | && s->hl == DRAW_CURSOR | 29145 | && s->hl == DRAW_CURSOR |
| 29146 | && MATRIX_ROW (s->w->current_matrix, | ||
| 29147 | s->w->phys_cursor.vpos)->mouse_face_p | ||
| 29125 | && cursor_in_mouse_face_p (s->w)) | 29148 | && cursor_in_mouse_face_p (s->w)) |
| 29126 | { | 29149 | { |
| 29127 | /* Adjust the background width of the glyph string, because | 29150 | /* Adjust the background width of the glyph string, because |