summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/x/ecore_evas_x.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-09 16:47:16 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-09 17:10:39 +0100
commit6524b0a155e774c5da93547e9ac052f478e98a92 (patch)
tree4d553ddf39ae39eff2398879e372bc168ebadc37 /src/modules/ecore_evas/engines/x/ecore_evas_x.c
parentf4ed0d4f930a00282b7b74d9f6fe2427f625d313 (diff)
ecore_evas_x: correctly handle images in X11
I thought that i explicitly tested this. However, it seems i was wrong, this way now this is handled correctly, and the image is stored and coverted to a path. With this you can now copy images from chromium and firefox to elm apps. The change in elm_entry reverts parts of the rewrite of the elm handling, as initially every path came *without* "file://" in front, so we have to maintain that. fixes T8625
Diffstat (limited to '')
-rw-r--r--src/modules/ecore_evas/engines/x/ecore_evas_x.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
index e6463fd6a9..05a8eb4499 100644
--- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c
+++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
@@ -3840,27 +3840,44 @@ _search_fitting_type_from_event(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edat
3840 eina_array_free(tmp); 3840 eina_array_free(tmp);
3841} 3841}
3842 3842
3843static Eina_Content*
3844_create_deliveriy_content(unsigned long int size, const void *mem, const char *mime_type)
3845{
3846 Eina_Content *content;
3847
3848 content = eina_content_new((Eina_Slice){.len = size, .mem = mem}, mime_type);
3849
3850 return content;
3851}
3852
3843static void 3853static void
3844_deliver_content(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edata, Ecore_Evas_Selection_Buffer selection, Ecore_X_Event_Selection_Notify *ev) 3854_deliver_content(Ecore_Evas *ee, Ecore_Evas_Engine_Data_X11 *edata, Ecore_Evas_Selection_Buffer selection, Ecore_X_Event_Selection_Notify *ev)
3845{ 3855{
3846 Ecore_X_Selection_Data *x11_data = ev->data; 3856 Ecore_X_Selection_Data *x11_data = ev->data;
3847 Eina_Rw_Slice data; 3857 Eina_Content *result = NULL;
3848 Eina_Content *result;
3849 Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type); 3858 Eina_Stringshare *mime_type = _decrypt_type(edata->selection_data[selection].requested_type);
3850 3859
3851 if (!strncmp(mime_type, "text", strlen("text"))) 3860 if (!strncmp(mime_type, "text", strlen("text")))
3852 { 3861 {
3853 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here. 3862 //ensure that we always have a \0 at the end, there is no assertion that \0 is included here.
3854 data.len = x11_data->length + 1; 3863 void *null_terminated = eina_memdup(x11_data->data, x11_data->length, EINA_TRUE);
3855 data.mem = eina_memdup(x11_data->data, x11_data->length, EINA_TRUE); 3864
3865 result = _create_deliveriy_content(x11_data->length + 1, null_terminated, mime_type);
3866 free(null_terminated);
3867 }
3868 else if (!strncmp(mime_type, "image", strlen("image")))
3869 {
3870 Eina_Content *tmp_container = eina_content_new((Eina_Slice){.len = x11_data->length, .mem = x11_data->data}, mime_type);
3871 const char *file = eina_content_as_file(tmp_container);
3872
3873 result = _create_deliveriy_content(strlen(file), file, mime_type);
3874 eina_content_free(tmp_container);
3856 } 3875 }
3857 else 3876 else
3858 { 3877 {
3859 data.len = x11_data->length; 3878 result = _create_deliveriy_content(x11_data->length, x11_data->data, mime_type);
3860 data.mem = x11_data->data;
3861 } 3879 }
3862 3880 EINA_SAFETY_ON_NULL_RETURN(result);
3863 result = eina_content_new(eina_rw_slice_slice_get(data), mime_type);
3864 3881
3865 //ensure that we deliver the correct type, we might have choosen a convertion before 3882 //ensure that we deliver the correct type, we might have choosen a convertion before
3866 if (edata->selection_data[selection].later_conversion != mime_type) 3883 if (edata->selection_data[selection].later_conversion != mime_type)