Skip to content

Commit 32bd911

Browse files
committed
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.
1 parent 5669878 commit 32bd911

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

lisp/x-dnd.el

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,13 @@ FRAME is the frame and W is the window where the drop happened.
412412
If W is a window, return its absolute coordinates,
413413
otherwise return the frame coordinates."
414414
(let* ((frame-left (frame-parameter frame 'left))
415-
;; If the frame is outside the display, frame-left looks like
416-
;; '(0 -16). Extract the -16.
417-
(frame-real-left (if (consp frame-left) (car (cdr frame-left))
418-
frame-left))
419-
(frame-top (frame-parameter frame 'top))
420-
(frame-real-top (if (consp frame-top) (car (cdr frame-top))
421-
frame-top)))
415+
(frame-top (frame-parameter frame 'top)))
422416
(if (windowp w)
423417
(let ((edges (window-inside-pixel-edges w)))
424418
(cons
425-
(+ frame-real-left (nth 0 edges))
426-
(+ frame-real-top (nth 1 edges))))
427-
(cons frame-real-left frame-real-top))))
419+
(+ frame-left (nth 0 edges))
420+
(+ frame-top (nth 1 edges))))
421+
(cons frame-left frame-top))))
428422

429423
(declare-function x-get-atom-name "xselect.c" (value &optional frame))
430424
(declare-function x-send-client-message "xselect.c"
@@ -434,15 +428,11 @@ otherwise return the frame coordinates."
434428

435429
(defun x-dnd-version-from-flags (flags)
436430
"Return the version byte from the 32 bit FLAGS in an XDndEnter message."
437-
(if (consp flags) ;; Long as cons
438-
(ash (car flags) -8)
439-
(ash flags -24))) ;; Ordinary number
431+
(ash flags -24))
440432

441433
(defun x-dnd-more-than-3-from-flags (flags)
442434
"Return the nmore-than3 bit from the 32 bit FLAGS in an XDndEnter message."
443-
(if (consp flags)
444-
(logand (cdr flags) 1)
445-
(logand flags 1)))
435+
(logand flags 1))
446436

447437
(defun x-dnd-handle-xdnd (event frame window message _format data)
448438
"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."
454444
(version (x-dnd-version-from-flags flags))
455445
(more-than-3 (x-dnd-more-than-3-from-flags flags))
456446
(dnd-source (aref data 0)))
457-
(message "%s %s" version more-than-3)
447+
(message "%s %s" version more-than-3)
458448
(if version ;; If flags is bad, version will be nil.
459449
(x-dnd-save-state
460450
window nil nil
@@ -545,30 +535,25 @@ FORMAT is 32 (not used). MESSAGE is the data part of an XClientMessageEvent."
545535

546536
((eq size 4)
547537
(if (eq byteorder ?l)
548-
(cons (+ (ash (aref data (+ 3 offset)) 8)
549-
(aref data (+ 2 offset)))
550-
(+ (ash (aref data (1+ offset)) 8)
551-
(aref data offset)))
552-
(cons (+ (ash (aref data offset) 8)
553-
(aref data (1+ offset)))
554-
(+ (ash (aref data (+ 2 offset)) 8)
555-
(aref data (+ 3 offset))))))))
538+
(+ (ash (aref data (+ 3 offset)) 24)
539+
(ash (aref data (+ 2 offset)) 16)
540+
(ash (aref data (1+ offset)) 8)
541+
(aref data offset))
542+
(+ (ash (aref data offset) 24)
543+
(aref data (1+ offset) 16)
544+
(ash (aref data (+ 2 offset)) 8)
545+
(aref data (+ 3 offset)))))))
556546

557547
(defun x-dnd-motif-value-to-list (value size byteorder)
558548
(let ((bytes (cond ((eq size 2)
559549
(list (logand (ash value -8) ?\xff)
560550
(logand value ?\xff)))
561551

562552
((eq size 4)
563-
(if (consp value)
564-
(list (logand (ash (car value) -8) ?\xff)
565-
(logand (car value) ?\xff)
566-
(logand (ash (cdr value) -8) ?\xff)
567-
(logand (cdr value) ?\xff))
568-
(list (logand (ash value -24) ?\xff)
569-
(logand (ash value -16) ?\xff)
570-
(logand (ash value -8) ?\xff)
571-
(logand value ?\xff)))))))
553+
(list (logand (ash value -24) ?\xff)
554+
(logand (ash value -16) ?\xff)
555+
(logand (ash value -8) ?\xff)
556+
(logand value ?\xff))))))
572557
(if (eq byteorder ?l)
573558
(reverse bytes)
574559
bytes)))

0 commit comments

Comments
 (0)