summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-05-10 13:16:46 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-05-10 13:23:05 -0400
commit37ed59474eaea466663d1da218b447f8427263f9 (patch)
tree9af762807ff46c8094468988771c76b223732f30
parent4126b7fabab7666a9778da0aecaf650a3f8f2f9e (diff)
Revert "elm cnp/Wl: Remove duplicated data receive callback"
This reverts commit f5d10f1961fcfae5ca0204c1bc0c787c96fb4f2c. this breaks pasting into efl applications on wayland fix T3455
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_dnd.c3
-rw-r--r--src/lib/elementary/elm_cnp.c213
2 files changed, 116 insertions, 100 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_dnd.c b/src/lib/ecore_wl2/ecore_wl2_dnd.c
index 26ab52fbd5..e9feb129fb 100644
--- a/src/lib/ecore_wl2/ecore_wl2_dnd.c
+++ b/src/lib/ecore_wl2/ecore_wl2_dnd.c
@@ -235,8 +235,7 @@ _selection_data_read(void *data, Ecore_Fd_Handler *fdh)
235 event->sel_type = source->sel_type; 235 event->sel_type = source->sel_type;
236 if (len <= 0) 236 if (len <= 0)
237 { 237 {
238 if (source->input->drag.source && 238 if (source->input->drag.source)
239 source->sel_type == ECORE_WL2_SELECTION_DND)
240 { 239 {
241 if (source->input->display->wl.data_device_manager_version >= 240 if (source->input->display->wl.data_device_manager_version >=
242 WL_DATA_OFFER_FINISH_SINCE_VERSION) 241 WL_DATA_OFFER_FINISH_SINCE_VERSION)
diff --git a/src/lib/elementary/elm_cnp.c b/src/lib/elementary/elm_cnp.c
index 9cce31cfe0..17f46f8041 100644
--- a/src/lib/elementary/elm_cnp.c
+++ b/src/lib/elementary/elm_cnp.c
@@ -2424,8 +2424,6 @@ struct _Wl_Cnp_Selection
2424 Elm_Xdnd_Action action; 2424 Elm_Xdnd_Action action;
2425 2425
2426 Eina_Bool active : 1; 2426 Eina_Bool active : 1;
2427 Eina_Bool requestfinished : 1;
2428 const char *requesttype;
2429}; 2427};
2430 2428
2431static Eina_Bool _wl_elm_cnp_init(void); 2429static Eina_Bool _wl_elm_cnp_init(void);
@@ -2434,7 +2432,7 @@ static Wl_Cnp_Selection wl_cnp_selection =
2434{ 2432{
2435 0, 0, NULL, NULL, 2433 0, 0, NULL, NULL,
2436 NULL, 0, 0, NULL, NULL, NULL, 2434 NULL, 0, 0, NULL, NULL, NULL,
2437 0, NULL, 0, EINA_FALSE, EINA_FALSE, "" 2435 0, NULL, 0, EINA_FALSE
2438}; 2436};
2439 2437
2440static void _wl_sel_obj_del2(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED); 2438static void _wl_sel_obj_del2(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
@@ -2460,6 +2458,7 @@ static Eina_Bool _wl_dnd_position(void *data EINA_UNUSED, int type EINA_UNUSED,
2460static Eina_Bool _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); 2458static Eina_Bool _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
2461/* static Eina_Bool _wl_dnd_offer(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); */ 2459/* static Eina_Bool _wl_dnd_offer(void *data EINA_UNUSED, int type EINA_UNUSED, void *event); */
2462 2460
2461static Eina_Bool _wl_dnd_receive(void *data, int type EINA_UNUSED, void *event);
2463static Eina_Bool _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED); 2462static Eina_Bool _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED);
2464static void _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Selection_Data_Ready *ev); 2463static void _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Selection_Data_Ready *ev);
2465 2464
@@ -2710,49 +2709,6 @@ done:
2710} 2709}
2711 2710
2712static Eina_Bool 2711static Eina_Bool
2713_wl_selection_get_timer_cb(void *data)
2714{
2715 Wl_Cnp_Selection *sel = data;
2716 Ecore_Wl2_Window *win;
2717
2718 win = _wl_elm_widget_window_get(sel->requestwidget);
2719 ecore_wl2_dnd_selection_get(ecore_wl2_window_input_get(win),
2720 sel->requesttype);
2721 return ECORE_CALLBACK_CANCEL;
2722}
2723
2724static Eina_Bool
2725_wl_notify_handler_targets(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Selection_Data_Ready *ev)
2726{
2727 cnp_debug("In\n");
2728 if (!ev) return EINA_FALSE;
2729 char *data = ev->data;
2730 int len = ev->len;
2731 int count = 0, i = 0;
2732 char **data_arr = NULL;
2733 Cnp_Atom *atom = NULL;
2734
2735 _wl_selection_parser(data, len, &data_arr, &count);
2736 for (i = 0; i < count; i++)
2737 {
2738 atom = eina_hash_find(_types_hash, data_arr[i]);
2739 if (atom && (atom->formats != ELM_SEL_FORMAT_TARGETS))
2740 {
2741 cnp_debug("Match found: %s\n", atom->name);
2742 sel->requestfinished = EINA_FALSE;
2743 /* Since we cannot call ecore_wl2_dnd_selection_get in here
2744 (it makes selection_send cannot be called), we use ecore_timer
2745 to call it */
2746 sel->requesttype = atom->name;
2747 ecore_timer_add(0.001, _wl_selection_get_timer_cb, sel);
2748 break;
2749 }
2750 }
2751 free(data_arr);
2752 return EINA_TRUE;
2753}
2754
2755static Eina_Bool
2756_wl_data_preparer_markup(Wl_Cnp_Selection *sel, Elm_Selection_Data *ddata, Ecore_Wl2_Event_Selection_Data_Ready *ev, Tmp_Info **tmp_info EINA_UNUSED) 2712_wl_data_preparer_markup(Wl_Cnp_Selection *sel, Elm_Selection_Data *ddata, Ecore_Wl2_Event_Selection_Data_Ready *ev, Tmp_Info **tmp_info EINA_UNUSED)
2757{ 2713{
2758 cnp_debug("In\n"); 2714 cnp_debug("In\n");
@@ -3065,9 +3021,9 @@ _wl_elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type selection, Elm_Se
3065 sel->requestformat = format; 3021 sel->requestformat = format;
3066 sel->requestwidget = (Evas_Object *) obj; 3022 sel->requestwidget = (Evas_Object *) obj;
3067 sel->win = win; 3023 sel->win = win;
3024 /* sel->request(win, ECORE_X_SELECTION_TARGET_TARGETS); */
3068 sel->datacb = datacb; 3025 sel->datacb = datacb;
3069 sel->udata = udata; 3026 sel->udata = udata;
3070 sel->requesttype = "TARGETS";
3071 3027
3072 evas_object_event_callback_add(sel->requestwidget, 3028 evas_object_event_callback_add(sel->requestwidget,
3073 EVAS_CALLBACK_DEL, _wl_sel_obj_del2, 3029 EVAS_CALLBACK_DEL, _wl_sel_obj_del2,
@@ -3077,7 +3033,28 @@ _wl_elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type selection, Elm_Se
3077 (selection == ELM_SEL_TYPE_PRIMARY) || 3033 (selection == ELM_SEL_TYPE_PRIMARY) ||
3078 (selection == ELM_SEL_TYPE_SECONDARY)) 3034 (selection == ELM_SEL_TYPE_SECONDARY))
3079 { 3035 {
3080 ecore_wl2_dnd_selection_get(ecore_wl2_window_input_get(win), "TARGETS"); 3036 const char *types[10] = {0, };
3037 int i = -1, j;
3038
3039 if ((format & ELM_SEL_FORMAT_MARKUP) ||
3040 (format & ELM_SEL_FORMAT_TEXT))
3041 {
3042 types[++i] = "application/x-elementary-markup";
3043 types[++i] = "text/plain";
3044 types[++i] = "text/plain;charset=utf-8";
3045 }
3046
3047 if (format & ELM_SEL_FORMAT_HTML)
3048 {
3049 types[++i] = "text/html";
3050 types[++i] = "text/html;charset=utf-8";
3051 }
3052
3053 if (i < 0) return EINA_FALSE;
3054
3055 for (j = 0; j <= i; j++)
3056 if (ecore_wl2_dnd_selection_get(ecore_wl2_window_input_get(win), types[j]))
3057 break;
3081 } 3058 }
3082 3059
3083 return EINA_TRUE; 3060 return EINA_TRUE;
@@ -3185,74 +3162,78 @@ _wl_selection_send(void *data, int type EINA_UNUSED, void *event)
3185 return ECORE_CALLBACK_PASS_ON; 3162 return ECORE_CALLBACK_PASS_ON;
3186} 3163}
3187 3164
3188static void 3165static Eina_Bool
3189_wl_selection_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl2_Event_Selection_Data_Ready *ev) 3166_wl_selection_receive(void *udata, int type EINA_UNUSED, void *event)
3190{ 3167{
3191 cnp_debug("In\n"); 3168 Wl_Cnp_Selection *sel = udata;
3192 sel->requestfinished = EINA_TRUE; 3169 Ecore_Wl2_Event_Selection_Data_Ready *ev = event;
3193 if (sel->datacb) 3170
3171 _wl_elm_cnp_init();
3172
3173 if (sel->requestwidget)
3194 { 3174 {
3195 if (!strcmp(sel->requesttype, "TARGETS") || 3175 if (!ev->done)
3196 !strcmp(sel->requesttype, "ATOMS"))
3197 {
3198 _wl_notify_handler_targets(sel, ev);
3199 }
3200 else
3201 { 3176 {
3202 Cnp_Atom *atom = eina_hash_find(_types_hash, sel->requesttype); 3177 if (sel->seltype == ELM_SEL_TYPE_XDND)
3203 if (atom && atom->wl_data_preparer)
3204 { 3178 {
3205 Elm_Selection_Data sdata; 3179 Elm_Selection_Data sdata;
3206 Tmp_Info *tmp_info = NULL; 3180 Eina_List *l;
3207 Eina_Bool success; 3181 Dropable *dropable;
3208 sdata.data = NULL;
3209 3182
3210 cnp_debug("Call notify for: %s\n", atom->name); 3183 EINA_LIST_FOREACH(drops, l, dropable)
3211 success = atom->wl_data_preparer(sel, &sdata, ev, &tmp_info);
3212 if (success)
3213 { 3184 {
3214 sdata.x = sdata.y = 0; 3185 if (dropable->obj == sel->requestwidget) break;
3215 sel->datacb(sel->udata, 3186 dropable = NULL;
3216 sel->requestwidget,
3217 &sdata);
3218 } 3187 }
3219 if (tmp_info) _tmpinfo_free(tmp_info);
3220 free(sdata.data);
3221 }
3222 }
3223 }
3224 else
3225 {
3226 cnp_debug("request to paste: datacb does not exist\n");
3227 }
3228}
3229 3188
3189 if (dropable)
3190 {
3191 Dropable_Cbs *cbs;
3230 3192
3231static Eina_Bool 3193 sdata.x = savedtypes.x;
3232_wl_selection_receive(void *data, int type EINA_UNUSED, void *event) 3194 sdata.y = savedtypes.y;
3233{ 3195 sdata.format = ELM_SEL_FORMAT_TEXT;
3234 Wl_Cnp_Selection *sel; 3196 sdata.data = ev->data;
3235 Ecore_Wl2_Event_Selection_Data_Ready *ev; 3197 sdata.len = ev->len;
3236 cnp_debug("In\n"); 3198 sdata.action = sel->action;
3237 3199
3238 _wl_elm_cnp_init(); 3200 EINA_INLIST_FOREACH(dropable->cbs_list, cbs)
3239 ev = event; 3201 if (cbs->dropcb)
3240 sel = data; 3202 cbs->dropcb(cbs->dropdata, dropable->obj, &sdata);
3241 3203
3242 if (sel->requestwidget) 3204 goto end;
3243 { 3205 }
3244 if (!ev->done) 3206 }
3245 { 3207
3246 if (ev->sel_type == ECORE_WL2_SELECTION_DND) 3208 if (sel->datacb)
3247 { 3209 {
3248 _wl_dropable_data_handle(sel, ev); 3210 Elm_Selection_Data sdata;
3211
3212 sdata.x = sdata.y = 0;
3213 sdata.format = ELM_SEL_FORMAT_TEXT;
3214 sdata.data = ev->data;
3215 sdata.len = ev->len;
3216 sdata.action = sel->action;
3217 sel->datacb(sel->udata,
3218 sel->requestwidget,
3219 &sdata);
3249 } 3220 }
3250 else 3221 else
3251 { 3222 {
3252 _wl_selection_data_handle(sel, ev); 3223 char *stripstr, *mkupstr;
3224
3225 stripstr = malloc(ev->len + 1);
3226 if (!stripstr) goto end;
3227 strncpy(stripstr, (char *)ev->data, ev->len);
3228 stripstr[ev->len] = '\0';
3229 mkupstr = _elm_util_text_to_mkup((const char *)stripstr);
3230 /* TODO BUG: should never NEVER assume it's an elm_entry! */
3231 _elm_entry_entry_paste(sel->requestwidget, mkupstr);
3232 free(stripstr);
3233 free(mkupstr);
3253 } 3234 }
3254 } 3235 }
3255 else if (sel->requestfinished) 3236 else
3256 { 3237 {
3257 evas_object_event_callback_del_full(sel->requestwidget, 3238 evas_object_event_callback_del_full(sel->requestwidget,
3258 EVAS_CALLBACK_DEL, 3239 EVAS_CALLBACK_DEL,
@@ -3261,6 +3242,12 @@ _wl_selection_receive(void *data, int type EINA_UNUSED, void *event)
3261 } 3242 }
3262 } 3243 }
3263 3244
3245end:
3246 if (sel->seltype == ELM_SEL_TYPE_XDND)
3247 {
3248 /* FIXME: Send Finished ?? */
3249 }
3250
3264 return ECORE_CALLBACK_PASS_ON; 3251 return ECORE_CALLBACK_PASS_ON;
3265} 3252}
3266 3253
@@ -3291,6 +3278,8 @@ _wl_elm_dnd_init(void)
3291 text_uri = eina_stringshare_add("text/uri-list"); 3278 text_uri = eina_stringshare_add("text/uri-list");
3292 3279
3293 _wl_elm_cnp_init(); 3280 _wl_elm_cnp_init();
3281 ecore_event_handler_add(ECORE_WL2_EVENT_SELECTION_DATA_READY,
3282 _wl_dnd_receive, &wl_cnp_selection);
3294 3283
3295 ecore_event_handler_add(ECORE_WL2_EVENT_DND_END, 3284 ecore_event_handler_add(ECORE_WL2_EVENT_DND_END,
3296 _wl_dnd_end, &wl_cnp_selection); 3285 _wl_dnd_end, &wl_cnp_selection);
@@ -3718,6 +3707,34 @@ _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3718} 3707}
3719 3708
3720static Eina_Bool 3709static Eina_Bool
3710_wl_dnd_receive(void *data, int type EINA_UNUSED, void *event)
3711{
3712 Wl_Cnp_Selection *sel;
3713 Ecore_Wl2_Event_Selection_Data_Ready *ev;
3714 cnp_debug("In\n");
3715
3716 ev = event;
3717 sel = data;
3718
3719 if (sel->requestwidget)
3720 {
3721 if (!ev->done)
3722 {
3723 _wl_dropable_data_handle(sel, ev);
3724 }
3725 else
3726 {
3727 evas_object_event_callback_del_full(sel->requestwidget,
3728 EVAS_CALLBACK_DEL,
3729 _wl_sel_obj_del2, sel);
3730 sel->requestwidget = NULL;
3731 }
3732 }
3733
3734 return ECORE_CALLBACK_PASS_ON;
3735}
3736
3737static Eina_Bool
3721_wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 3738_wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3722{ 3739{
3723 Ecore_Wl2_Event_Dnd_End *ev; 3740 Ecore_Wl2_Event_Dnd_End *ev;