Respect mouse-face on SVG image glyphs (bug#67794)

* src/dispextern.h:
* src/image.c (image_spec_value): Export 'image_spec_value'.
* src/xdisp.c (draw_glyphs): Maybe update SVG image glyphs with
mouse face features before drawing.
This commit is contained in:
Manuel Giraud 2023-12-19 12:25:24 +01:00 committed by Eli Zaretskii
parent cbbb19ced6
commit e69fafdbc8
3 changed files with 22 additions and 1 deletions

View file

@ -3618,6 +3618,7 @@ void image_prune_animation_caches (bool);
bool valid_image_p (Lisp_Object);
void prepare_image_for_display (struct frame *, struct image *);
ptrdiff_t lookup_image (struct frame *, Lisp_Object, int);
Lisp_Object image_spec_value (Lisp_Object, Lisp_Object, bool *);
#if defined HAVE_X_WINDOWS || defined USE_CAIRO || defined HAVE_NS \
|| defined HAVE_HAIKU || defined HAVE_ANDROID

View file

@ -1543,7 +1543,7 @@ parse_image_spec (Lisp_Object spec, struct image_keyword *keywords,
if KEY is not present in SPEC. Set *FOUND depending on whether KEY
was found in SPEC. */
static Lisp_Object
Lisp_Object
image_spec_value (Lisp_Object spec, Lisp_Object key, bool *found)
{
Lisp_Object tail;

View file

@ -30940,6 +30940,26 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
}
}
#ifdef HAVE_RSVG
/* Update SVG image glyphs with mouse face features. FIXME: it
should be possible to have this behaviour with transparent
background PNG. */
if (hl == DRAW_MOUSE_FACE)
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
for (s = head; s; s = s->next)
if (s->first_glyph->type == IMAGE_GLYPH)
if (s->img
&& (EQ (image_spec_value (s->img->spec, QCtype, NULL), Qsvg)))
{
ptrdiff_t id;
id = lookup_image (f, s->img->spec, hlinfo->mouse_face_face_id);
s->img = IMAGE_FROM_ID (f, id);
prepare_image_for_display(f, s->img);
}
}
#endif
/* Draw all strings. */
for (s = head; s; s = s->next)
FRAME_RIF (f)->draw_glyph_string (s);