1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-24 19:03:29 +00:00

Simplify x-dnd.el due to bignums

* lisp/x-dnd.el (x-dnd-get-drop-x-y, x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags, x-dnd-get-motif-value)
(x-dnd-motif-value-to-list): Do not worry about pairs of
16-bit numbers, as the C code no longer generates them;
it generates bignums now, when needed on 32-bit platforms.
This commit is contained in:
Paul Eggert 2020-01-04 19:07:02 -08:00
parent 5669878d7f
commit 32bd911f82

View File

@ -412,19 +412,13 @@ FRAME is the frame and W is the window where the drop happened.
If W is a window, return its absolute coordinates,
otherwise return the frame coordinates."
(let* ((frame-left (frame-parameter frame 'left))
;; If the frame is outside the display, frame-left looks like
;; '(0 -16). Extract the -16.
(frame-real-left (if (consp frame-left) (car (cdr frame-left))
frame-left))
(frame-top (frame-parameter frame 'top))
(frame-real-top (if (consp frame-top) (car (cdr frame-top))
frame-top)))
(frame-top (frame-parameter frame 'top)))
(if (windowp w)
(let ((edges (window-inside-pixel-edges w)))
(cons
(+ frame-real-left (nth 0 edges))
(+ frame-real-top (nth 1 edges))))
(cons frame-real-left frame-real-top))))
(+ frame-left (nth 0 edges))
(+ frame-top (nth 1 edges))))
(cons frame-left frame-top))))
(declare-function x-get-atom-name "xselect.c" (value &optional frame))
(declare-function x-send-client-message "xselect.c"
@ -434,15 +428,11 @@ otherwise return the frame coordinates."
(defun x-dnd-version-from-flags (flags)
"Return the version byte from the 32 bit FLAGS in an XDndEnter message."
(if (consp flags) ;; Long as cons
(ash (car flags) -8)
(ash flags -24))) ;; Ordinary number
(ash flags -24))
(defun x-dnd-more-than-3-from-flags (flags)
"Return the nmore-than3 bit from the 32 bit FLAGS in an XDndEnter message."
(if (consp flags)
(logand (cdr flags) 1)
(logand flags 1)))
(logand flags 1))
(defun x-dnd-handle-xdnd (event frame window message _format data)
"Receive one XDND event (client message) and send the appropriate reply.
@ -454,7 +444,7 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
(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)
(message "%s %s" version more-than-3)
(if version ;; If flags is bad, version will be nil.
(x-dnd-save-state
window nil nil
@ -545,14 +535,14 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
((eq size 4)
(if (eq byteorder ?l)
(cons (+ (ash (aref data (+ 3 offset)) 8)
(aref data (+ 2 offset)))
(+ (ash (aref data (1+ offset)) 8)
(aref data offset)))
(cons (+ (ash (aref data offset) 8)
(aref data (1+ offset)))
(+ (ash (aref data (+ 2 offset)) 8)
(aref data (+ 3 offset))))))))
(+ (ash (aref data (+ 3 offset)) 24)
(ash (aref data (+ 2 offset)) 16)
(ash (aref data (1+ offset)) 8)
(aref data offset))
(+ (ash (aref data offset) 24)
(aref data (1+ offset) 16)
(ash (aref data (+ 2 offset)) 8)
(aref data (+ 3 offset)))))))
(defun x-dnd-motif-value-to-list (value size byteorder)
(let ((bytes (cond ((eq size 2)
@ -560,15 +550,10 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
(logand value ?\xff)))
((eq size 4)
(if (consp value)
(list (logand (ash (car value) -8) ?\xff)
(logand (car value) ?\xff)
(logand (ash (cdr value) -8) ?\xff)
(logand (cdr value) ?\xff))
(list (logand (ash value -24) ?\xff)
(logand (ash value -16) ?\xff)
(logand (ash value -8) ?\xff)
(logand value ?\xff)))))))
(list (logand (ash value -24) ?\xff)
(logand (ash value -16) ?\xff)
(logand (ash value -8) ?\xff)
(logand value ?\xff))))))
(if (eq byteorder ?l)
(reverse bytes)
bytes)))