]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix drag-and-drop treatment of reused tooltip frames
authorPo Lu <luangruo@yahoo.com>
Thu, 27 Feb 2025 01:53:41 +0000 (09:53 +0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 28 Feb 2025 11:18:43 +0000 (12:18 +0100)
* src/androidfns.c (Fx_show_tip): Set `tip_window' to that of
any reused tooltip frame.

* src/haikufns.c (unwind_create_frame): Return whether the frame
was destroyed, as on X.
(unwind_create_tip_frame, haiku_create_frame, Fx_show_tip):
Synchronize with X.
(do_unwind_create_frame): New function.
(tip_window): Remove unused variable.

* src/nsfns.m (tip_window, unwind_create_tip_frame): Remove
unused variable `tip_window'.

* src/pgtkfns.c (pgtk_create_tip_frame): Rename to
pgtk_create_tip_frame.
(Fx_show_tip): Adjust accordingly.  Set `tip_window' to that of
any reused tooltip frame.

* src/w32fns.c (Fx_show_tip):

* src/xfns.c (Fx_show_tip): Set `tip_window' to that of any
reused tooltip frame.

(cherry picked from commit a4a458ffa4aaeb988ff4b6e6087c44dfdaf40a0b)

src/androidfns.c
src/haikufns.c
src/nsfns.m
src/pgtkfns.c
src/w32fns.c
src/xfns.c

index f8e3d397008dc2cfa509ebc2f378550dac22a7e9..ec8651aafcb9caf242fb1f58ac265176510722e1 100644 (file)
@@ -2449,6 +2449,8 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
        /* Creating the tip frame failed.  */
        return unbind_to (count, Qnil);
     }
+  else
+    tip_window = FRAME_ANDROID_WINDOW (XFRAME (tip_frame));
 
   tip_f = XFRAME (tip_frame);
   window = FRAME_ROOT_WINDOW (tip_f);
index 6490a22bd019f925c83e4e09c1915c81086e8e87..298a27ccc022ff9fab2c5dbd30d0a157c1103984 100644 (file)
@@ -53,10 +53,6 @@ Lisp_Object tip_frame;
 /* The X and Y deltas of the last call to `x-show-tip'.  */
 Lisp_Object tip_dx, tip_dy;
 
-/* The window-system window corresponding to the frame of the
-   currently visible tooltip.  */
-static Window tip_window;
-
 /* A timer that hides or deletes the currently visible tooltip when it
    fires.  */
 static Lisp_Object tip_timer;
@@ -610,7 +606,7 @@ initial_setup_back_buffer (struct frame *f)
   unblock_input ();
 }
 
-static void
+static Lisp_Object
 unwind_create_frame (Lisp_Object frame)
 {
   struct frame *f = XFRAME (frame);
@@ -619,22 +615,27 @@ unwind_create_frame (Lisp_Object frame)
      display is disconnected after the frame has become official, but
      before x_create_frame removes the unwind protect.  */
   if (!FRAME_LIVE_P (f))
-    return;
+    return Qnil;
 
   /* If frame is ``official'', nothing to do.  */
   if (NILP (Fmemq (frame, Vframe_list)))
     {
       haiku_free_frame_resources (f);
       free_glyphs (f);
+      return Qt;
     }
+
+  return Qnil;
 }
 
 static void
 unwind_create_tip_frame (Lisp_Object frame)
 {
-  unwind_create_frame (frame);
-  tip_window = NULL;
-  tip_frame = Qnil;
+  Lisp_Object deleted;
+
+  deleted = unwind_create_frame (frame);
+  if (deleted)
+    tip_frame = Qnil;
 }
 
 static unsigned long
@@ -673,6 +674,12 @@ haiku_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval
     }
 }
 
+static void
+do_unwind_create_frame (Lisp_Object frame)
+{
+  unwind_create_frame (frame);
+}
+
 static Lisp_Object
 haiku_create_frame (Lisp_Object parms)
 {
@@ -759,7 +766,7 @@ haiku_create_frame (Lisp_Object parms)
   FRAME_DISPLAY_INFO (f) = dpyinfo;
 
   /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe.  */
-  record_unwind_protect (unwind_create_frame, frame);
+  record_unwind_protect (do_unwind_create_frame, frame);
 
   /* Set the name; the functions to which we pass f expect the name to
      be set.  */
@@ -2504,12 +2511,12 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
                      break;
                    }
                  else
-                   tip_last_parms =
-                     calln (Qassq_delete_all, parm, tip_last_parms);
+                   tip_last_parms
+                     calln (Qassq_delete_all, parm, tip_last_parms);
                }
              else
-               tip_last_parms =
-                 calln (Qassq_delete_all, parm, tip_last_parms);
+               tip_last_parms
+                 calln (Qassq_delete_all, parm, tip_last_parms);
            }
 
          /* Now check if every parameter in what is left of
index a2c50468cd1d750a286e1e499f26d0bd290d0e5b..9f52777879c76708323085ab22e24c035d6a97e9 100644 (file)
@@ -66,10 +66,6 @@ static Lisp_Object tip_frame;
 /* The X and Y deltas of the last call to `x-show-tip'.  */
 static Lisp_Object tip_dx, tip_dy;
 
-/* The window-system window corresponding to the frame of the
-   currently visible tooltip.  */
-static NSWindow *tip_window;
-
 /* A timer that hides or deletes the currently visible tooltip when it
    fires.  */
 static Lisp_Object tip_timer;
@@ -2959,10 +2955,7 @@ unwind_create_tip_frame (Lisp_Object frame)
 
   deleted = unwind_create_frame (frame);
   if (EQ (deleted, Qt))
-    {
-      tip_window = NULL;
-      tip_frame = Qnil;
-    }
+    tip_frame = Qnil;
 }
 
 /* Create a frame for a tooltip on the display described by DPYINFO.
index 73cd6e5695d09750227d67f02bd4da9b211037f3..6231ef1cb481e90a73c858250e72151d1acb9089 100644 (file)
@@ -2646,7 +2646,7 @@ unwind_create_tip_frame (Lisp_Object frame)
    when this happens.  */
 
 static Lisp_Object
-x_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct frame *p)
+pgtk_create_tip_frame (struct pgtk_display_info *dpyinfo, Lisp_Object parms, struct frame *p)
 {
   struct frame *f;
   Lisp_Object frame;
@@ -3264,10 +3264,13 @@ Text larger than the specified size is clipped.  */)
 
       /* Create a frame for the tooltip, and record it in the global
         variable tip_frame.  */
-      if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms, f)))
+      if (NILP ((tip_frame = pgtk_create_tip_frame (FRAME_DISPLAY_INFO (f),
+                                                   parms, f))))
        /* Creating the tip frame failed.  */
        return unbind_to (count, Qnil);
     }
+  else
+    tip_window = FRAME_X_WINDOW (XFRAME (tip_frame));
 
   tip_f = XFRAME (tip_frame);
   window = FRAME_ROOT_WINDOW (tip_f);
index 89a4d46240aea59c5d69f7b1ff109d9ba11c9326..17221b73470831343a2cc9653ba79a5f8ee97764 100644 (file)
@@ -7931,6 +7931,11 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
          return unbind_to (count, Qnil);
        }
     }
+  else
+    /* Required by X11 drag and drop, and left here in the interests of
+       consistency and in the event drag and drop should be implemented
+       on W32.  */
+    tip_window = FRAME_W32_WINDOW (XFRAME (tip_frame));
 
   tip_f = XFRAME (tip_frame);
   window = FRAME_ROOT_WINDOW (tip_f);
index ec7d54180e4c67732c8fa76fb37ddc48af76dd80..d8a3ce0b3b1762bfa7029e5a400a86e4be68ea9f 100644 (file)
@@ -9109,12 +9109,12 @@ Text larger than the specified size is clipped.  */)
                      break;
                    }
                  else
-                   tip_last_parms =
-                     calln (Qassq_delete_all, parm, tip_last_parms);
+                   tip_last_parms
+                     calln (Qassq_delete_all, parm, tip_last_parms);
                }
              else
-               tip_last_parms =
-                 calln (Qassq_delete_all, parm, tip_last_parms);
+               tip_last_parms
+                 calln (Qassq_delete_all, parm, tip_last_parms);
            }
 
          /* Now check if every parameter in what is left of
@@ -9166,6 +9166,9 @@ Text larger than the specified size is clipped.  */)
        /* Creating the tip frame failed.  */
        return unbind_to (count, Qnil);
     }
+  else
+    /* Required by X11 drag and drop.  */
+    tip_window = FRAME_X_WINDOW (XFRAME (tip_frame));
 
   tip_f = XFRAME (tip_frame);
   window = FRAME_ROOT_WINDOW (tip_f);