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
Subject: Re: Help with tooltips and events
Date: Fri, 23 Oct 2020 15:45:49 +0200	[thread overview]
Message-ID: <VI1PR06MB4526481A33E131409115EE97961A0@VI1PR06MB4526.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <833625jcsb.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 23 Oct 2020 16:24:20 +0300")

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

Eli Zaretskii <eliz@gnu.org> writes:


[-- Attachment #2: sticky-tip.png --]
[-- Type: image/png, Size: 14722 bytes --]

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



>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: eliz@gnu.org
>> Date: Fri, 23 Oct 2020 15:12:44 +0200
>> 
>> I was looking at those sticky tooltips idea yesterday and I really can't
>> find where do I hack tooltips to let through events for tooltip frame.
>> 
>> I need ButtonPress so user can enable the checkbox and I need pointer
>> motion so user can move a tooltip with the mouse. If I can also put the
>> cursor icon to grabbing hand (like in pdf readers) while moving the
>> tooltip tt would be the icing on the cake. Just tell me what
>> mechanism/place do I look at?
>
> I don't understand your problem.  can you explain it in more detail,
> and maybe provide an example of what you were trying to do?
When I create a native tooltip frame, I wish to be able to click in it,
so I can click on sticky checkbox. So I need it to react on mouse click
events.

If a tooltip is made sticky, then it might be useful to move it around
to some place in Emacs frame where it is not in the way, so I wish to be
able to click and drag the tooltip frame with the mouse.

You can see in the attached img what checkbox I talk about.

Tooltips by default does not respond to mouse (or key) events, so I have
tried to buttonpress and pointermotion even for tooltips, but I don't
seem to do it right.

In x_create_tip_frame:

    attrs.event_mask =
      StructureNotifyMask | PointerMotionMask | ButtonPressMask;
    tip_window
      = FRAME_X_WINDOW (f)
      = XCreateWindow (FRAME_X_DISPLAY (f),
		       FRAME_DISPLAY_INFO (f)->root_window,
		       /* x, y, width, height */
		       0, 0, 1, 1,
		       /* Border.  */
		       f->border_width,
		       CopyFromParent, InputOutput, CopyFromParent,
                       mask, &attrs);

( ... )
  /* Also do the stuff which must be set before the window exists.  */
  gui_default_parameter (f, parms, Qno_accept_focus, Qnil,
                         NULL, NULL, RES_TYPE_BOOLEAN);
  gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
                         "foreground", "Foreground", RES_TYPE_STRING);
( ...)

I was also looking at fun_window_change_functions in window.c, too; when
buffer is changed:


      if (!FRAME_LIVE_P (f)
	  || !f->can_set_window_size
	  || !f->after_make_frame
	  // || FRAME_TOOLTIP_P (f)
	  || !(frame_window_change
	       || frame_selected_change
	       || frame_selected_window_change
	       || frame_window_state_change))
	/* Either we are not allowed to run hooks for this frame or no
	   window change has been reported for it since the last time
	   we ran window change functions on it.  */
	continue;

In xterm.c, since I have set no-accept-focus to nil, it should not
ignore button press, no? According to the comment. But I see no effect,
so there some other place I am missing.

 case ButtonPress:
      {
        /* If we decide we want to generate an event to be seen
           by the rest of Emacs, we put it here.  */
        bool tab_bar_p = false;
        bool tool_bar_p = false;

	memset (&compose_status, 0, sizeof (compose_status));
	dpyinfo->last_mouse_glyph_frame = NULL;
	x_display_set_last_user_time (dpyinfo, event->xbutton.time);

	f = mouse_or_wdesc_frame (dpyinfo, event->xmotion.window);
	if (f && event->xbutton.type == ButtonPress
	    && !popup_activated ()
	    && !x_window_to_scroll_bar (event->xbutton.display,
					event->xbutton.window, 2)
	    && !FRAME_NO_ACCEPT_FOCUS (f))
	  {
	    /* When clicking into a child frame or when clicking
	       into a parent frame with the child frame selected and
	       `no-accept-focus' is not set, select the clicked
	       frame.  */
	    struct frame *hf = dpyinfo->highlight_frame;

	    if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf)))
	      {
		block_input ();
		XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
				RevertToParent, CurrentTime);
		if (FRAME_PARENT_FRAME (f))
		  XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
		unblock_input ();
	      }
	  }

  reply	other threads:[~2020-10-23 13:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 13:12 Help with tooltips and events Arthur Miller
2020-10-23 13:24 ` Eli Zaretskii
2020-10-23 13:45   ` Arthur Miller [this message]
2020-10-23 19:59     ` Eli Zaretskii

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=VI1PR06MB4526481A33E131409115EE97961A0@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.