[mutter/wip/carlosg/map-mimetype-to-atom] x11: Map mimetypes back to selection atoms



commit 5c1be2233de15c7bb18bbb32b8071b78e992a0c5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 12 19:15:11 2019 +0200

    x11: Map mimetypes back to selection atoms
    
    This may be seen as the missing half of
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/842. Now that we
    translate some atoms to better known mimetypes, we should also translate
    those mimetypes to the underlying atoms if we might have added them.
    
    Fixes c&p from certain X11 clients.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/854

 src/x11/meta-selection-source-x11.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/x11/meta-selection-source-x11.c b/src/x11/meta-selection-source-x11.c
index 1a0369ab0..55e500327 100644
--- a/src/x11/meta-selection-source-x11.c
+++ b/src/x11/meta-selection-source-x11.c
@@ -82,6 +82,15 @@ meta_selection_source_x11_read_async (MetaSelectionSource *source,
   task = g_task_new (source, cancellable, callback, user_data);
   g_task_set_source_tag (task, meta_selection_source_x11_read_async);
 
+  if (strcmp (mimetype, "text/plain") == 0 &&
+      g_list_find_custom (source_x11->mimetypes, "STRING",
+                          (GCompareFunc) g_strcmp0))
+    mimetype = "STRING";
+  else if (strcmp (mimetype, "text/plain;charset=utf-8") == 0 &&
+           g_list_find_custom (source_x11->mimetypes, "UTF8_STRING",
+                               (GCompareFunc) g_strcmp0))
+    mimetype = "UTF8_STRING";
+
   meta_x11_selection_input_stream_new_async (source_x11->x11_display,
                                              source_x11->x11_display->selection.xwindow,
                                              gdk_x11_get_xatom_name (source_x11->xselection),


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