emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Side effects in `tooltip-show'


From: Po Lu
Subject: Side effects in `tooltip-show'
Date: Mon, 17 Jan 2022 09:30:16 +0800

I'd like to install a fix for a regression in the release branch: since
`equal-including-properties' is used in Emac 28 to compare tooltip
strings with their previous values, this branch in tooltip-show-help is
never reached:

              ((equal-including-properties previous-help msg)
               ;; Same help as before (but possibly the mouse has moved).
               ;; Keep what we have.
               )

Because tooltip-show mutates the text properties of any string passed to
it.  This causes a lot of flicker when the mouse is moved around.

The fix is to copy the string passed to `tooltip-show' before modifying
its text properties, like this:

diff --git a/lisp/tooltip.el b/lisp/tooltip.el
index 1cf16fdb5d..142c16a336 100644
--- a/lisp/tooltip.el
+++ b/lisp/tooltip.el
@@ -252,17 +252,18 @@ tooltip-show
            (setf (alist-get 'border-color params) fg))
          (when (stringp bg)
            (setf (alist-get 'background-color params) bg))
-          ;; Use non-nil APPEND argument below to avoid overriding any
-          ;; faces used in our TEXT.  Among other things, this allows
-          ;; tooltips to use the `help-key-binding' face used in
-          ;; `substitute-command-keys' substitutions.
-          (add-face-text-property 0 (length text) 'tooltip t text)
-          (x-show-tip text
-                     (selected-frame)
-                     params
-                     tooltip-hide-delay
-                     tooltip-x-offset
-                     tooltip-y-offset))
+          (let ((copy (copy-sequence text)))
+            ;; Use non-nil APPEND argument below to avoid overriding any
+            ;; faces used in our TEXT.  Among other things, this allows
+            ;; tooltips to use the `help-key-binding' face used in
+            ;; `substitute-command-keys' substitutions.
+            (add-face-text-property 0 (length text) 'tooltip t copy)
+            (x-show-tip copy
+                       (selected-frame)
+                       params
+                       tooltip-hide-delay
+                       tooltip-x-offset
+                       tooltip-y-offset)))
       (error
        (message "Error while displaying tooltip: %s" error)
        (sit-for 1)

Does anyone mind if I install this change on the release branch?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]