[mutter/wip/carlosg/x11-selection-supply-mimetypes] x11: Translate well known selection atoms to mimetypes
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/x11-selection-supply-mimetypes] x11: Translate well known selection atoms to mimetypes
- Date: Thu, 10 Oct 2019 10:57:56 +0000 (UTC)
commit ebee803fb753912b3654a059c3a86afc6464e8b0
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Oct 10 12:16:58 2019 +0200
x11: Translate well known selection atoms to mimetypes
Some antediluvian x11 clients only bother to set atoms like
UTF8_STRING/STRING/TEXT/... and no matching mimetypes. Cover for them
and add the well known mimetypes if they are missing.
Reported at https://bugzilla.redhat.com/show_bug.cgi?id=1758873
https://gitlab.gnome.org/GNOME/mutter/merge_requests/842
src/x11/meta-selection-source-x11.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/src/x11/meta-selection-source-x11.c b/src/x11/meta-selection-source-x11.c
index 15a763651..1a0369ab0 100644
--- a/src/x11/meta-selection-source-x11.c
+++ b/src/x11/meta-selection-source-x11.c
@@ -139,6 +139,8 @@ atoms_to_mimetypes (MetaX11Display *display,
const Atom *atoms;
gsize size;
guint i, n_atoms;
+ gboolean utf8_string_found = FALSE, utf8_text_plain_found = FALSE;
+ gboolean string_found = FALSE, text_plain_found = FALSE;
atoms = g_bytes_get_data (bytes, &size);
n_atoms = size / sizeof (Atom);
@@ -149,8 +151,19 @@ atoms_to_mimetypes (MetaX11Display *display,
mimetype = gdk_x11_get_xatom_name (atoms[i]);
mimetypes = g_list_prepend (mimetypes, g_strdup (mimetype));
+
+ utf8_text_plain_found |= strcmp (mimetype, "text/plain;charset=utf-8") == 0;
+ text_plain_found |= strcmp (mimetype, "text/plain") == 0;
+ utf8_string_found |= strcmp (mimetype, "UTF8_STRING") == 0;
+ string_found |= strcmp (mimetype, "STRING") == 0;
}
+ /* Ensure non-x11 clients get well-known mimetypes */
+ if (string_found && !text_plain_found)
+ mimetypes = g_list_prepend (mimetypes, g_strdup ("text/plain"));
+ if (utf8_string_found && !utf8_text_plain_found)
+ mimetypes = g_list_prepend (mimetypes, g_strdup ("text/plain;charset=utf-8"));
+
return mimetypes;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]