From: Po Lu Date: Sun, 29 May 2022 04:55:54 +0000 (+0800) Subject: Make DND target list lifecycle a little clearer X-Git-Tag: emacs-29.0.90~1910^2~360 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=22a3e92dc6e3106fe5a7afdf3c1de95e2b3e1fb7;p=emacs.git Make DND target list lifecycle a little clearer * src/xfns.c (Fx_begin_drag): Pass target atoms and ntargets to x_dnd_begin_drag_and_drop instead. * src/xterm.c (x_set_dnd_targets): Make static. (x_clear_dnd_targets): Delete function. (x_dnd_begin_drag_and_drop): Adjust to set targets here instead. * src/xterm.h: Update prototypes. --- diff --git a/src/xfns.c b/src/xfns.c index 9f218d2b7fe..401ad816955 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6933,11 +6933,11 @@ that mouse buttons are being held down, such as immediately after a ntargets, False, target_atoms); unblock_input (); - x_set_dnd_targets (target_atoms, ntargets); lval = x_dnd_begin_drag_and_drop (f, FRAME_DISPLAY_INFO (f)->last_user_time, xaction, return_frame, action_list, (const char **) &name_list, nnames, - !NILP (allow_current_frame)); + !NILP (allow_current_frame), target_atoms, + ntargets); SAFE_FREE (); return lval; diff --git a/src/xterm.c b/src/xterm.c index 3e5aaf5d4a4..65d3eaf83f2 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3901,7 +3901,7 @@ x_dnd_send_drop (struct frame *f, Window target, Time timestamp, return true; } -void +static void x_set_dnd_targets (Atom *targets, int ntargets) { if (x_dnd_targets) @@ -10292,13 +10292,6 @@ x_next_event_from_any_display (XEvent *event) #endif /* USE_X_TOOLKIT || USE_GTK */ -static void -x_clear_dnd_targets (void) -{ - if (x_dnd_unwind_flag) - x_set_dnd_targets (NULL, 0); -} - /* This function is defined far away from the rest of the XDND code so it can utilize `x_any_window_to_frame'. */ @@ -10306,7 +10299,8 @@ Lisp_Object x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, Lisp_Object return_frame, Atom *ask_action_list, const char **ask_action_names, size_t n_ask_actions, - bool allow_current_frame) + bool allow_current_frame, Atom *target_atoms, + int ntargets) { #ifndef USE_GTK XEvent next_event; @@ -10394,43 +10388,25 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, } if (!FRAME_VISIBLE_P (f)) - { - x_set_dnd_targets (NULL, 0); - error ("Frame is invisible"); - } + error ("Frame must be visible"); XSETFRAME (frame, f); local_value = assq_no_quit (QXdndSelection, FRAME_TERMINAL (f)->Vselection_alist); if (x_dnd_in_progress || x_dnd_waiting_for_finish) - { - x_set_dnd_targets (NULL, 0); - error ("A drag-and-drop session is already in progress"); - } + error ("A drag-and-drop session is already in progress"); if (CONSP (local_value)) - { - ref = SPECPDL_INDEX (); - - record_unwind_protect_void (x_clear_dnd_targets); - x_dnd_unwind_flag = true; - x_own_selection (QXdndSelection, - Fnth (make_fixnum (1), local_value), frame); - x_dnd_unwind_flag = false; - unbind_to (ref, Qnil); - } + x_own_selection (QXdndSelection, + Fnth (make_fixnum (1), local_value), frame); else - { - x_set_dnd_targets (NULL, 0); - error ("No local value for XdndSelection"); - } + error ("No local value for XdndSelection"); if (popup_activated ()) - { - x_set_dnd_targets (NULL, 0); - error ("Trying to drag-and-drop from within a menu-entry"); - } + error ("Trying to drag-and-drop from within a menu-entry"); + + x_set_dnd_targets (target_atoms, ntargets); ltimestamp = x_timestamp_for_selection (FRAME_DISPLAY_INFO (f), QXdndSelection); diff --git a/src/xterm.h b/src/xterm.h index 6c798ea246d..bc2e138aa99 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1451,11 +1451,10 @@ extern void x_scroll_bar_configure (GdkEvent *); extern Lisp_Object x_dnd_begin_drag_and_drop (struct frame *, Time, Atom, Lisp_Object, Atom *, const char **, - size_t, bool); + size_t, bool, Atom *, int); extern void x_dnd_do_unsupported_drop (struct x_display_info *, Lisp_Object, Lisp_Object, Lisp_Object, Window, int, int, Time); -extern void x_set_dnd_targets (Atom *, int); extern int x_display_pixel_height (struct x_display_info *); extern int x_display_pixel_width (struct x_display_info *);