From: Po Lu Date: Sat, 18 Jun 2022 02:14:24 +0000 (+0800) Subject: Fix specifying named action lists in `x-begin-drag' X-Git-Tag: emacs-29.0.90~1447^2~1656 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=95370484d4750717ea32a94a3785be3cd18b9427;p=emacs.git 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. --- diff --git a/src/xfns.c b/src/xfns.c index 3df91679afd..1372809da68 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 fe7b6ffe212..67bb2651727 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) {