ecore_evas: fix null selection set 37/312537/1 accepted/tizen/unified/20240612.100000 accepted/tizen/unified/dev/20240620.010648 accepted/tizen/unified/toolchain/20240624.121558 accepted/tizen/unified/x/20240612.110433 accepted/tizen/unified/x/asan/20240625.092706
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 11 Jun 2024 10:06:42 +0000 (19:06 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 11 Jun 2024 10:06:42 +0000 (19:06 +0900)
I think that the selection claim should fail when there is no available type.
But.. a null selection set is called from elm_object_cnp_selection_clear.
For compatibility, if a null selection set is invoked,
the selection data will be cleared and true will be returned.

Change-Id: I89d40578c051cf01847ca7b9994c90554b2939d5
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c

index 1d198f4..7e80a8f 100644 (file)
@@ -3697,8 +3697,28 @@ _ecore_evas_wl_selection_claim(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Sel
    unsigned int type_count = eina_array_count(available_types);
    if (type_count == 0u)
      {
-        ERR("available_types is empty");
-        return EINA_FALSE;
+        ERR("available_types is empty, selection clear");
+        _reeval_seat(&seat, ee);
+
+        for (int i = 0 ; i < ECORE_EVAS_SELECTION_CNP_TYPE_LAST; ++i)
+          {
+             Ecore_Evas_Wl_Selection_Data *data = &wdata->selection_datas[i];
+             Ecore_Evas_Selection_Callbacks *cbs = &data->callbacks;
+             if (cbs->cancel)
+               {
+                  _clear_selection(ee, seat, selection, _cnp_type_to_mime_type((Ecore_Evas_Selection_Cnp_Type)i));
+               }
+
+             cbs->delivery = delivery;
+             cbs->cancel = cancel;
+             cbs->available_types = available_types;
+          }
+
+        char *tmp_array[type_count + 1];
+        tmp_array[type_count] = NULL;
+
+        ecore_wl2_dnd_selection_set(_fetch_input(ee, seat), (const char**)tmp_array);
+        return EINA_TRUE;
      }
 
    char *tmp_array[type_count + 1];