Function: x-dnd-handle-drag-n-drop-event

x-dnd-handle-drag-n-drop-event is an interactive and byte-compiled function defined in x-dnd.el.gz.

Signature

(x-dnd-handle-drag-n-drop-event EVENT)

Documentation

Receive drag and drop events (X client messages).

Currently XDND, Motif and old KDE 1.x protocols are recognized.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/x-dnd.el.gz
(defun x-dnd-handle-drag-n-drop-event (event)
  "Receive drag and drop events (X client messages).
Currently XDND, Motif and old KDE 1.x protocols are recognized."
  (interactive "e")
  (let* ((client-message (car (cdr (cdr event))))
         (x-fast-protocol-requests (not x-dnd-debug-errors))
	 (window (posn-window (event-start event))))
    (if (eq (and (consp client-message)
                 (car client-message))
            'XdndSelection)
        ;; This is an internal Emacs message caused by something being
        ;; dropped on top of a frame.
        (progn
          (let ((action (cdr (assoc (symbol-name (cadr client-message))
                                    x-dnd-xdnd-to-action)))
                (targets (cdddr client-message))
                (local-value (nth 2 client-message)))
            (when (windowp window)
              (select-window window))
            ;; Remove XdndDirectSave0 from this list--Emacs does not
            ;; support this protocol for internal drops.
            (setq targets (delete 'XdndDirectSave0 targets))
            (x-dnd-save-state window nil nil (apply #'vector targets))
            (x-dnd-maybe-call-test-function window action nil)
            (unwind-protect
                (x-dnd-drop-data event (if (framep window) window
                                         (window-frame window))
                                 window
                                 (x-get-local-selection
                                  local-value
                                  (intern (x-dnd-current-type window)))
                                 (x-dnd-current-type window))
              (x-dnd-forget-drop window))))
      (let ((message-atom (aref client-message 0))
	    (frame (aref client-message 1))
	    (format (aref client-message 2))
	    (data (aref client-message 3)))
        (cond ((equal "DndProtocol" message-atom)	; Old KDE 1.x.
	       (x-dnd-handle-old-kde event frame window message-atom format data))
              ((equal "_DND_PROTOCOL" message-atom) ; OffiX protocol.
               (x-dnd-handle-offix event frame window message-atom format data))
	      ((equal "_MOTIF_DRAG_AND_DROP_MESSAGE" message-atom)	; Motif
	       (x-dnd-handle-motif event frame window message-atom format data))

	      ((and (> (length message-atom) 4)	; XDND protocol.
		    (equal "Xdnd" (substring message-atom 0 4)))
	       (x-dnd-handle-xdnd event frame window message-atom format data)))))))