]> git.eshelyaron.com Git - emacs.git/commitdiff
Adjust last change to Haiku as well
authorPo Lu <luangruo@yahoo.com>
Wed, 1 Jun 2022 08:39:26 +0000 (08:39 +0000)
committerPo Lu <luangruo@yahoo.com>
Wed, 1 Jun 2022 08:39:26 +0000 (08:39 +0000)
* lisp/term/haiku-win.el (haiku-dnd-selection-converters): Add
text/uri-list.
(haiku-dnd-convert-text-uri-list): New function.
(x-begin-drag): Handle alternative data specified in selection
local values.

lisp/term/haiku-win.el

index a8cc1da731aa3e0fab541b768701a7be2e48f07b..2a31dd38c8145e17697dc22e7bde5486d89b82db 100644 (file)
@@ -52,7 +52,8 @@
   "The local value of the special `XdndSelection' selection.")
 
 (defvar haiku-dnd-selection-converters '((STRING . haiku-dnd-convert-string)
-                                         (FILE_NAME . haiku-dnd-convert-file-name))
+                                         (FILE_NAME . haiku-dnd-convert-file-name)
+                                         (text/uri-list . haiku-dnd-convert-text-uri-list))
   "Alist of X selection types to functions that act as selection converters.
 The functions should accept a single argument VALUE, describing
 the value of the drag-and-drop selection, and return a list of
@@ -148,6 +149,19 @@ VALUE as a unibyte string, or nil if VALUE was not a string."
              (file-exists-p value))
     (list "refs" (propertize (expand-file-name value) 'type 'ref))))
 
+(defun haiku-dnd-convert-text-uri-list (value)
+  "Convert VALUE to a list of URLs."
+  (cond
+   ((stringp value) (list "text/uri-list"
+                          (concat (url-encode-url value) "\n")))
+   ((vectorp value) (list "text/uri-list"
+                          (with-temp-buffer
+                            (cl-loop for tem across value
+                                     do (progn
+                                          (insert (url-encode-url tem))
+                                          (insert "\n")))
+                            (buffer-string))))))
+
 (declare-function x-open-connection "haikufns.c")
 (declare-function x-handle-args "common-win")
 (declare-function haiku-selection-data "haikuselect.c")
@@ -341,12 +355,17 @@ take effect on menu items until the menu bar is updated again."
         (mouse-highlight nil)
         (haiku-signal-invalid-refs nil))
     (dolist (target targets)
-      (let ((selection-converter (cdr (assoc (intern target)
-                                             haiku-dnd-selection-converters))))
+      (let* ((target-atom (intern target))
+             (selection-converter (cdr (assoc target-atom
+                                              haiku-dnd-selection-converters))))
         (when selection-converter
           (let ((selection-result
                  (funcall selection-converter
-                          haiku-dnd-selection-value)))
+                          (if (stringp haiku-dnd-selection-value)
+                              (or (get-text-property 0 target-atom
+                                                     haiku-dnd-selection-value)
+                                  haiku-dnd-selection-value)
+                            haiku-dnd-selection-value))))
             (when selection-result
               (let ((field (cdr (assoc (car selection-result) message))))
                 (unless (cadr field)