mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
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
This commit is contained in:
parent
d49d10b14f
commit
59a697f773
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user