aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-06-10 15:27:07 +0800
committerPo Lu2022-06-10 15:27:07 +0800
commit32aa5c76bdb0236f159f24a7d8a7698b88fcb712 (patch)
tree6b04b787109c221c0971375ef772eff6c58a5d83
parent45bdeb7d9c62dbc4811db85da81993f45b6b9780 (diff)
downloademacs-32aa5c76bdb0236f159f24a7d8a7698b88fcb712.tar.gz
emacs-32aa5c76bdb0236f159f24a7d8a7698b88fcb712.zip
Fix receiving drops from drop-only Motif programs
* lisp/x-dnd.el (x-dnd-xm-read-targets-table): Fix doc string. (x-dnd-handle-motif): Recompute types and state on XmDROP_START if no state already exists.
-rw-r--r--lisp/x-dnd.el121
1 files changed, 67 insertions, 54 deletions
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index 85b4138f170..7ee20e0fc3c 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -624,7 +624,9 @@ describing the selection targets in the current rec."
624 624
625(defun x-dnd-xm-read-targets-table (frame) 625(defun x-dnd-xm-read-targets-table (frame)
626 "Read the Motif targets table on FRAME. 626 "Read the Motif targets table on FRAME.
627Return a vector of vectors of numbers (the drop targets)." 627Return a vector of vectors of numbers, which are the atoms of the
628available selection targets for each index into the selection
629table."
628 (let* ((drag-window (x-window-property "_MOTIF_DRAG_WINDOW" 630 (let* ((drag-window (x-window-property "_MOTIF_DRAG_WINDOW"
629 frame "WINDOW" 0 nil t)) 631 frame "WINDOW" 0 nil t))
630 (targets-data (x-window-property "_MOTIF_DRAG_TARGETS" 632 (targets-data (x-window-property "_MOTIF_DRAG_TARGETS"
@@ -809,60 +811,71 @@ Return a vector of atoms containing the selection targets."
809 (selection-atom (x-dnd-get-motif-value 811 (selection-atom (x-dnd-get-motif-value
810 data 12 4 source-byteorder)) 812 data 12 4 source-byteorder))
811 (atom-name (x-get-atom-name selection-atom)) 813 (atom-name (x-get-atom-name selection-atom))
812 (dnd-source (x-dnd-get-motif-value 814 (dnd-source (x-dnd-get-motif-value
813 data 16 4 source-byteorder)) 815 data 16 4 source-byteorder)))
814 (action-type (x-dnd-maybe-call-test-function 816
815 window 817 ;; This might be a drop from a program that doesn't use
816 source-action)) 818 ;; the Motif drag protocol. Compute all the necessary
817 (reply-action (and (not (posn-area (event-start event))) 819 ;; state here if that is true.
818 (car (rassoc (car action-type) 820 (unless (and (x-dnd-get-state-for-frame frame)
819 x-dnd-motif-to-action)))) 821 (aref (x-dnd-get-state-for-frame frame) 2))
820 (reply-flags 822 (x-dnd-forget-drop frame)
821 (x-dnd-motif-value-to-list 823 (let ((types (x-dnd-xm-read-targets frame dnd-source
822 (if (posn-area (event-start event)) 824 atom-name)))
823 (+ ?\x20 ; 20: invalid drop site 825 (x-dnd-save-state window nil nil types dnd-source)))
824 ?\x200) ; 200: drop cancel 826
825 (if reply-action 827 (let* ((action-type (x-dnd-maybe-call-test-function
826 (+ reply-action 828 window
827 ?\x30 ; 30: valid drop site 829 source-action))
828 ?\x700) ; 700: can do copy, move or link 830 (reply-action (and (not (posn-area (event-start event)))
829 (+ ?\x30 ; 30: drop site, but noop. 831 (car (rassoc (car action-type)
830 ?\x200))) ; 200: drop cancel. 832 x-dnd-motif-to-action))))
833 (reply-flags
834 (x-dnd-motif-value-to-list
835 (if (posn-area (event-start event))
836 (+ ?\x20 ; 20: invalid drop site
837 ?\x200) ; 200: drop cancel
838 (if reply-action
839 (+ reply-action
840 ?\x30 ; 30: valid drop site
841 ?\x700) ; 700: can do copy, move or link
842 (+ ?\x30 ; 30: drop site, but noop.
843 ?\x200))) ; 200: drop cancel.
831 2 my-byteorder)) 844 2 my-byteorder))
832 (reply (append 845 (reply (append
833 (list 846 (list
834 (+ ?\x80 ; 0x80 indicates a reply. 847 (+ ?\x80 ; 0x80 indicates a reply.
835 5) ; DROP_START. 848 5) ; DROP_START.
836 my-byteorder) 849 my-byteorder)
837 reply-flags 850 reply-flags
838 x y)) 851 x y))
839 (timestamp (x-dnd-get-motif-value 852 (timestamp (x-dnd-get-motif-value
840 data 4 4 source-byteorder)) 853 data 4 4 source-byteorder))
841 action) 854 action)
842 855
843 (x-send-client-message frame 856 (x-send-client-message frame
844 dnd-source 857 dnd-source
845 frame 858 frame
846 "_MOTIF_DRAG_AND_DROP_MESSAGE" 859 "_MOTIF_DRAG_AND_DROP_MESSAGE"
847 8 860 8
848 reply) 861 reply)
849 (setq action 862 (setq action
850 (when (and reply-action atom-name) 863 (when (and reply-action atom-name)
851 (let* ((value (x-get-selection-internal 864 (let* ((value (x-get-selection-internal
852 (intern atom-name) 865 (intern atom-name)
853 (intern (x-dnd-current-type window))))) 866 (intern (x-dnd-current-type window)))))
854 (when value 867 (when value
855 (condition-case info 868 (condition-case info
856 (x-dnd-drop-data event frame window value 869 (x-dnd-drop-data event frame window value
857 (x-dnd-current-type window)) 870 (x-dnd-current-type window))
858 (error 871 (error
859 (message "Error: %s" info) 872 (message "Error: %s" info)
860 nil)))))) 873 nil))))))
861 (x-get-selection-internal 874 (x-get-selection-internal
862 (intern atom-name) 875 (intern atom-name)
863 (if action 'XmTRANSFER_SUCCESS 'XmTRANSFER_FAILURE) 876 (if action 'XmTRANSFER_SUCCESS 'XmTRANSFER_FAILURE)
864 timestamp) 877 timestamp)
865 (x-dnd-forget-drop frame))) 878 (x-dnd-forget-drop frame))))
866 879
867 (t (message "Unknown Motif drag-and-drop message: %s" 880 (t (message "Unknown Motif drag-and-drop message: %s"
868 (logand (aref data 0) #x3f))))))) 881 (logand (aref data 0) #x3f)))))))