Function: pgtk-dnd-handle-gdk
pgtk-dnd-handle-gdk is a byte-compiled function defined in
pgtk-dnd.el.gz.
Signature
(pgtk-dnd-handle-gdk EVENT FRAME WINDOW CLIENT-MESSAGE)
Documentation
Handle drag-n-drop EVENT on FRAME.
WINDOW should be the window the event happened on top of. CLIENT-MESSAGE is the detailed description of the drag-and-drop message.
Source Code
;; Defined in /usr/src/emacs/lisp/pgtk-dnd.el.gz
(defun pgtk-dnd-handle-gdk (event frame window client-message)
"Handle drag-n-drop EVENT on FRAME.
WINDOW should be the window the event happened on top of.
CLIENT-MESSAGE is the detailed description of the drag-and-drop
message."
(cond
;; We can't handle `drag-leave' immediately, since that signal is
;; also sent right before `drag-drop', and there is no reliable way
;; to distinguish a signal sent because the source left from one
;; sent prior to a drop. Instead, set a flag that tells Emacs to
;; clear the drag-and-drop state if anything other than a drop is
;; received.
((not client-message) ; drag-leave
(setq pgtk-dnd-clear-data-on-motion t))
((eq (car client-message) 'lambda) ; drag-motion
(let ((state (pgtk-dnd-get-state-for-frame frame)))
(unless (and (aref state 0) ;; This is actually an entry.
(not pgtk-dnd-clear-data-on-motion))
(setq pgtk-dnd-clear-data-on-motion nil)
;; Forget the drop first, or else the list of targets will not
;; be cleared if it is nil.
(pgtk-dnd-forget-drop window)
(pgtk-dnd-save-state window nil nil
(pgtk-get-selection-internal
(nth 1 client-message) 'TARGETS)
t)
(setq state (pgtk-dnd-get-state-for-frame frame)))
(let* ((action (nth 3 client-message))
(time (nth 2 client-message))
(action-type (pgtk-dnd-maybe-call-test-function window
action)))
;; Get the selection contents now. GdkWaylandSelection
;; becomes unavailable immediately after `drag-drop' is sent.
(let* ((current-type (pgtk-dnd-current-type window))
(current-action-type (car-safe (aref state 6))))
(when (and current-type
(not (equal current-action-type action-type)))
(aset state 6 (cons action-type
(pgtk-get-selection-internal
(nth 1 client-message)
(intern current-type))))))
(pgtk-update-drop-status (car action-type) time)
(dnd-handle-movement (event-start event)))))
((eq (car client-message) 'quote) ; drag-drop
(let* ((state (pgtk-dnd-get-state-for-frame frame))
(timestamp (nth 2 client-message))
(value (and (pgtk-dnd-current-type window)
(or (cdr-safe (aref state 6))
(pgtk-get-selection-internal
(nth 1 client-message)
(intern (pgtk-dnd-current-type window))
timestamp))))
action)
(unwind-protect
(setq action (when value
(condition-case info
(pgtk-dnd-drop-data
event frame window value
(pgtk-dnd-current-type window))
(error
(message "Error: %s" info)
nil))))
(pgtk-drop-finish action timestamp (eq action 'move))
(pgtk-dnd-forget-drop window))))))