diff options
-rw-r--r-- | doc/lispref/frames.texi | 12 | ||||
-rw-r--r-- | lisp/x-dnd.el | 2 | ||||
-rw-r--r-- | src/keyboard.c | 5 | ||||
-rw-r--r-- | src/xterm.c | 20 |
4 files changed, 35 insertions, 4 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 720753edad6..f7491502f4c 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -4280,6 +4280,18 @@ will only be used if @code{"FILE_NAME"} is one of the targets given to to drop all supported content. @end defvar +@defvar x-dnd-use-unsupported-drop +When one of the @code{"STRING"}, @code{"UTF8_STRING"}, +@code{"COMPOUND_TEXT"} or @code{"TEXT"} targets is present in the list +given to @code{x-begin-drag}, Emacs will try to use synthesized mouse +events and the primary selection to insert the text if the drop target +doesn't support any drag-and-drop protocol at all. + +A side effect is that Emacs will become the owner of the primary +selection upon such a drop. If that is not desired, then the drop +emulation can be disabled by setting this variable to @code{nil}. +@end defvar + @node Color Names @section Color Names diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el index c3d56f327dd..43905e1bb02 100644 --- a/lisp/x-dnd.el +++ b/lisp/x-dnd.el @@ -1144,6 +1144,7 @@ ACTION is the action given to `x-begin-drag'." "Whether or not the drop target made a request for `XdndDirectSave0'.") (defvar x-dnd-disable-motif-protocol) +(defvar x-dnd-use-unsupported-drop) (defun x-dnd-handle-direct-save (_selection _type _value) "Handle a selection request for `XdndDirectSave'." @@ -1204,6 +1205,7 @@ was taken, or the direct save failed." ;; possibly work with Motif or OffiX programs. (x-dnd-disable-motif-protocol t) (x-dnd-use-offix-drop nil) + (x-dnd-use-unsupported-drop nil) (prop-deleted nil) encoded-name) (unwind-protect diff --git a/src/keyboard.c b/src/keyboard.c index 8b8d348c41a..4cac20eb4b7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -4068,7 +4068,10 @@ kbd_buffer_get_event (KBOARD **kbp, /* `x-dnd-unsupported-drop-function' could have deleted the event frame. */ - if (!FRAME_LIVE_P (f)) + if (!FRAME_LIVE_P (f) + /* This means `x-dnd-use-unsupported-drop' was nil when the + event was generated. */ + || NILP (XCAR (XCDR (XCDR (XCDR (event->ie.arg)))))) break; x_dnd_do_unsupported_drop (FRAME_DISPLAY_INFO (f), diff --git a/src/xterm.c b/src/xterm.c index 500443ebaa1..fa43371f05c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3810,6 +3810,9 @@ x_dnd_do_unsupported_drop (struct x_display_info *dpyinfo, if (NILP (value)) return; + if (!x_dnd_use_unsupported_drop) + return; + event.xbutton.serial = 0; event.xbutton.send_event = True; event.xbutton.display = dpyinfo->display; @@ -3914,9 +3917,10 @@ x_dnd_send_unsupported_drop (struct x_display_info *dpyinfo, Window target_windo ie.kind = UNSUPPORTED_DROP_EVENT; ie.code = (unsigned) target_window; ie.modifiers = x_dnd_unsupported_event_level; - ie.arg = list3 (assq_no_quit (QXdndSelection, + ie.arg = list4 (assq_no_quit (QXdndSelection, dpyinfo->terminal->Vselection_alist), - targets, arg); + targets, arg, (x_dnd_use_unsupported_drop + ? Qt : Qnil)); ie.timestamp = before; XSETINT (ie.x, root_x); @@ -11377,7 +11381,10 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction, /* `x-dnd-unsupported-drop-function' could have deleted the event frame. */ - if (!FRAME_LIVE_P (event_frame)) + if (!FRAME_LIVE_P (event_frame) + /* This means `x-dnd-use-unsupported-drop' was nil when the + event was generated. */ + || NILP (XCAR (XCDR (XCDR (XCDR (event->ie.arg)))))) continue; x_dnd_do_unsupported_drop (FRAME_DISPLAY_INFO (event_frame), @@ -28075,4 +28082,11 @@ drag-and-drop code. */); When non-nil, `x-begin-drag' will not drop onto any window that only supports the Motif drag-and-drop protocols. */); x_dnd_disable_motif_protocol = false; + + DEFVAR_BOOL ("x-dnd-use-unsupported-drop", x_dnd_use_unsupported_drop, + doc: /* Enable the emulation of drag-and-drop based on the primary selection. +When nil, do not use the primary selection and synthetic mouse clicks +to emulate the drag-and-drop of `STRING', `UTF8_STRING', +`COMPOUND_TEXT' or `TEXT'. */); + x_dnd_use_unsupported_drop = true; } |