]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't lose drag-and-drop data intended for XTerm-like programs
authorPo Lu <luangruo@yahoo.com>
Sat, 8 Mar 2025 12:42:49 +0000 (20:42 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Mar 2025 10:29:06 +0000 (11:29 +0100)
* src/xselect.c (x_own_selection): If special values exist for
drag-and-drop to unsupported programs, retain them till the
selection is cleared.

(cherry picked from commit b0b7ad24e6efca04a373a4f2845a483984e3f1ea)

src/xselect.c

index 5e494a2ca228a54bfddfe625da118201a0cbed5a..5497a98e61ddf3f1eafcbe533aa0eb635b95d0cf 100644 (file)
@@ -299,10 +299,17 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
     Lisp_Object selection_data;
     Lisp_Object prev_value;
 
+    prev_value = LOCAL_SELECTION (selection_name, dpyinfo);
+
+    /* If the previous value contains alternative data for responding to
+       programs that do not understand a specialized drag-and-drop
+       protocol and DND_DATA is unset, transfer it to the new value.  */
+    if (NILP (dnd_data) && !NILP (prev_value))
+      dnd_data = XCAR (XCDR (XCDR (XCDR (XCDR (prev_value)))));
+
     selection_data = list5 (selection_name, selection_value,
                            INT_TO_INTEGER (timestamp), frame,
                            dnd_data);
-    prev_value = LOCAL_SELECTION (selection_name, dpyinfo);
 
     tset_selection_alist
       (dpyinfo->terminal,