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; }