emacs-devel
[Top][All Lists]
Advanced

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

Re: Help with tooltips and events


From: Arthur Miller
Subject: Re: Help with tooltips and events
Date: Fri, 23 Oct 2020 15:45:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

Attachment: sticky-tip.png
Description: PNG image


>> 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 via email to

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