emacs-diffs
[Top][All Lists]
Advanced

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

master 3f349a08ae 1/3: Make `mouse-position' work correctly with GTK too


From: Po Lu
Subject: master 3f349a08ae 1/3: Make `mouse-position' work correctly with GTK tooltips
Date: Sat, 4 Jun 2022 22:06:14 -0400 (EDT)

branch: master
commit 3f349a08ae0f23ccbef96f21e7c1a9a1c5869a9b
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 src/xterm.c | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 34a40da548..3eb9ee21da 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);



reply via email to

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