emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b47d36f189: Improve Haiku selection handling


From: Po Lu
Subject: master b47d36f189: Improve Haiku selection handling
Date: Mon, 14 Feb 2022 05:27:07 -0500 (EST)

branch: master
commit b47d36f189d067ebf41098021da1d1e160db9d53
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve Haiku selection handling
    
    * lisp/select.el (gui--selection-value-internal): Use X types on
    Haiku as well.
    
    * lisp/term/haiku-win.el (haiku--selection-type-to-mime): Update
    types to correspond better with X.
    
    * src/haikuselect.c (Fhaiku_selection_data):
    (Fhaiku_selection_put): Remove a great deal of ad hoc code now
    handled by the regular selection machinery.
---
 lisp/select.el         |  2 +-
 lisp/term/haiku-win.el |  3 ++-
 src/haikuselect.c      | 31 +++++++------------------------
 3 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/lisp/select.el b/lisp/select.el
index ca9061c0b0..42b50c44e6 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -176,7 +176,7 @@ decoded.  If `gui-get-selection' signals an error, return 
nil."
            (memq window-system '(x haiku))
            (eq type 'CLIPBOARD)
            (gui-backend-selection-owner-p type))
-    (let ((request-type (if (memq window-system '(x pgtk))
+    (let ((request-type (if (memq window-system '(x pgtk haiku))
                             (or x-select-request-type
                                 '(UTF8_STRING COMPOUND_TEXT STRING 
text/plain\;charset=utf-8))
                           'STRING))
diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el
index 4c06f7f58a..c4810f116d 100644
--- a/lisp/term/haiku-win.el
+++ b/lisp/term/haiku-win.el
@@ -86,7 +86,8 @@ DISPLAY may be set to the name of a display that will be 
initialized."
   "Convert symbolic selection type TYPE to its MIME equivalent.
 If TYPE is nil, return \"text/plain\"."
   (cond
-   ((memq type '(TEXT COMPOUND_TEXT STRING UTF8_STRING)) "text/plain")
+   ((eq type 'STRING) "text/plain;charset=iso-8859-1")
+   ((eq type 'UTF8_STRING) "text/plain")
    ((stringp type) type)
    ((symbolp type) (symbol-name type))
    (t "text/plain")))
diff --git a/src/haikuselect.c b/src/haikuselect.c
index e65ab827c5..65dac0e02f 100644
--- a/src/haikuselect.c
+++ b/src/haikuselect.c
@@ -97,20 +97,12 @@ fetch.  */)
     return Qnil;
 
   Lisp_Object str = make_unibyte_string (dat, len);
-  Lisp_Object lispy_type = Qnil;
 
-  if (!strcmp (SSDATA (name), "text/utf-8") ||
-      !strcmp (SSDATA (name), "text/plain"))
-    {
-      if (string_ascii_p (str))
-       lispy_type = QSTRING;
-      else
-       lispy_type = QUTF8_STRING;
-    }
-
-  if (!NILP (lispy_type))
-    Fput_text_property (make_fixnum (0), make_fixnum (len),
-                       Qforeign_selection, lispy_type, str);
+  /* `foreign-selection' just means that the selection has to be
+     decoded by `gui-get-selection'.  It has no other meaning,
+     AFAICT.  */
+  Fput_text_property (make_fixnum (0), make_fixnum (len),
+                     Qforeign_selection, Qt, str);
 
   block_input ();
   BClipboard_free_data (dat);
@@ -125,10 +117,8 @@ DEFUN ("haiku-selection-put", Fhaiku_selection_put, 
Shaiku_selection_put,
 CLIPBOARD is the symbol `PRIMARY', `SECONDARY' or `CLIPBOARD'.  NAME
 is a MIME type denoting the type of the data to add.  DATA is the
 string that will be placed in the clipboard, or nil if the content is
-to be removed.  If NAME is the string "text/utf-8" or the string
-"text/plain", encode it as UTF-8 before storing it into the clipboard.
-CLEAR, if non-nil, means to erase all the previous contents of the
-clipboard.  */)
+to be removed.  CLEAR, if non-nil, means to erase all the previous
+contents of the clipboard.  */)
   (Lisp_Object clipboard, Lisp_Object name, Lisp_Object data,
    Lisp_Object clear)
 {
@@ -138,13 +128,6 @@ clipboard.  */)
     CHECK_STRING (data);
 
   block_input ();
-  /* It seems that Haiku applications counter-intuitively expect
-     UTF-8 data in both text/utf-8 and text/plain.  */
-  if (!NILP (data) && STRING_MULTIBYTE (data) &&
-      (!strcmp (SSDATA (name), "text/utf-8") ||
-       !strcmp (SSDATA (name), "text/plain")))
-    data = ENCODE_UTF_8 (data);
-
   char *dat = !NILP (data) ? SSDATA (data) : NULL;
   ptrdiff_t len = !NILP (data) ? SBYTES (data) : 0;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]