Make `mouse-position' work correctly with GTK tooltips

* src/xterm.c (x_tooltip_window_to_frame): New parameter
`unrelated_tooltip_p'.
(XTmouse_position): Pass that, and if it turns out to be true,
look beneath the tooltip window.
This commit is contained in:
Po Lu 2022-06-05 09:24:20 +08:00
parent e74652386d
commit 3f349a08ae

View file

@ -10281,13 +10281,22 @@ x_window_to_frame (struct x_display_info *dpyinfo, int wdesc)
return 0;
}
/* Like x_any_window_to_frame but only try to find tooltip frames. */
/* Like x_any_window_to_frame but only try to find tooltip frames.
If wdesc is a toolkit tooltip without an associated frame, set
UNRELATED_TOOLTIP_P to true. Otherwise, set it to false. */
static struct frame *
x_tooltip_window_to_frame (struct x_display_info *dpyinfo,
Window wdesc)
Window wdesc, bool *unrelated_tooltip_p)
{
Lisp_Object tail, frame;
struct frame *f;
#ifdef USE_GTK
GtkWidget *widget;
GdkWindow *tooltip_window;
#endif
*unrelated_tooltip_p = false;
FOR_EACH_FRAME (tail, frame)
{
@ -10297,6 +10306,25 @@ x_tooltip_window_to_frame (struct x_display_info *dpyinfo,
&& FRAME_DISPLAY_INFO (f) == dpyinfo
&& FRAME_X_WINDOW (f) == wdesc)
return f;
#ifdef USE_GTK
if (FRAME_X_OUTPUT (f)->ttip_window)
widget = GTK_WIDGET (FRAME_X_OUTPUT (f)->ttip_window);
else
widget = NULL;
if (widget)
tooltip_window = gtk_widget_get_window (widget);
else
tooltip_window = NULL;
if (tooltip_window
&& (gdk_x11_window_get_xid (tooltip_window) == wdesc))
{
*unrelated_tooltip_p = true;
break;
}
#endif
}
return NULL;
@ -11782,6 +11810,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
{
struct frame *f1, *maybe_tooltip;
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
bool unrelated_tooltip;
block_input ();
@ -11882,9 +11911,10 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
&& (EQ (track_mouse, Qdrag_source)
|| EQ (track_mouse, Qdropping)))
{
maybe_tooltip = x_tooltip_window_to_frame (dpyinfo, child);
maybe_tooltip = x_tooltip_window_to_frame (dpyinfo, child,
&unrelated_tooltip);
if (maybe_tooltip)
if (maybe_tooltip || unrelated_tooltip)
child = x_get_window_below (dpyinfo->display, child,
parent_x, parent_y, &win_x,
&win_y);