unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Help with tooltips and events
@ 2020-10-23 13:12 Arthur Miller
  2020-10-23 13:24 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Arthur Miller @ 2020-10-23 13:12 UTC (permalink / raw)
  To: emacs-devel; +Cc: eliz

Sorry for taking your time guys; I am aware you have 1001 bug to fix;
but I need some help in Emacs source.

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 have registered tooltip frame for ButtonPressMask and
PointerMotionMask at tooltip frame creation time; set
no_accept_focus to nil; and let through buffer change events in window.c
but it still does not want to talk with me! I have been looking in
xterm.c and grepping and searching all over the source for tooltip and
events, but I can't seem to find where to enable events for tooltips.

I have fixed the thing with positioning and popping up; now it work every
time, and tooltips are staying on the screen for the specified interval
so one can move a pointer in and out. It was just deleayd timeout
that was spooking.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with tooltips and events
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2020-10-23 13:24 UTC (permalink / raw)
  To: Arthur Miller; +Cc: emacs-devel

> 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?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with tooltips and events
  2020-10-23 13:24 ` Eli Zaretskii
@ 2020-10-23 13:45   ` Arthur Miller
  2020-10-23 19:59     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Arthur Miller @ 2020-10-23 13:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

[-- 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 ();
	      }
	  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Help with tooltips and events
  2020-10-23 13:45   ` Arthur Miller
@ 2020-10-23 19:59     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2020-10-23 19:59 UTC (permalink / raw)
  To: Arthur Miller; +Cc: emacs-devel

> From: Arthur Miller <arthur.miller@live.com>
> Cc: emacs-devel@gnu.org
> Date: Fri, 23 Oct 2020 15:45:49 +0200
> 
> Tooltips by default does not respond to mouse (or key) events

Isn't that the problem that should be fixed?  If the tooltip is just a
special kind of frame, why wouldn't it get mouse events?  How did you
test that?



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-23 19:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-10-23 19:59     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).