--- Begin Message ---
Subject: |
23.1.92; `x-show-tip' and `tooltip-frame-parameters' do not respect `left' and `top' |
Date: |
Wed, 10 Mar 2010 23:49:35 -0800 |
emacs -Q
M-: (x-show-tip "aaaaaaaa" (selected-frame)
'((left . 30) (top . 40)) 10 0 0)
Or something similar. Instead of displaying the tooltip frame at the absolute
location specified by `left' and `top', it always displays it at the mouse
position plus the DX and DY (0 and 0 here).
Also, the tooltip does not remain displayed for the 10 seconds specified, but
perhaps that is due to the way this is evaluated (M-:).
As another example (easier to see), evaluate this:
(let ((tooltip-frame-parameters '((nil . "tooltip")
(left . 100)
(top . 200))))
(tooltip-show "aaaaaaaaa" nil))
In this case, the tooltip is always shown with an offset of 5 (the default DX
and DY) from the mouse pointer.
The `left' and `right' parameters are ignored. Even the doc string of
`tooltip-frame-parameters' says that `left' and `top' should be respected.
Instead, the mouse pointer position is always used.
Another illustration:
M-: (my-show "aaaaaa" nil 100 200)
where `my-show' is the same as `tooltip-show' except that it accepts optional
LEFT and TOP params, to override `tooltip-frame-parameters':
(defun my-show (text &optional use-echo-area left top)
"..."
(if use-echo-area
(tooltip-show-help-non-mode text)
(condition-case error
(let ((params (copy-sequence tooltip-frame-parameters))
(fg (face-attribute 'tooltip :foreground))
(bg (face-attribute 'tooltip :background)))
(when (stringp fg)
(setq params (tooltip-set-param params 'foreground-color fg))
(setq params (tooltip-set-param params 'border-color fg)))
(when (stringp bg)
(setq params (tooltip-set-param params 'background-color bg)))
(when left (setq params (tooltip-set-param params 'left left)))
(when top (setq params (tooltip-set-param params 'top top)))
(x-show-tip (propertize text 'face 'tooltip)
(selected-frame)
params
tooltip-hide-delay
tooltip-x-offset
tooltip-y-offset))
(error
(message "Error while displaying tooltip: %s" error)
(sit-for 1)
(message "%s" text)))))
`tooltip-show' should in fact be modified in this way (adding optional LEFT and
TOP), IMO, so that you can easily show the tooltip anywhere without first adding
the location to `tooltip-frame-parameters' (e.g. as in the `let' example). But
the bug needs to be fixed first.
In GNU Emacs 23.1.92.1 (i386-mingw-nt5.1.2600)
of 2010-02-20 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#5703: 23.1.92; `x-show-tip' and `tooltip-frame-parameters' do not respect `left' and `top' |
Date: |
Wed, 31 Mar 2010 12:17:19 +0300 |
> Date: Wed, 31 Mar 2010 08:33:25 +0900
> From: YAMAMOTO Mitsuharu <address@hidden>
> Cc: Chong Yidong <address@hidden>, address@hidden,
> address@hidden, address@hidden
>
> > I see almost identical code in xfns.c versions of these functions,
> > so I'd be interested to hear how come the X version does not suffer
> > from the same problem. That's because the patch below, although it
> > does the job, feels a bit kludgey, and I wonder if there a cleaner
> > way.
>
> Because x_create_tip_frame in xfns.c makes a copy of `parms'?
Right, I missed that. Thanks.
So I committed to the emacs-23 branch the following patch which fixes
the bug:
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2010-03-31 04:00:23 +0000
+++ src/ChangeLog 2010-03-31 09:08:40 +0000
@@ -1,3 +1,8 @@
+2010-03-31 Eli Zaretskii <address@hidden>
+
+ * w32fns.c (x_create_tip_frame): Copy `parms' before we modify it
+ in this function. (Bug#5703)
+
2010-03-31 Chong Yidong <address@hidden>
* nsterm.h: Fix last change.
=== modified file 'src/w32fns.c'
--- src/w32fns.c 2010-01-13 08:35:10 +0000
+++ src/w32fns.c 2010-03-31 09:08:40 +0000
@@ -5427,6 +5427,10 @@ x_create_tip_frame (dpyinfo, parms, text
kb = dpyinfo->terminal->kboard;
+ /* The calls to x_get_arg remove elements from PARMS, so copy it to
+ avoid destructive changes behind our caller's back. */
+ parms = Fcopy_alist (parms);
+
/* Get the name of the frame to use for resource lookup. */
name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
if (!STRINGP (name)
--- End Message ---