aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2021-10-14 18:38:26 +0800
committerEli Zaretskii2021-10-17 14:46:55 +0300
commit2028df7826bb2c2909b2aaeba47282ca70c514e3 (patch)
tree3927400069c36a3825feadeabd33d82e20c87a0b /src
parent5a5651a2f927b7758dfdf36953073f1f1a9920f9 (diff)
downloademacs-2028df7826bb2c2909b2aaeba47282ca70c514e3.tar.gz
emacs-2028df7826bb2c2909b2aaeba47282ca70c514e3.zip
Fix minor issues with text display when cursor is in mouse face
* src/xdisp.c (get_cursor_offset_for_mouse_face): Don't calculate offsets for the glyph the cursor is on, and move some logic to get_glyph_pixel_width_delta_for_mouse_face. (fill_composite_glyph_string) (fill_gstring_glyph_string) (fill_glyphless_glyph_string) (fill_glyph_string) (fill_image_glyph_string) (fill_xwidget_glyph_string) (fill_stretch_glyph_string): Set s->face to mouse face whenever appropriate. (get_glyph_pixel_width_delta_for_mouse_face): New function. (set_glyph_string_background_width): Update background width and s->width to take into account differing :box properties of the mouse face, when producing strings for the cursor. (erase_phys_cursor): Redraw mouse face when erasing a cursor on top of the mouse face. * src/xterm.c (x_set_mouse_face_gc): Stop setting s->face when under mouse face because redisplay now does that for us. * src/w32term.c (w32_set_mouse_face_gc): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c16
-rw-r--r--src/xdisp.c244
-rw-r--r--src/xterm.c16
3 files changed, 180 insertions, 96 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 9cf250cd73f..07a5cd35649 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -954,22 +954,6 @@ w32_set_cursor_gc (struct glyph_string *s)
954static void 954static void
955w32_set_mouse_face_gc (struct glyph_string *s) 955w32_set_mouse_face_gc (struct glyph_string *s)
956{ 956{
957 int face_id;
958 struct face *face;
959
960 /* What face has to be used last for the mouse face? */
961 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
962 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
963 if (face == NULL)
964 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
965
966 if (s->first_glyph->type == CHAR_GLYPH)
967 face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch, -1, Qnil);
968 else
969 face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil);
970 s->face = FACE_FROM_ID (s->f, face_id);
971 prepare_face_for_display (s->f, s->face);
972
973 /* If font in this face is same as S->font, use it. */ 957 /* If font in this face is same as S->font, use it. */
974 if (s->font == s->face->font) 958 if (s->font == s->face->font)
975 s->gc = s->face->gc; 959 s->gc = s->face->gc;
diff --git a/src/xdisp.c b/src/xdisp.c
index f4ea7de1907..7fb6cb8bfdb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1179,6 +1179,11 @@ static void append_stretch_glyph (struct it *, Lisp_Object,
1179static Lisp_Object get_it_property (struct it *, Lisp_Object); 1179static Lisp_Object get_it_property (struct it *, Lisp_Object);
1180static Lisp_Object calc_line_height_property (struct it *, Lisp_Object, 1180static Lisp_Object calc_line_height_property (struct it *, Lisp_Object,
1181 struct font *, int, bool); 1181 struct font *, int, bool);
1182static int get_glyph_pixel_width_delta_for_mouse_face (struct glyph *,
1183 struct glyph_row *,
1184 struct window *,
1185 struct face *,
1186 struct face *);
1182static void get_cursor_offset_for_mouse_face (struct window *w, 1187static void get_cursor_offset_for_mouse_face (struct window *w,
1183 struct glyph_row *row, 1188 struct glyph_row *row,
1184 int *offset); 1189 int *offset);
@@ -28125,6 +28130,20 @@ fill_composite_glyph_string (struct glyph_string *s, struct face *base_face,
28125 s->font = s->face->font; 28130 s->font = s->face->font;
28126 } 28131 }
28127 28132
28133 if (s->hl == DRAW_MOUSE_FACE
28134 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28135 {
28136 int c = COMPOSITION_GLYPH (s->cmp, 0);
28137 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28138 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28139
28140 if (!s->face)
28141 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28142
28143 s->face = FACE_FROM_ID (s->f, FACE_FOR_CHAR (s->f, s->face, c, -1, Qnil));
28144 prepare_face_for_display (s->f, s->face);
28145 }
28146
28128 /* All glyph strings for the same composition has the same width, 28147 /* All glyph strings for the same composition has the same width,
28129 i.e. the width set for the first component of the composition. */ 28148 i.e. the width set for the first component of the composition. */
28130 s->width = s->first_glyph->pixel_width; 28149 s->width = s->first_glyph->pixel_width;
@@ -28161,7 +28180,17 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
28161 s->cmp_id = glyph->u.cmp.id; 28180 s->cmp_id = glyph->u.cmp.id;
28162 s->cmp_from = glyph->slice.cmp.from; 28181 s->cmp_from = glyph->slice.cmp.from;
28163 s->cmp_to = glyph->slice.cmp.to + 1; 28182 s->cmp_to = glyph->slice.cmp.to + 1;
28164 s->face = FACE_FROM_ID (s->f, face_id); 28183 if (s->hl == DRAW_MOUSE_FACE
28184 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28185 {
28186 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28187 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28188 if (!s->face)
28189 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28190 prepare_face_for_display (s->f, s->face);
28191 }
28192 else
28193 s->face = FACE_FROM_ID (s->f, face_id);
28165 lgstring = composition_gstring_from_id (s->cmp_id); 28194 lgstring = composition_gstring_from_id (s->cmp_id);
28166 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring)); 28195 s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
28167 /* The width of a composition glyph string is the sum of the 28196 /* The width of a composition glyph string is the sum of the
@@ -28217,6 +28246,15 @@ fill_glyphless_glyph_string (struct glyph_string *s, int face_id,
28217 voffset = glyph->voffset; 28246 voffset = glyph->voffset;
28218 s->face = FACE_FROM_ID (s->f, face_id); 28247 s->face = FACE_FROM_ID (s->f, face_id);
28219 s->font = s->face->font ? s->face->font : FRAME_FONT (s->f); 28248 s->font = s->face->font ? s->face->font : FRAME_FONT (s->f);
28249 if (s->hl == DRAW_MOUSE_FACE
28250 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28251 {
28252 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28253 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28254 if (!s->face)
28255 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28256 prepare_face_for_display (s->f, s->face);
28257 }
28220 s->nchars = 1; 28258 s->nchars = 1;
28221 s->width = glyph->pixel_width; 28259 s->width = glyph->pixel_width;
28222 glyph++; 28260 glyph++;
@@ -28280,6 +28318,19 @@ fill_glyph_string (struct glyph_string *s, int face_id,
28280 28318
28281 s->font = s->face->font; 28319 s->font = s->face->font;
28282 28320
28321 if (s->hl == DRAW_MOUSE_FACE
28322 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28323 {
28324 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28325 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28326 if (!s->face)
28327 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28328 s->face
28329 = FACE_FROM_ID (s->f, FACE_FOR_CHAR (s->f, s->face,
28330 s->first_glyph->u.ch, -1, Qnil));
28331 prepare_face_for_display (s->f, s->face);
28332 }
28333
28283 /* If the specified font could not be loaded, use the frame's font, 28334 /* If the specified font could not be loaded, use the frame's font,
28284 but record the fact that we couldn't load it in 28335 but record the fact that we couldn't load it in
28285 S->font_not_found_p so that we can draw rectangles for the 28336 S->font_not_found_p so that we can draw rectangles for the
@@ -28309,6 +28360,15 @@ fill_image_glyph_string (struct glyph_string *s)
28309 s->slice = s->first_glyph->slice.img; 28360 s->slice = s->first_glyph->slice.img;
28310 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 28361 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
28311 s->font = s->face->font; 28362 s->font = s->face->font;
28363 if (s->hl == DRAW_MOUSE_FACE
28364 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28365 {
28366 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28367 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28368 if (!s->face)
28369 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28370 prepare_face_for_display (s->f, s->face);
28371 }
28312 s->width = s->first_glyph->pixel_width; 28372 s->width = s->first_glyph->pixel_width;
28313 28373
28314 /* Adjust base line for subscript/superscript text. */ 28374 /* Adjust base line for subscript/superscript text. */
@@ -28323,6 +28383,15 @@ fill_xwidget_glyph_string (struct glyph_string *s)
28323 eassert (s->first_glyph->type == XWIDGET_GLYPH); 28383 eassert (s->first_glyph->type == XWIDGET_GLYPH);
28324 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id); 28384 s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
28325 s->font = s->face->font; 28385 s->font = s->face->font;
28386 if (s->hl == DRAW_MOUSE_FACE
28387 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28388 {
28389 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28390 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28391 if (!s->face)
28392 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28393 prepare_face_for_display (s->f, s->face);
28394 }
28326 s->width = s->first_glyph->pixel_width; 28395 s->width = s->first_glyph->pixel_width;
28327 s->ybase += s->first_glyph->voffset; 28396 s->ybase += s->first_glyph->voffset;
28328 s->xwidget = s->first_glyph->u.xwidget; 28397 s->xwidget = s->first_glyph->u.xwidget;
@@ -28348,6 +28417,15 @@ fill_stretch_glyph_string (struct glyph_string *s, int start, int end)
28348 face_id = glyph->face_id; 28417 face_id = glyph->face_id;
28349 s->face = FACE_FROM_ID (s->f, face_id); 28418 s->face = FACE_FROM_ID (s->f, face_id);
28350 s->font = s->face->font; 28419 s->font = s->face->font;
28420 if (s->hl == DRAW_MOUSE_FACE
28421 || (s->hl == DRAW_CURSOR && cursor_in_mouse_face_p (s->w)))
28422 {
28423 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (s->f);
28424 s->face = FACE_FROM_ID_OR_NULL (s->f, hlinfo->mouse_face_face_id);
28425 if (!s->face)
28426 s->face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
28427 prepare_face_for_display (s->f, s->face);
28428 }
28351 s->width = glyph->pixel_width; 28429 s->width = glyph->pixel_width;
28352 s->nchars = 1; 28430 s->nchars = 1;
28353 voffset = glyph->voffset; 28431 voffset = glyph->voffset;
@@ -28595,7 +28673,12 @@ right_overwriting (struct glyph_string *s)
28595 28673
28596/* Set background width of glyph string S. START is the index of the 28674/* Set background width of glyph string S. START is the index of the
28597 first glyph following S. LAST_X is the right-most x-position + 1 28675 first glyph following S. LAST_X is the right-most x-position + 1
28598 in the drawing area. */ 28676 in the drawing area.
28677
28678 If S's hl is DRAW_CURSOR, S->f is a window system frame, and the
28679 cursor in S's window is currently under mouse face, s->width will
28680 also be updated to take into account differing :box properties
28681 between the original face and the mouse face. */
28599 28682
28600static void 28683static void
28601set_glyph_string_background_width (struct glyph_string *s, int start, int last_x) 28684set_glyph_string_background_width (struct glyph_string *s, int start, int last_x)
@@ -28617,7 +28700,28 @@ set_glyph_string_background_width (struct glyph_string *s, int start, int last_x
28617 if (s->extends_to_end_of_line_p) 28700 if (s->extends_to_end_of_line_p)
28618 s->background_width = last_x - s->x + 1; 28701 s->background_width = last_x - s->x + 1;
28619 else 28702 else
28620 s->background_width = s->width; 28703 {
28704 s->background_width = s->width;
28705#ifdef HAVE_WINDOW_SYSTEM
28706 if (FRAME_WINDOW_P (s->f)
28707 && s->hl == DRAW_CURSOR
28708 && cursor_in_mouse_face_p (s->w))
28709 {
28710 /* We will have to adjust the background width of the string
28711 in this situation, because the glyph's pixel_width might
28712 be inconsistent with the box of the mouse face, which
28713 leads to an ugly over-wide cursor. */
28714
28715 struct glyph *g = s->first_glyph;
28716 struct face *regular_face = FACE_FROM_ID (s->f, g->face_id);
28717 s->background_width +=
28718 get_glyph_pixel_width_delta_for_mouse_face (g, s->row, s->w,
28719 regular_face, s->face);
28720 /* s->width is probably worth adjusting here as well. */
28721 s->width = s->background_width;
28722 }
28723#endif
28724 }
28621} 28725}
28622 28726
28623 28727
@@ -31752,10 +31856,6 @@ erase_phys_cursor (struct window *w)
31752 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); 31856 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
31753 int hpos = w->phys_cursor.hpos; 31857 int hpos = w->phys_cursor.hpos;
31754 int vpos = w->phys_cursor.vpos; 31858 int vpos = w->phys_cursor.vpos;
31755#ifdef HAVE_WINDOW_SYSTEM
31756 int mouse_delta;
31757 int phys_x = w->phys_cursor.x;
31758#endif
31759 bool mouse_face_here_p = false; 31859 bool mouse_face_here_p = false;
31760 struct glyph_matrix *active_glyphs = w->current_matrix; 31860 struct glyph_matrix *active_glyphs = w->current_matrix;
31761 struct glyph_row *cursor_row; 31861 struct glyph_row *cursor_row;
@@ -31826,13 +31926,16 @@ erase_phys_cursor (struct window *w)
31826 mouse_face_here_p = true; 31926 mouse_face_here_p = true;
31827 31927
31828#ifdef HAVE_WINDOW_SYSTEM 31928#ifdef HAVE_WINDOW_SYSTEM
31829 /* Adjust the physical cursor's X coordinate if needed. The problem 31929 /* Since erasing the phys cursor will probably lead to corruption of
31830 solved by the code below is outlined in the comment above 31930 the mouse face display if the glyph's pixel_width is not kept up
31831 'get_cursor_offset_for_mouse_face'. */ 31931 to date with the :box property of the mouse face, just redraw the
31832 if (mouse_face_here_p) 31932 mouse face. */
31933 if (FRAME_WINDOW_P (WINDOW_XFRAME (w)) && mouse_face_here_p)
31833 { 31934 {
31834 get_cursor_offset_for_mouse_face (w, cursor_row, &mouse_delta); 31935 w->phys_cursor_on_p = false;
31835 w->phys_cursor.x += mouse_delta; 31936 w->phys_cursor_type = NO_CURSOR;
31937 show_mouse_face (MOUSE_HL_INFO (WINDOW_XFRAME (w)), DRAW_MOUSE_FACE);
31938 return;
31836 } 31939 }
31837#endif 31940#endif
31838 31941
@@ -31871,10 +31974,6 @@ erase_phys_cursor (struct window *w)
31871 draw_phys_cursor_glyph (w, cursor_row, hl); 31974 draw_phys_cursor_glyph (w, cursor_row, hl);
31872 31975
31873 mark_cursor_off: 31976 mark_cursor_off:
31874#ifdef HAVE_WINDOW_SYSTEM
31875 /* Restore the original cursor position. */
31876 w->phys_cursor.x = phys_x;
31877#endif
31878 w->phys_cursor_on_p = false; 31977 w->phys_cursor_on_p = false;
31879 w->phys_cursor_type = NO_CURSOR; 31978 w->phys_cursor_type = NO_CURSOR;
31880} 31979}
@@ -35993,6 +36092,65 @@ cancel_hourglass (void)
35993 } 36092 }
35994} 36093}
35995 36094
36095/* Return a delta that must be applied to g->pixel_width in order to
36096 obtain the correct pixel_width of G when drawn under MOUSE_FACE.
36097 ORIGINAL_FACE is the face G was originally drawn in, and MOUSE_FACE
36098 is the face it will be drawn in now. ROW should be the row G is
36099 located in. W should be the window G is located in. */
36100static int
36101get_glyph_pixel_width_delta_for_mouse_face (struct glyph *g,
36102 struct glyph_row *row,
36103 struct window *w,
36104 struct face *original_face,
36105 struct face *mouse_face)
36106{
36107 int sum = 0;
36108
36109 bool do_left_box_p = g->left_box_line_p;
36110 bool do_right_box_p = g->right_box_line_p;
36111
36112 /* This is required because we test some parameters
36113 of the image slice before applying the box in
36114 produce_image_glyph. */
36115
36116 if (g->type == IMAGE_GLYPH)
36117 {
36118 if (!row->reversed_p)
36119 {
36120 struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w),
36121 g->u.img_id);
36122 do_left_box_p = g->left_box_line_p &&
36123 g->slice.img.x == 0;
36124 do_right_box_p = g->right_box_line_p &&
36125 g->slice.img.x + g->slice.img.width == img->width;
36126 }
36127 else
36128 {
36129 struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w),
36130 g->u.img_id);
36131 do_left_box_p = g->left_box_line_p &&
36132 g->slice.img.x + g->slice.img.width == img->width;
36133 do_right_box_p = g->right_box_line_p &&
36134 g->slice.img.x == 0;
36135 }
36136 }
36137
36138 /* If the glyph has a left box line, subtract it from the offset. */
36139 if (do_left_box_p)
36140 sum -= max (0, original_face->box_vertical_line_width);
36141 /* Likewise with the right box line, as there may be a
36142 box there as well. */
36143 if (do_right_box_p)
36144 sum -= max (0, original_face->box_vertical_line_width);
36145 /* Now add the line widths from the new face. */
36146 if (g->left_box_line_p)
36147 sum += max (0, mouse_face->box_vertical_line_width);
36148 if (g->right_box_line_p)
36149 sum += max (0, mouse_face->box_vertical_line_width);
36150
36151 return sum;
36152}
36153
35996/* Get the offset due to mouse-highlight to apply before drawing 36154/* Get the offset due to mouse-highlight to apply before drawing
35997 phys_cursor, and return it in OFFSET. ROW should be the row that 36155 phys_cursor, and return it in OFFSET. ROW should be the row that
35998 is under mouse face and contains the phys cursor. 36156 is under mouse face and contains the phys cursor.
@@ -36036,57 +36194,15 @@ get_cursor_offset_for_mouse_face (struct window *w, struct glyph_row *row,
36036 start = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; 36194 start = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
36037 } 36195 }
36038 36196
36039 /* Calculate the offset to correct phys_cursor x if we are 36197 /* Calculate the offset by which to correct phys_cursor x if we are
36040 drawing the cursor inside mouse-face highlighted text. */ 36198 drawing the cursor inside mouse-face highlighted text. */
36041 36199
36042 for (; row->reversed_p ? start >= end : start <= end; 36200 for (; row->reversed_p ? start > end : start < end;
36043 row->reversed_p ? --start : ++start) 36201 row->reversed_p ? --start : ++start)
36044 { 36202 {
36045 struct glyph *g = start; 36203 sum += get_glyph_pixel_width_delta_for_mouse_face (start, row, w,
36046 struct face *mouse = mouse_face; 36204 FACE_FROM_ID (f, start->face_id),
36047 struct face *regular_face = FACE_FROM_ID (f, g->face_id); 36205 mouse_face);
36048
36049 bool do_left_box_p = g->left_box_line_p;
36050 bool do_right_box_p = g->right_box_line_p;
36051
36052 /* This is required because we test some parameters
36053 of the image slice before applying the box in
36054 produce_image_glyph. */
36055
36056 if (g->type == IMAGE_GLYPH)
36057 {
36058 if (!row->reversed_p)
36059 {
36060 struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w),
36061 g->u.img_id);
36062 do_left_box_p = g->left_box_line_p &&
36063 g->slice.img.x == 0;
36064 do_right_box_p = g->right_box_line_p &&
36065 g->slice.img.x + g->slice.img.width == img->width;
36066 }
36067 else
36068 {
36069 struct image *img = IMAGE_FROM_ID (WINDOW_XFRAME (w),
36070 g->u.img_id);
36071 do_left_box_p = g->left_box_line_p &&
36072 g->slice.img.x + g->slice.img.width == img->width;
36073 do_right_box_p = g->right_box_line_p &&
36074 g->slice.img.x == 0;
36075 }
36076 }
36077
36078 /* If the glyph has a left box line, subtract it from the offset. */
36079 if (do_left_box_p)
36080 sum -= max (0, regular_face->box_vertical_line_width);
36081 /* Likewise with the right box line, as there may be a
36082 box there as well. */
36083 if (do_right_box_p)
36084 sum -= max (0, regular_face->box_vertical_line_width);
36085 /* Now add the line widths from the new face. */
36086 if (g->left_box_line_p)
36087 sum += max (0, mouse->box_vertical_line_width);
36088 if (g->right_box_line_p)
36089 sum += max (0, mouse->box_vertical_line_width);
36090 } 36206 }
36091 36207
36092 if (row->reversed_p) 36208 if (row->reversed_p)
diff --git a/src/xterm.c b/src/xterm.c
index 89885e0d889..961c61c2452 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1563,22 +1563,6 @@ x_set_cursor_gc (struct glyph_string *s)
1563static void 1563static void
1564x_set_mouse_face_gc (struct glyph_string *s) 1564x_set_mouse_face_gc (struct glyph_string *s)
1565{ 1565{
1566 int face_id;
1567 struct face *face;
1568
1569 /* What face has to be used last for the mouse face? */
1570 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
1571 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
1572 if (face == NULL)
1573 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
1574
1575 if (s->first_glyph->type == CHAR_GLYPH)
1576 face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch, -1, Qnil);
1577 else
1578 face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil);
1579 s->face = FACE_FROM_ID (s->f, face_id);
1580 prepare_face_for_display (s->f, s->face);
1581
1582 if (s->font == s->face->font) 1566 if (s->font == s->face->font)
1583 s->gc = s->face->gc; 1567 s->gc = s->face->gc;
1584 else 1568 else