raster pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=13734e51c1838d0300f862672c655bb9db9c10f1
commit 13734e51c1838d0300f862672c655bb9db9c10f1 Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Fri Apr 13 02:37:16 2018 +0900 efl selection - fix entry <-> plain text compy and paste in wl efl didnt convert markup to plain text when pasting markup -> text. this fixes that and enables middle mouse paste etc. etc. @fix --- src/lib/elementary/efl_selection_manager.c | 31 +++++++++++++++++++--- src/lib/elementary/efl_selection_manager_private.h | 3 ++- src/lib/elementary/elm_entry.c | 28 ++++++++++++------- 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c index 52edb97fd8..5b92f612ff 100644 --- a/src/lib/elementary/efl_selection_manager.c +++ b/src/lib/elementary/efl_selection_manager.c @@ -2829,9 +2829,31 @@ _wl_selection_receive(void *data, int type EINA_UNUSED, void *event) Efl_Selection_Data sel_data; sel_data.pos.x = sel_data.pos.y = 0; - sel_data.format = sel->format; - sel_data.content.mem = ev->data; - sel_data.content.len = ev->len; + if (((sel->format & EFL_SELECTION_FORMAT_MARKUP) || + (sel->format & EFL_SELECTION_FORMAT_HTML)) && + (sel->want_format == EFL_SELECTION_FORMAT_TEXT)) + { + char *tmp = malloc(ev->len + 1); + sel_data.format = sel->format; + sel_data.content.mem = NULL; + sel_data.content.len = 0; + if (tmp) + { + sel_data.format = sel->want_format; + strncpy(tmp, ev->data, ev->len); + tmp[ev->len] = 0; + sel_data.content.mem = _elm_util_mkup_to_text(tmp); + if (sel_data.content.mem) + sel_data.content.len = strlen(sel_data.content.mem); + free(tmp); + } + } + else + { + sel_data.format = sel->format; + sel_data.content.mem = ev->data; + sel_data.content.len = ev->len; + } sel_data.action = _wl_to_elm(ecore_wl2_offer_action_get(sel->sel_offer)); sel->data_func(sel->data_func_data, sel->request_obj, @@ -2893,7 +2915,7 @@ _wl_efl_sel_manager_selection_get(const Efl_Object *request, Efl_Selection_Manag for (i = 0; sm_wl_convertion[i].translates; i++) { int j = 0; - if (!(format & sm_wl_convertion[i].format)) continue; +// if (!(format & sm_wl_convertion[i].format)) continue; for (j = 0; sm_wl_convertion[i].translates[j]; j++) { @@ -2902,6 +2924,7 @@ _wl_efl_sel_manager_selection_get(const Efl_Object *request, Efl_Selection_Manag //we have found matching mimetypes sel->sel_offer = offer; sel->format = sm_wl_convertion[i].format; + sel->want_format = format; sel_debug("request type: %s", (char *)sm_wl_convertion[i].translates[j]); evas_object_event_callback_add(sel->request_obj, EVAS_CALLBACK_DEL, diff --git a/src/lib/elementary/efl_selection_manager_private.h b/src/lib/elementary/efl_selection_manager_private.h index 8ffa7c8df3..5495c9e33e 100644 --- a/src/lib/elementary/efl_selection_manager_private.h +++ b/src/lib/elementary/efl_selection_manager_private.h @@ -118,6 +118,7 @@ struct _Sel_Manager_Selection Ecore_Win32_Window *win; #endif + Efl_Selection_Format want_format; Efl_Selection_Format format; Efl_Selection_Action action; Eina_Bool active : 1; @@ -279,7 +280,7 @@ char *sm_wl_vcard[] = {"text/x-vcard", NULL}; char *sm_wl_image[] = {"image/", "text/uri-list", NULL}; Sel_Manager_Wl_Format_Translation sm_wl_convertion[] = { - {EFL_SELECTION_FORMAT_MARKUP, sm_wl_markup}, + {EFL_SELECTION_FORMAT_MARKUP | EFL_SELECTION_FORMAT_TEXT, sm_wl_markup}, {EFL_SELECTION_FORMAT_TEXT, sm_wl_text}, {EFL_SELECTION_FORMAT_HTML, sm_wl_html}, {EFL_SELECTION_FORMAT_VCARD, sm_wl_vcard}, diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index cededa5c8b..9e0c64754c 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -2314,13 +2314,15 @@ _entry_selection_none_signal_cb(void *data, elm_entry_select_none(data); } -static inline Eina_Bool -_entry_win_is_wl(Evas_Object *obj) -{ - Evas_Object *win = _entry_win_get(obj); - /* primary selection does not exist (yet) */ - return win && elm_win_wl_window_get(win); -} +// XXX: still try primary selection even if on wl in case it's +// supported +//static inline Eina_Bool +//_entry_win_is_wl(Evas_Object *obj) +//{ +// Evas_Object *win = _entry_win_get(obj); +// /* primary selection does not exist (yet) */ +// return win && elm_win_wl_window_get(win); +//} static void _entry_selection_changed_signal_cb(void *data, @@ -2334,7 +2336,9 @@ _entry_selection_changed_signal_cb(void *data, sd->have_selection = EINA_TRUE; efl_event_callback_legacy_call (data, EFL_UI_EVENT_SELECTION_CHANGED, NULL); - if (!_entry_win_is_wl(data)) + // XXX: still try primary selection even if on wl in case it's + // supported +// if (!_entry_win_is_wl(data)) _selection_store(ELM_SEL_TYPE_PRIMARY, data); _update_selection_handler(data); if (_elm_config->atspi_mode) @@ -2355,7 +2359,9 @@ _entry_selection_cleared_signal_cb(void *data, sd->have_selection = EINA_FALSE; efl_event_callback_legacy_call (data, EFL_UI_EVENT_SELECTION_CLEARED, NULL); - if (!_entry_win_is_wl(data)) + // XXX: still try primary selection even if on wl in case it's + // supported +// if (!_entry_win_is_wl(data)) { if (sd->cut_sel) { @@ -2389,7 +2395,9 @@ _entry_paste_request_signal_cb(void *data, ELM_SEL_TYPE_PRIMARY : ELM_SEL_TYPE_CLIPBOARD; if (!sd->editable) return; - if ((type == ELM_SEL_TYPE_PRIMARY) && _entry_win_is_wl(data)) return; + // XXX: still try primary selection even if on wl in case it's + // supported +// if ((type == ELM_SEL_TYPE_PRIMARY) && _entry_win_is_wl(data)) return; efl_event_callback_legacy_call (data, EFL_UI_EVENT_SELECTION_PASTE, NULL); --