From: Po Lu Date: Sun, 5 Jun 2022 01:24:20 +0000 (+0800) Subject: Make `mouse-position' work correctly with GTK tooltips X-Git-Tag: emacs-29.0.90~1910^2~230 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3f349a08ae0f23ccbef96f21e7c1a9a1c5869a9b;p=emacs.git 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. --- diff --git a/src/xterm.c b/src/xterm.c index 34a40da548f..3eb9ee21daa 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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);