all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: arthur miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Sv: Sticky tooltips
Date: Thu, 1 Oct 2020 02:28:25 +0000	[thread overview]
Message-ID: <VI1PR06MB452600F8F32FB97166EC241696300@VI1PR06MB4526.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <83pn63iajn.fsf@gnu.org>

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

I can't sleep, so I thought it help to read some C code. I got just more awake.

Anyway, I have looked at x-show-tip, and yes it is pretty  much same as I described 🙂.

I am not sure how to get buffer out of x-show-tip, so I was thinking about different
strategv: modify x-show-tip to take as argument a buffer (or string-or-buffer) and modify it accordingly;
throw away most of "lispy" code that deals with setting up buffer and styling the string. The
buffer itself should be setup and styled on lisp side in tooltip.el. Just as illutstration:

(defcustom tooltip-enable-sticky nil
  "When enabled the tooltip frame will show a small checkbox widget
witch when enabled will make a tooltip not dissapear after timeout. To
  close a sticky tooltip untick the checkbox."
  :type 'boolean
  :group 'tooltip)

(defun tooltip-show (text &optional use-echo-area)
....
  (if use-echo-area
      (tooltip-show-help-non-mode text)
    (condition-case error
.....

 (with-current-buffer (get-buffer-create "some name")

     ;; do some other setup needed ...

     (insert (propertize text 'face 'tooltip))

     (when enable-sticky-tooltips
        ;; setup "widget" part to show
        ;; checkbox
     )

     ;; send in "ready-made" buffer

     (x-show-tip (current-buffer)
           (  ... )
.....


Amd x-show-tip would have signature like this

  (Lisp_Object buffer, Lisp_Object frame, Lisp_Object parms,
  Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)

I don't know how the function would deal with Gtk tooltips; if they can also take a buffer
and display it, that is why I mean the function to take string-or-buffer.

Another thing is timer; if user is going to make an action to cancel timer (enable sticky)
then lisp code needs access to the timer, so it probably should be handled in lisp too.

________________________________
Från: Eli Zaretskii <eliz@gnu.org>
Skickat: den 30 september 2020 16:50
Till: Arthur Miller <arthur.miller@live.com>
Kopia: emacs-devel@gnu.org <emacs-devel@gnu.org>
Ämne: Re: Sticky tooltips

> From: Arthur Miller <arthur.miller@live.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 29 Sep 2020 23:30:14 +0200
>
> Yeah, you are correct, what tooltip already does, as you say is
> logically what I described, but the implementation is different:
> tooltip.el seems to outsource all it's work to xfns.c, and the code for
> tooltip frame creation; I used just "a naked frame" and some Lisp to
> create an effect of a tooltip.

The C-level implementation notwithstanding, we still insert the
tooltip text into a buffer, so we could snatch it from there, right?
We could have a command that took that text and displayed it in *Help*
buffer, for example.

> By the way; "tooltip-show" (in tooltip.el) seems to take a string
> argument; rather than a buffer, and that widget library "widget.el",
> needs a buffer (for the minor mode, etc).

See above.

> Just as a side curious question: did tooltips really needed own c
> implementation? Isn't code in x-create-tip-frame and x-show-tip seems
> redundant to other frame creation routines/display? Couldn't tooltips be
> implemented using normal frames, with "tooltip-special" code written in
> lisp?

If you compare x-create-frame and x-create-tip-frame, you will see
that the tip frame is special, and some of the differences are in
fields of the frame object that are not exposed to Lisp.  To move this
to Lisp would mean we'd have to expose them to Lisp first, and I'm not
sure we want to do that.

> I dont' mean to ditch it away, just a reflection on complexity. Maybe I
> don't see all the complexity with tooltips; but it is still ~900+ lines
> of c code that need to be maintained for X11, and there are well w32 and
> ns implementations, so around 3k locs?

The code replication is a separate issue: we did make an effort lately
to extract some common code and have it only once.  Patches are
welcome to do that in x-create-frame and x-create-tip-frame as well.
It isn't entirely trivial, because the common code is interspersed
with window-system specific API calls.

[-- Attachment #2: Type: text/html, Size: 8875 bytes --]

  parent reply	other threads:[~2020-10-01  2:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 20:04 Sticky tooltips Arthur Miller
2020-09-28 22:11 ` Jean Louis
2020-09-29  3:39   ` Arthur Miller
2020-09-29  4:20     ` Jean Louis
2020-09-29  2:41 ` Eli Zaretskii
2020-09-29  3:36   ` Arthur Miller
2020-09-29 14:17     ` Eli Zaretskii
2020-09-29 21:30       ` Arthur Miller
2020-09-30 14:50         ` Eli Zaretskii
2020-09-30 15:17           ` Arthur Miller
2020-10-01  2:28           ` arthur miller [this message]
2020-10-01 12:58             ` Sv: " Eli Zaretskii
2020-10-02 10:47               ` Sv: " arthur miller
2020-10-05  9:27               ` Arthur Miller
2020-10-05  9:48                 ` Eli Zaretskii
2020-10-05 10:18                   ` Arthur Miller
2020-10-05 10:52                     ` Eli Zaretskii
2020-10-05 11:04                       ` Arthur Miller

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=VI1PR06MB452600F8F32FB97166EC241696300@VI1PR06MB4526.eurprd06.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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.