X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Flib%2Felm_cnp.c;h=cf081899b2fdafd04527cce1823a266581f6fa5e;hb=4ed84da20140d37c8bc43c95e24eff275fa90a41;hp=41c8f5243a944ec0f0006d1c1a977de4ddbb8793;hpb=d493e889fe0330f6ada33617161e5b3c3e1451c0;p=framework%2Fuifw%2Felementary.git diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c index 41c8f52..cf08189 100644 --- a/src/lib/elm_cnp.c +++ b/src/lib/elm_cnp.c @@ -324,7 +324,7 @@ static Cnp_Atom atoms[CNP_N_ATOMS] = { }, }; -static Cnp_Selection selections[ELM_SEL_TYPE_MAX] = { +static Cnp_Selection selections[ELM_SEL_TYPE_CLIPBOARD + 1] = { ARRAYINIT(ELM_SEL_TYPE_PRIMARY) { .debug = "Primary", .ecore_sel = ECORE_X_SELECTION_PRIMARY, @@ -339,6 +339,11 @@ static Cnp_Selection selections[ELM_SEL_TYPE_MAX] = { .clear = ecore_x_selection_secondary_clear, .request = ecore_x_selection_secondary_request, }, + ARRAYINIT(ELM_SEL_TYPE_XDND) { + .debug = "XDnD", + .ecore_sel = ECORE_X_SELECTION_XDND, + .request = ecore_x_selection_xdnd_request, + }, ARRAYINIT(ELM_SEL_TYPE_CLIPBOARD) { .debug = "Clipboard", .ecore_sel = ECORE_X_SELECTION_CLIPBOARD, @@ -346,11 +351,6 @@ static Cnp_Selection selections[ELM_SEL_TYPE_MAX] = { .clear = ecore_x_selection_clipboard_clear, .request = ecore_x_selection_clipboard_request, }, - ARRAYINIT(ELM_SEL_TYPE_XDND) { - .debug = "XDnD", - .ecore_sel = ECORE_X_SELECTION_XDND, - .request = ecore_x_selection_xdnd_request, - }, }; /* Data for DND in progress */ @@ -390,7 +390,7 @@ elm_selection_selection_has_owner(void) } EAPI Eina_Bool -elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj, +elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, Elm_Sel_Format format, const void *selbuf, size_t buflen) { #ifdef HAVE_ELEMENTARY_X @@ -400,11 +400,11 @@ elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj, if (top) xwin = elm_win_xwindow_get(top); else xwin = elm_win_xwindow_get(obj); - if ((!xwin) || (selection >= ELM_SEL_TYPE_MAX)) + if ((!xwin) || (selection > ELM_SEL_TYPE_CLIPBOARD)) return EINA_FALSE; if (!_elm_cnp_init_count) _elm_cnp_init(); if ((!selbuf) && (format != ELM_SEL_FORMAT_IMAGE)) - return elm_cnp_selection_clear(selection, obj); + return elm_object_cnp_selection_clear(obj, selection); sel = selections + selection; @@ -417,7 +417,8 @@ elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj, { if (format == ELM_SEL_FORMAT_IMAGE) { - sel->selbuf = malloc(buflen+1); + // selbuf is actual image data, not text/string + sel->selbuf = malloc(buflen); memcpy(sel->selbuf, selbuf, buflen); } else @@ -433,12 +434,12 @@ elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *obj, } EAPI Eina_Bool -elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *obj) +elm_object_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type selection) { #ifdef HAVE_ELEMENTARY_X Cnp_Selection *sel; - if ((unsigned int)selection >= (unsigned int)ELM_SEL_TYPE_MAX) + if ((unsigned int)selection > (unsigned int)ELM_SEL_TYPE_CLIPBOARD) return EINA_FALSE; if (!_elm_cnp_init_count) _elm_cnp_init(); @@ -463,14 +464,14 @@ elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *obj) } EAPI Eina_Bool -elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, - Evas_Object *obj, Elm_Drop_Cb datacb, void *udata) +elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection, + Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata) { #ifdef HAVE_ELEMENTARY_X Evas_Object *top; Cnp_Selection *sel; - if (selection >= ELM_SEL_TYPE_MAX) + if (selection > ELM_SEL_TYPE_CLIPBOARD) return EINA_FALSE; if (!_elm_cnp_init_count) _elm_cnp_init(); @@ -519,13 +520,13 @@ selection_clear(void *udata __UNUSED__, int type __UNUSED__, void *event) Cnp_Selection *sel; int i; - for (i = 0; i < ELM_SEL_TYPE_MAX; i++) + for (i = 0; i <= ELM_SEL_TYPE_CLIPBOARD; i++) { if (selections[i].ecore_sel == ev->selection) break; } cnp_debug("selection %d clear\n", i); /* Not me... Don't care */ - if (i == ELM_SEL_TYPE_MAX) return ECORE_CALLBACK_PASS_ON; + if (i > ELM_SEL_TYPE_CLIPBOARD) return ECORE_CALLBACK_PASS_ON; sel = selections + i; sel->active = EINA_FALSE; @@ -556,9 +557,6 @@ selection_notify(void *udata __UNUSED__, int type __UNUSED__, void *event) cnp_debug("selection notify callback: %d\n",ev->selection); switch (ev->selection) { - case ECORE_X_SELECTION_CLIPBOARD: - sel = selections + ELM_SEL_TYPE_CLIPBOARD; - break; case ECORE_X_SELECTION_PRIMARY: sel = selections + ELM_SEL_TYPE_PRIMARY; break; @@ -568,6 +566,9 @@ selection_notify(void *udata __UNUSED__, int type __UNUSED__, void *event) case ECORE_X_SELECTION_XDND: sel = selections + ELM_SEL_TYPE_XDND; break; + case ECORE_X_SELECTION_CLIPBOARD: + sel = selections + ELM_SEL_TYPE_CLIPBOARD; + break; default: return ECORE_CALLBACK_PASS_ON; } @@ -600,7 +601,7 @@ _get_selection_type(void *data, int size) Cnp_Selection *sel = selections + *((int *)data); if (sel->active && (sel->format >= ELM_SEL_FORMAT_TARGETS) && - (sel->format < ELM_SEL_FORMAT_MAX)) + (sel->format <= ELM_SEL_FORMAT_HTML)) return sel->format; } return ELM_SEL_FORMAT_NONE; @@ -715,7 +716,7 @@ notify_handler_targets(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notif if ((j == CNP_ATOM_text_uri) || (j == CNP_ATOM_text_urilist)) { - if(!is_uri_type_data(sel, notify)) continue; + if (!is_uri_type_data(sel, notify)) continue; } cnp_debug("Atom %s matches\n",atoms[j].name); goto done; @@ -775,8 +776,13 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify) { Ecore_X_Selection_Data *data; char *str; + char *mkupstr; data = notify->data; + str = malloc(sizeof(char) * (data->length + 1)); + if (!str) return 0; + strncpy(str, (char *)data->data, data->length); + str[data->length] = '\0'; if (sel->datacb) { @@ -787,14 +793,17 @@ notify_handler_text(Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notify) ddata.data = data->data; ddata.len = data->length; sel->datacb(sel->udata, sel->widget, &ddata); + free(str); return 0; } - cnp_debug("Notify handler text %d %d %p\n", data->format,data->length, data->data); - str = _elm_util_text_to_mkup((const char *) data->data); + cnp_debug("Notify handler text %d %d %p\n", data->format, + data->length, data->data); + mkupstr = _elm_util_text_to_mkup((const char *)str); cnp_debug("String is %s (from %s)\n", str, data->data); - _elm_entry_entry_paste(sel->requestwidget, str); + _elm_entry_entry_paste(sel->requestwidget, mkupstr); free(str); + free(mkupstr); return 0; } @@ -1471,7 +1480,7 @@ elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data, void ( ecore_x_dnd_callback_pos_update_set(_drag_move, NULL); ecore_x_dnd_begin(xwin, (unsigned char *)&xdnd, sizeof(Elm_Sel_Type)); evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP, - _drag_mouse_up, (uintptr_t *)xwin); + _drag_mouse_up, (void *)(long)xwin); handler_status = ecore_event_handler_add(ECORE_X_EVENT_XDND_STATUS, _dnd_status, NULL);