>From afc1097a0fe0ee483bcdb2cac2045201a3f00a72 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 19 Dec 2023 12:25:24 +0100 Subject: [PATCH] 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. --- src/dispextern.h | 1 + src/image.c | 2 +- src/xdisp.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/dispextern.h b/src/dispextern.h index 3a4d6095f73..020c33a2628 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3618,6 +3618,7 @@ #define TRY_WINDOW_IGNORE_FONTS_CHANGE (1 << 1) 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 diff --git a/src/image.c b/src/image.c index 38744fc1cce..651ec0b34e5 100644 --- a/src/image.c +++ b/src/image.c @@ -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; diff --git a/src/xdisp.c b/src/xdisp.c index 75d769600c4..731ad231058 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -30985,6 +30985,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); -- 2.43.0