all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gerd.moellmann@gmail.com, 67794@debbugs.gnu.org, alan@idiocy.org
Subject: bug#67794: 30.0.50; mouse-face is not respected on SVG images
Date: Wed, 20 Dec 2023 18:53:41 +0100	[thread overview]
Message-ID: <87frzwoj4q.fsf@ledu-giraud.fr> (raw)
In-Reply-To: <83o7elggf2.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Dec 2023 15:19:29 +0200")

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

[...]

> It would be a shame to waste cycles on PNG images as long as we don't
> solve this problem, so I'd prefer to enable this only for SVG and
> leave a FIXME comment about PNG.

Here is an updated version of this patch:

     - I had to export 'image_spec_value' from image.c to use it in
       xdisp.c
     - I also guard this feature behind a #ifdef HAVE_RSVG


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Respect-mouse-face-on-SVG-image-glyphs-bug-67794.patch --]
[-- Type: text/x-patch, Size: 2506 bytes --]

From afc1097a0fe0ee483bcdb2cac2045201a3f00a72 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
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


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

  parent reply	other threads:[~2023-12-20 17:53 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 13:12 bug#67794: 30.0.50; mouse-face is not respected on SVG images Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 13:31 ` Eli Zaretskii
2023-12-12 14:07   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 14:43     ` Alan Third
2023-12-12 16:35       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-12 17:28         ` Eli Zaretskii
2023-12-13  8:18           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 12:19             ` Eli Zaretskii
2023-12-13 14:13               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 15:08                 ` Eli Zaretskii
2023-12-13 16:04                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 16:23                     ` Eli Zaretskii
2023-12-13 16:50                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 17:29                         ` Eli Zaretskii
2023-12-13 17:57                           ` Gerd Möllmann
2023-12-13 18:11                             ` Eli Zaretskii
2023-12-13 18:24                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-13 18:46                             ` Eli Zaretskii
2023-12-14  9:07                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14  9:23                                 ` Eli Zaretskii
2023-12-14  9:48                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-14 10:05                                     ` Eli Zaretskii
2023-12-18 11:02                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-18 11:42                                         ` Alan Third
2023-12-18 18:36                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-18 19:48                                             ` Alan Third
2023-12-19 12:45                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-19 13:03                                                 ` Eli Zaretskii
2023-12-19 13:23                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-19 13:40                                                     ` Eli Zaretskii
2023-12-19 13:48                                                       ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-19 14:25                                                         ` Eli Zaretskii
2023-12-19 14:39                                                           ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-19 15:34                                                             ` Eli Zaretskii
2023-12-20  8:47                                                               ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-20 13:19                                                                 ` Eli Zaretskii
2023-12-20 13:54                                                                   ` Alan Third
2023-12-20 13:54                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-20 17:53                                                                   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-12-23 10:22                                                                     ` Eli Zaretskii
2023-12-12 14:47     ` Eli Zaretskii
2023-12-12 15:20       ` Alan Third

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frzwoj4q.fsf@ledu-giraud.fr \
    --to=bug-gnu-emacs@gnu.org \
    --cc=67794@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=gerd.moellmann@gmail.com \
    --cc=manuel@ledu-giraud.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.