]> code.delx.au - gnu-emacs/blobdiff - lisp/x-dnd.el
CC Mode: truncate the semi-nonlit cache when applying syntax-table to a quote
[gnu-emacs] / lisp / x-dnd.el
index 1c6af1f45f27403c0550a3edce95bcdbe4547641..eea9e9690022404cda7c14de2dd95b50a3c2c2bf 100644 (file)
@@ -1,9 +1,9 @@
-;;; x-dnd.el --- drag and drop support for X  -*- coding: utf-8 -*-
+;;; x-dnd.el --- drag and drop support for X
 
-;; Copyright (C) 2004-201 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
 
 ;; Author: Jan Djärv <jan.h.d@swipnet.se>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: window, drag, drop
 ;; Package: emacs
 
@@ -217,10 +217,10 @@ WINDOW is the window where the drop happened.  ACTION is ignored.
 DATA is the moz-url, which is formatted as two strings separated by \\r\\n.
 The first string is the URL, the second string is the title of that URL.
 DATA is encoded in utf-16.  Decode the URL and call `x-dnd-handle-uri-list'."
-  ;; Mozilla and applications based on it (Galeon for example) uses
-  ;; text/unicode, but it is impossible to tell if it is le or be.  Use what
-  ;; the machine Emacs runs on use.  This loses if dropping between machines
-  ;; with different endian, but it is the best we can do.
+  ;; Mozilla and applications based on it use text/unicode, but it is
+  ;; impossible to tell if it is le or be.  Use what the machine Emacs
+  ;; runs on uses.  This loses if dropping between machines
+  ;; with different endian-ness, but it is the best we can do.
   (let* ((coding (if (eq (byteorder) ?B) 'utf-16be 'utf-16le))
         (string (decode-coding-string data coding))
         (strings (split-string string "[\r\n]" t))
@@ -410,7 +410,7 @@ otherwise return the frame width/height."
   "Return the x/y coordinates to be sent in a XDndStatus message.
 Coordinates are required to be absolute.
 FRAME is the frame and W is the window where the drop happened.
-If W is a window, return its absolute corrdinates,
+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
@@ -431,7 +431,19 @@ otherwise return the frame coordinates."
 (declare-function x-send-client-message "xselect.c"
                  (display dest from message-type format values))
 (declare-function x-get-selection-internal "xselect.c"
-                 (selection-symbol target-type &optional time-stamp))
+                 (selection-symbol target-type &optional time-stamp terminal))
+
+(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
+
+(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)))
 
 (defun x-dnd-handle-xdnd (event frame window message _format data)
   "Receive one XDND event (client message) and send the appropriate reply.
@@ -440,9 +452,10 @@ 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 (and (consp flags) (ash (car flags) -8)))
-               (more-than-3 (and (consp flags) (cdr flags)))
+               (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