emacs-diffs
[Top][All Lists]
Advanced

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

master 95370484d4: Fix specifying named action lists in `x-begin-drag'


From: Po Lu
Subject: master 95370484d4: Fix specifying named action lists in `x-begin-drag'
Date: Fri, 17 Jun 2022 22:15:51 -0400 (EDT)

branch: master
commit 95370484d4750717ea32a94a3785be3cd18b9427
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix specifying named action lists in `x-begin-drag'
    
    * src/xfns.c (Fx_begin_drag): Record original value of `targets'
    separately.  Pass that as the selection targets list instead.
    
    * src/xterm.c (x_dnd_delete_action_list): New function.
    (x_dnd_begin_drag_and_drop): Bind it if there are multiple
    actions.
---
 src/xfns.c  |  5 +++--
 src/xterm.c | 39 ++++++++++++++++++++++++++-------------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/src/xfns.c b/src/xfns.c
index 3df91679af..1372809da6 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -6899,7 +6899,7 @@ that mouse buttons are being held down, such as 
immediately after a
   int ntargets = 0, nnames = 0;
   char *target_names[2048];
   Atom *target_atoms;
-  Lisp_Object lval, original, tem, t1, t2;
+  Lisp_Object lval, original, targets_arg, tem, t1, t2;
   Atom xaction;
   Atom action_list[2048];
   char *name_list[2048];
@@ -6908,6 +6908,7 @@ that mouse buttons are being held down, such as 
immediately after a
 
   CHECK_LIST (targets);
   original = targets;
+  targets_arg = targets;
 
   for (; CONSP (targets); targets = XCDR (targets))
     {
@@ -6995,7 +6996,7 @@ that mouse buttons are being held down, such as 
immediately after a
                                    xaction, return_frame, action_list,
                                    (const char **) &name_list, nnames,
                                    !NILP (allow_current_frame), target_atoms,
-                                   ntargets, original, !NILP (follow_tooltip));
+                                   ntargets, targets_arg, !NILP 
(follow_tooltip));
 
   SAFE_FREE ();
   return lval;
diff --git a/src/xterm.c b/src/xterm.c
index fe7b6ffe21..67bb265172 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -11094,6 +11094,30 @@ x_clear_dnd_action (void)
   x_dnd_action_symbol = Qnil;
 }
 
+/* Delete action descriptions from F after drag-and-drop.  */
+static void
+x_dnd_delete_action_list (Lisp_Object frame)
+{
+  struct frame *f;
+
+  /* Delete those two properties, since some clients look at them and
+     not the action to decide whether or not the user should be
+     prompted to select an action.  This can be called with FRAME no
+     longer alive (or its display dead).  */
+
+  f = XFRAME (frame);
+
+  if (!FRAME_LIVE_P (f) || !FRAME_DISPLAY_INFO (f)->display)
+    return;
+
+  block_input ();
+  XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                  FRAME_DISPLAY_INFO (f)->Xatom_XdndActionList);
+  XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                  FRAME_DISPLAY_INFO (f)->Xatom_XdndActionDescription);
+  unblock_input ();
+}
+
 /* This function is defined far away from the rest of the XDND code so
    it can utilize `x_any_window_to_frame'.  */
 
@@ -11262,6 +11286,8 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, 
Atom xaction,
        = xm_side_effect_from_action (FRAME_DISPLAY_INFO (f),
                                      ask_action_list[0]);
 
+      record_unwind_protect (x_dnd_delete_action_list, frame);
+
       ask_actions = NULL;
       end = 0;
       count = SPECPDL_INDEX ();
@@ -11306,19 +11332,6 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, 
Atom xaction,
 
       unbind_to (count, Qnil);
     }
-  else
-    {
-      /* Delete those two properties, since some clients look at them
-        and not the action to decide whether or not the user should
-        be prompted to select an action.  */
-
-      block_input ();
-      XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                      FRAME_DISPLAY_INFO (f)->Xatom_XdndActionList);
-      XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                      FRAME_DISPLAY_INFO (f)->Xatom_XdndActionDescription);
-      unblock_input ();
-    }
 
   if (follow_tooltip)
     {



reply via email to

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