From 39d0d27e531a488e893089b63113d9194c576c91 Mon Sep 17 00:00:00 2001 From: Michal Pakula vel Rutka Date: Thu, 24 May 2012 04:34:53 +0000 Subject: [PATCH] From: Michal Pakula vel Rutka Subject: [E-devel] [patch] allow copy and paste operations for non-widget evas objects I am currently implementing a clipboard for WebKit-EFL. When using elm_cnp_selection_get and set function an evas object passed has to be a widget. Currently in WebKit-EFL we are using an view which is an Evas_Object, but not a widget. Sample WebKit applications like EWebLauncher and tests applications does not use elementary so I cannot obtain parent widget for a view object and finally we cannot perform copy and paste operations. Widgets are used in elm_cnp_selection functions to obtain Ecore_X_Window. My patch leaves current way of obtaining it and adds an another in case when the standard one fails. When Evas_Object is not a widget I am trying to get an Ecore_X_Window using ecore. SVN revision: 71381 --- legacy/elementary/ChangeLog | 5 +++++ legacy/elementary/src/lib/elm_cnp.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index ea01dcbb88..3103d52ffe 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -92,3 +92,8 @@ * Map: Add elm_map_overlays_get & elm_map_overlay_visible_get functions. +2012-05-24 Michal Pakula vel Rutka + + * Add ability to use cnp helper code on non-elm widget objects by + falling back to ecore-evas to get the window id. + diff --git a/legacy/elementary/src/lib/elm_cnp.c b/legacy/elementary/src/lib/elm_cnp.c index d002606e1d..64300d27c0 100644 --- a/legacy/elementary/src/lib/elm_cnp.c +++ b/legacy/elementary/src/lib/elm_cnp.c @@ -400,6 +400,16 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection, if (top) xwin = elm_win_xwindow_get(top); else xwin = elm_win_xwindow_get(obj); + + if (!xwin) + { + Evas *evas = evas_object_evas_get(obj); + if (!evas) return EINA_FALSE; + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas); + if (!ee) return EINA_FALSE; + xwin = (Ecore_X_Window) ecore_evas_window_get(ee); + } + if ((!xwin) || (selection > ELM_SEL_TYPE_CLIPBOARD)) return EINA_FALSE; if (!_elm_cnp_init_count) _elm_cnp_init(); @@ -474,6 +484,7 @@ elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection, { #ifdef HAVE_ELEMENTARY_X Evas_Object *top; + Ecore_X_Window xwin; Cnp_Selection *sel; if (selection > ELM_SEL_TYPE_CLIPBOARD) @@ -482,11 +493,21 @@ elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection, sel = selections + selection; top = elm_widget_top_get(obj); - if (!top) return EINA_FALSE; + if (top) xwin = elm_win_xwindow_get(top); + else + { + Evas *evas = evas_object_evas_get(obj); + if (!evas) return EINA_FALSE; + Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas); + if (!ee) return EINA_FALSE; + xwin = (Ecore_X_Window) ecore_evas_window_get(ee); + } + + if (!xwin) return EINA_FALSE; sel->requestformat = format; sel->requestwidget = obj; - sel->request(elm_win_xwindow_get(top), ECORE_X_SELECTION_TARGET_TARGETS); + sel->request(xwin, ECORE_X_SELECTION_TARGET_TARGETS); sel->datacb = datacb; sel->udata = udata;