From: Po Lu Date: Sun, 10 Apr 2022 01:31:24 +0000 (+0800) Subject: Try harder to own DND selections X-Git-Tag: emacs-29.0.90~1931^2~681 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fea97e29895ebe7ca1cc17095766d7c30f9884ac;p=emacs.git Try harder to own DND selections * src/xterm.c (x_dnd_do_unsupported_drop): Fix computation of local value. (x_dnd_begin_drag_and_drop): Try to own the selection if we do have a local value. --- diff --git a/src/xterm.c b/src/xterm.c index 0a2c3c58634..14a15066044 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2856,10 +2856,11 @@ x_dnd_do_unsupported_drop (struct x_display_info *dpyinfo, root_y = dest_y; } - x_own_selection (QPRIMARY, - assq_no_quit (QPRIMARY, - dpyinfo->terminal->Vselection_alist), - frame); + if (CONSP (value)) + x_own_selection (QPRIMARY, Fnth (make_fixnum (1), value), + frame); + else + x_own_selection (QPRIMARY, Qnil, frame); event.xbutton.window = child; event.xbutton.x = dest_x; @@ -9369,20 +9370,27 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, ptrdiff_t i, end, fill; XTextProperty prop; xm_drop_start_message dmsg; - Lisp_Object frame_object, x, y; + Lisp_Object frame_object, x, y, frame, local_value; if (!FRAME_VISIBLE_P (f)) error ("Frame is invisible"); + XSETFRAME (frame, f); + local_value = assq_no_quit (QXdndSelection, + FRAME_TERMINAL (f)->Vselection_alist); + if (x_dnd_in_progress || x_dnd_waiting_for_finish) error ("A drag-and-drop session is already in progress"); + if (CONSP (local_value)) + x_own_selection (QXdndSelection, + Fnth (make_fixnum (1), local_value), frame); + else + error ("No local value for XdndSelection"); + ltimestamp = x_timestamp_for_selection (FRAME_DISPLAY_INFO (f), QXdndSelection); - if (NILP (ltimestamp)) - error ("No local value for XdndSelection"); - if (BIGNUMP (ltimestamp)) x_dnd_selection_timestamp = bignum_to_intmax (ltimestamp); else