Function: x-dnd-handle-xdnd
x-dnd-handle-xdnd is a byte-compiled function defined in x-dnd.el.gz.
Signature
(x-dnd-handle-xdnd EVENT FRAME WINDOW MESSAGE FORMAT DATA)
Documentation
Receive one XDND event (client message) and send the appropriate reply.
EVENT is the client message. FRAME is where the mouse is now. WINDOW is the window within FRAME where the mouse is now. FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent.
Source Code
;; Defined in /usr/src/emacs/lisp/x-dnd.el.gz
(defun x-dnd-handle-xdnd (event frame window message _format data)
"Receive one XDND event (client message) and send the appropriate reply.
EVENT is the client message. FRAME is where the mouse is now.
WINDOW is the window within FRAME where the mouse is now.
FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
(cond ((equal "XdndEnter" message)
(let* ((flags (aref data 1))
(version (x-dnd-version-from-flags flags))
(more-than-3 (x-dnd-more-than-3-from-flags flags))
(dnd-source (aref data 0)))
(message "%s %s" version more-than-3)
(if version ;; If flags is bad, version will be nil.
(x-dnd-save-state
window nil nil
(if (> more-than-3 0)
(x-window-property "XdndTypeList"
frame "AnyPropertyType"
dnd-source nil t)
(vector (x-get-atom-name (aref data 2))
(x-get-atom-name (aref data 3))
(x-get-atom-name (aref data 4))))))))
((equal "XdndPosition" message)
(let* ((action (x-get-atom-name (aref data 4)))
(dnd-source (aref data 0))
(action-type (x-dnd-maybe-call-test-function
window
(cdr (assoc action x-dnd-xdnd-to-action))))
(reply-action (car (rassoc (car action-type)
x-dnd-xdnd-to-action)))
(accept ;; 1 = accept, 0 = reject
(if (and reply-action action-type) 1 0))
(list-to-send
(list (string-to-number
(frame-parameter frame 'outer-window-id))
accept ;; 1 = Accept, 0 = reject.
(x-dnd-get-drop-x-y frame window)
(x-dnd-get-drop-width-height
frame window (eq accept 1))
(or reply-action 0)
)))
(x-send-client-message
frame dnd-source frame "XdndStatus" 32 list-to-send)
))
((equal "XdndLeave" message)
(x-dnd-forget-drop window))
((equal "XdndDrop" message)
(if (windowp window) (select-window window))
(let* ((dnd-source (aref data 0))
(timestamp (aref data 2))
(value (and (x-dnd-current-type window)
(x-get-selection-internal
'XdndSelection
(intern (x-dnd-current-type window))
timestamp)))
success action)
(setq action (if value
(condition-case info
(x-dnd-drop-data event frame window value
(x-dnd-current-type window))
(error
(message "Error: %s" info)
nil))))
(setq success (if action 1 0))
(x-send-client-message
frame dnd-source frame "XdndFinished" 32
(list (string-to-number (frame-parameter frame 'outer-window-id))
success ;; 1 = Success, 0 = Error
(if success "XdndActionPrivate" 0)
))
(x-dnd-forget-drop window)))
(t (error "Unknown XDND message %s %s" message data))))