wayland: Figure out better the right selection source for a wl_data_offer

We were just looking at DnD actions which might still be unset at that
point. Instead of doing these heuristics, store the selection type on
the data offer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/845
This commit is contained in:
Carlos Garnacho 2019-10-11 19:32:42 +02:00
parent 84cc89e19a
commit e1751ad9ee

View File

@ -60,6 +60,7 @@ struct _MetaWaylandDataOffer
gboolean action_sent; gboolean action_sent;
uint32_t dnd_actions; uint32_t dnd_actions;
enum wl_data_device_manager_dnd_action preferred_dnd_action; enum wl_data_device_manager_dnd_action preferred_dnd_action;
MetaSelectionType selection_type;
}; };
typedef struct _MetaWaylandDataSourcePrivate typedef struct _MetaWaylandDataSourcePrivate
@ -399,11 +400,7 @@ data_offer_receive (struct wl_client *client, struct wl_resource *resource,
GList *mime_types; GList *mime_types;
gboolean found; gboolean found;
if (offer->dnd_actions != 0) selection_type = offer->selection_type;
selection_type = META_SELECTION_DND;
else
selection_type = META_SELECTION_CLIPBOARD;
mime_types = meta_selection_get_mimetypes (meta_display_get_selection (display), mime_types = meta_selection_get_mimetypes (meta_display_get_selection (display),
selection_type); selection_type);
found = g_list_find_custom (mime_types, mime_type, (GCompareFunc) g_strcmp0) != NULL; found = g_list_find_custom (mime_types, mime_type, (GCompareFunc) g_strcmp0) != NULL;
@ -622,6 +619,7 @@ create_and_send_dnd_offer (MetaWaylandDataSource *source,
MetaWaylandDataOffer *offer = g_slice_new0 (MetaWaylandDataOffer); MetaWaylandDataOffer *offer = g_slice_new0 (MetaWaylandDataOffer);
char **p; char **p;
offer->selection_type = META_SELECTION_DND;
offer->source = source; offer->source = source;
g_object_add_weak_pointer (G_OBJECT (source), (gpointer *)&offer->source); g_object_add_weak_pointer (G_OBJECT (source), (gpointer *)&offer->source);
offer->resource = wl_resource_create (wl_resource_get_client (target), offer->resource = wl_resource_create (wl_resource_get_client (target),
@ -2043,6 +2041,7 @@ create_and_send_clipboard_offer (MetaWaylandDataDevice *data_device,
return NULL; return NULL;
offer = g_slice_new0 (MetaWaylandDataOffer); offer = g_slice_new0 (MetaWaylandDataOffer);
offer->selection_type = META_SELECTION_CLIPBOARD;
offer->resource = wl_resource_create (wl_resource_get_client (target), offer->resource = wl_resource_create (wl_resource_get_client (target),
&wl_data_offer_interface, &wl_data_offer_interface,
wl_resource_get_version (target), 0); wl_resource_get_version (target), 0);
@ -2075,6 +2074,7 @@ create_and_send_primary_offer (MetaWaylandDataDevice *data_device,
return NULL; return NULL;
offer = g_slice_new0 (MetaWaylandDataOffer); offer = g_slice_new0 (MetaWaylandDataOffer);
offer->selection_type = META_SELECTION_PRIMARY;
offer->resource = wl_resource_create (wl_resource_get_client (target), offer->resource = wl_resource_create (wl_resource_get_client (target),
&gtk_primary_selection_offer_interface, &gtk_primary_selection_offer_interface,
wl_resource_get_version (target), 0); wl_resource_get_version (target), 0);