summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiep Ha <thiepha@gmail.com>2018-01-05 15:39:34 +0900
committerThiep Ha <thiepha@gmail.com>2018-01-05 15:39:34 +0900
commitbf8178f8c8a11672bd4ca25cf05114a91457f9e1 (patch)
tree18aaa68ae64c6fde17e87d4f06d10f376be17e7d
parent03faf153af6633df4181c3a4fa631543b679d8d1 (diff)
downloadefl-bf8178f8c8a11672bd4ca25cf05114a91457f9e1.tar.gz
change from efl_future to eina_future
-rw-r--r--src/lib/elementary/efl_selection.c35
-rw-r--r--src/lib/elementary/efl_selection.eo2
-rw-r--r--src/lib/elementary/efl_selection_manager.c169
-rw-r--r--src/lib/elementary/efl_selection_manager.eo2
-rw-r--r--src/lib/elementary/efl_selection_manager_private.h2
5 files changed, 56 insertions, 154 deletions
diff --git a/src/lib/elementary/efl_selection.c b/src/lib/elementary/efl_selection.c
index 9b199f2254..ef29a3dbea 100644
--- a/src/lib/elementary/efl_selection.c
+++ b/src/lib/elementary/efl_selection.c
@@ -44,7 +44,7 @@ _efl_selection_selection_get(Eo *obj, void *pd, Efl_Selection_Type type, Efl_Sel
data_func_free_cb, seat);
}
-EOLIAN static Efl_Future *
+EOLIAN static Eina_Future *
_efl_selection_selection_set(Eo *obj, void *pd, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat)
{
ERR("In");
@@ -191,23 +191,26 @@ struct _Sel_Lost_Data
Elm_Selection_Loss_Cb loss_cb;
};
-static void
-_selection_lost_cb(void *data, const Efl_Event *event)
+static Eina_Value
+_selection_lost_cb(void *data, const Eina_Value value)
{
Eina_List *l, *l2;
Sel_Lost_Data *ldata, *ldata2;
- ldata = data;
- ERR("Lost2: data: %p has lost selection; %p", ldata, event->object);
- EINA_LIST_FOREACH_SAFE(lost_cb_list, l, l2, ldata2)
- {
- if ((ldata->obj == ldata2->obj) &&
- (ldata->type == ldata2->type))
- {
- ldata2->loss_cb(ldata2->udata, ldata2->type);
- lost_cb_list = eina_list_remove(lost_cb_list, ldata2);
- }
- }
+ ldata = data;
+ ERR("selection has lost");
+ EINA_LIST_FOREACH_SAFE(lost_cb_list, l, l2, ldata2)
+ {
+ if ((ldata->obj == ldata2->obj) &&
+ (ldata->type == ldata2->type))
+ {
+ ldata2->loss_cb(ldata2->udata, ldata2->type);
+ lost_cb_list = eina_list_remove(lost_cb_list, ldata2);
+ }
+ }
+ free(ldata);
+
+ return value;
}
EAPI Eina_Bool
@@ -236,7 +239,7 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type type,
Elm_Sel_Format format, const void *selbuf, size_t buflen)
{
int seatid = 1;
- Efl_Future *f;
+ Eina_Future *f;
Sel_Lost_Data *ldata;
Eo *sel_man = _selection_manager_get(obj);
Eina_Slice data;
@@ -252,7 +255,7 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type type,
ldata->obj = obj;
ldata->type = type;
- efl_future_then(f, _selection_lost_cb, NULL, NULL, ldata);
+ eina_future_then_easy(f, _selection_lost_cb, NULL, NULL, EINA_VALUE_TYPE_UINT, ldata);
return EINA_TRUE;
}
diff --git a/src/lib/elementary/efl_selection.eo b/src/lib/elementary/efl_selection.eo
index 6b9e95a68e..ac76e2b7aa 100644
--- a/src/lib/elementary/efl_selection.eo
+++ b/src/lib/elementary/efl_selection.eo
@@ -14,7 +14,7 @@ mixin Efl.Selection {
@in data: Eina.Slice;
@in seat: uint;[[Specified seat for multiple seats case.]]
}
- return: future<void_ptr>; [[Future for tracking when the selection is lost]]
+ return: ptr(Eina.Future); [[Future for tracking when the selection is lost]]
}
selection_get {
params {
diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c
index c109fe947a..ace7fc3c02 100644
--- a/src/lib/elementary/efl_selection_manager.c
+++ b/src/lib/elementary/efl_selection_manager.c
@@ -56,21 +56,16 @@ _owner_change_check(Efl_Object *owner, Sel_Manager_Seat_Selection *seat_sel,
{
Eina_List *l, *l_next;
Sel_Manager_Selection_Lost *sel_lost;
- /*//call selection_loss callback: should we include prev owner??
- Efl_Selection_Type *lt = malloc(sizeof(Efl_Selection_Type));
- *lt = pd->loss_type;
- efl_promise_value_set(pd->promise, lt, _selection_loss_data_clear_cb);*/
EINA_LIST_FOREACH_SAFE(seat_sel->sel_lost_list, l, l_next, sel_lost)
{
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == type))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL);
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
}
- //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL);
}
}
@@ -1053,15 +1048,6 @@ _x11_selection_clear(void *data, int type EINA_UNUSED, void *event)
unsigned int i;
ERR("In");
-
- /*if (pd->promise)
- {
- Efl_Selection_Type *lt = malloc(sizeof(Efl_Selection_Type));
- *lt = pd->loss_type;
- efl_promise_value_set(pd->promise, lt, _selection_loss_data_clear_cb);
- pd->promise = NULL;
- }*/
-
seat_sel = _sel_manager_seat_selection_get(pd, 1);
if (!seat_sel)
return EINA_FALSE;
@@ -1076,13 +1062,13 @@ _x11_selection_clear(void *data, int type EINA_UNUSED, void *event)
sel = seat_sel->sel_list + i;
- //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL);
EINA_LIST_FOREACH_SAFE(seat_sel->sel_lost_list, l, l_next, sel_lost)
{
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == i))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL); //data, clear_func
+ sel_debug("resolve the promise: %p", sel_lost->promise);
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
@@ -1247,32 +1233,39 @@ _x11_text_converter(char *target, void *data, int size EINA_UNUSED, void **data_
return EINA_TRUE;
}
-static inline Efl_Future *
+static void
+_sel_manager_promise_cancel(void *data, const Eina_Promise *dead_future EINA_UNUSED)
+{
+ Sel_Manager_Selection_Lost *sel_lost = data;
+ //FIXME: remove from sel_lost_list in seat_sel
+ ERR("Free sel_lost");
+ free(sel_lost);
+}
+
+static inline Eina_Future *
_update_sel_lost_list(Efl_Object *obj, Efl_Selection_Type type,
Sel_Manager_Seat_Selection *seat_sel)
{
- Efl_Promise *p;
- Eo *loop;
-
- loop = efl_loop_get(obj);
- p = efl_add(EFL_PROMISE_CLASS, loop);
- if (!p) return NULL;
+ Eina_Promise *p;
+ Sel_Manager_Selection_Lost *sel_lost;
- Sel_Manager_Selection_Lost *sel_lost = calloc(1, sizeof(Sel_Manager_Selection_Lost));
+ sel_lost = calloc(1, sizeof(Sel_Manager_Selection_Lost));
if (!sel_lost)
- {
- //efl_promise_value_set(p, NULL);
- return NULL;
- }
+ return NULL;
sel_lost->request = obj;
sel_lost->type = type;
- sel_lost->promise = p;
seat_sel->sel_lost_list = eina_list_append(seat_sel->sel_lost_list, sel_lost);
- return efl_promise_future_get(p); //FIXME: change to eina_promise
+ p = eina_promise_new(efl_loop_future_scheduler_get(obj),
+ _sel_manager_promise_cancel, NULL);
+ eina_promise_data_set(p, sel_lost);
+ if (!p) return NULL;
+ sel_lost->promise = p;
+
+ return eina_future_new(p);
}
-static Efl_Future *
+static Eina_Future *
_x11_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd, Efl_Object *owner,
Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data,
Ecore_X_Window xwin, unsigned int seat)
@@ -2508,7 +2501,7 @@ _wl_sel_obj_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_i
//if (dragwidget == obj) dragwidget = NULL;
}
-static Efl_Future *
+static Eina_Future *
_wl_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
Efl_Object *owner, Efl_Selection_Type type,
Efl_Selection_Format format,
@@ -2546,7 +2539,7 @@ _wl_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == type))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL); //data, clear_func
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
@@ -3885,7 +3878,7 @@ _job_pb_cb(void *data)
}
}
-static Efl_Future *
+static Eina_Future *
_cocoa_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
Evas_Object *owner,
Efl_Selection_Type type,
@@ -3915,7 +3908,7 @@ _cocoa_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == type))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL); //data, clear_func
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
@@ -4099,7 +4092,7 @@ _win32_window_get(const Evas_Object *obj)
return win;
}
-static Efl_Future *
+static Eina_Future *
_win32_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
Evas_Object *owner,
Efl_Selection_Type type,
@@ -4133,7 +4126,7 @@ _win32_efl_sel_manager_selection_set(Efl_Selection_Manager_Data *pd,
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == type))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL); //data, clear_func
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
@@ -4607,17 +4600,14 @@ _drag_item_container_cmp(const void *d1, const void *d2)
return (((uintptr_t)dc->cont) - ((uintptr_t)d2));
}
//exposed APIs
-EOLIAN static Efl_Future *
+EOLIAN static Eina_Future *
_efl_selection_manager_selection_set(Eo *obj, Efl_Selection_Manager_Data *pd,
Efl_Object *owner, Efl_Selection_Type type,
Efl_Selection_Format format,
Eina_Slice data, unsigned int seat)
{
ERR("In");
- //Sel_Manager_Seat_Selection *seat_sel;
- //Sel_Manager_Selection *sel = NULL;
- //Eina_Bool same_win = EINA_FALSE;
- Efl_Promise *p = NULL;
+ Eina_Future *p = NULL;
sel_debug("owner: %p, seat: %d, type: %d, format: %d", owner, seat, type, format);
if (type > EFL_SELECTION_TYPE_CLIPBOARD)
@@ -4626,76 +4616,6 @@ _efl_selection_manager_selection_set(Eo *obj, Efl_Selection_Manager_Data *pd,
return NULL;
}
- //Sel_Manager_Selection *sel = pd->sel_list + type;
-/*#ifdef HAVE_ELEMENTARY_X
- Ecore_X_Window xwin = _x11_xwin_get(owner);
- if (xwin)
- {
- seat_sel = _x11_sel_manager_seat_selection_init(pd, seat);
- seat_sel->active_type = type;
- sel = seat_sel->sel_list + type;
- //support 1 app with multiple window, 1 selection manager
- if (sel->xwin == xwin)
- same_win = EINA_TRUE;
- }
-#endif
-#ifdef HAVE_ELEMENTARY_WL2
- Ecore_Wl2_Window *win = _wl_window_get(owner);
- if (win)
- {
- seat_sel = _wl_sel_manager_seat_selection_init(pd, seat);
- seat_sel->active_type = type;
- sel = seat_sel->sel;
- }
-#endif
-#ifdef HAVE_ELEMENTARY_COCOA
- Ecore_Cocoa_Window *win = _cocoa_window_get(owner);
- if (win)
- {
- seat_sel = _cocoa_sel_manager_seat_selection_init(pd, seat);
- seat_sel->active_type = type;
- sel = seat_sel->sel;
- }
-#endif
-#ifdef HAVE_ELEMENTARY_WIN32
- Ecore_Win32_Window *win = _win32_window_get(owner);
- if (win)
- {
- seat_sel = _win32_sel_manager_seat_selection_init(pd, seat);
- seat_sel->active_type = type;
- sel = seat_sel->sel_list + type;
- }
-#endif
-
- if (!sel) return NULL;
- */
-#if 0
- //check if owner is changed
- if ((sel->owner != NULL) &&
- (sel->owner != owner) && same_win)
- {
- Eina_List *l, *l_next;
- Sel_Manager_Selection_Lost *sel_lost;
- /*//call selection_loss callback: should we include prev owner??
- Efl_Selection_Type *lt = malloc(sizeof(Efl_Selection_Type));
- *lt = pd->loss_type;
- efl_promise_value_set(pd->promise, lt, _selection_loss_data_clear_cb);*/
- EINA_LIST_FOREACH_SAFE(seat_sel->sel_lost_list, l, l_next, sel_lost)
- {
- if ((sel_lost->request == sel->owner) &&
- (sel_lost->type == type))
- {
- efl_promise_value_set(sel_lost->promise, NULL, NULL);
- seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
- free(sel_lost);
- }
- }
- //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL);
- }
-#endif
- //_owner_change_check(owner, seat_sel, sel, type, same_win);
-
- //sel->owner = owner;
#ifdef HAVE_ELEMENTARY_X
Ecore_X_Window xwin = _x11_xwin_get(owner);
if (xwin)
@@ -4717,26 +4637,6 @@ _efl_selection_manager_selection_set(Eo *obj, Efl_Selection_Manager_Data *pd,
p = _win32_efl_sel_manager_selection_set(pd, owner, type, format, data, win, seat);
#endif
- /*Eo *loop;
-
- loop = efl_loop_get(owner);
- p = efl_add(EFL_PROMISE_CLASS, loop);
- if (!p) return NULL;
-
- Sel_Manager_Selection_Lost *sel_lost = calloc(1, sizeof(Sel_Manager_Selection_Lost));
- if (!sel_lost)
- {
- //efl_promise_value_set(p, NULL);
- return NULL;
- }
- sel_lost->request = owner;
- sel_lost->type = type;
- sel_lost->promise = p;
- seat_sel->sel_lost_list = eina_list_append(seat_sel->sel_lost_list, sel_lost);
-
- return efl_promise_future_get(p); //FIXME: change to eina_promise
- */
-
return p;
}
@@ -4827,12 +4727,11 @@ _efl_selection_manager_selection_clear(Eo *obj, Efl_Selection_Manager_Data *pd,
if ((sel_lost->request == sel->owner) &&
(sel_lost->type == type))
{
- efl_promise_value_set(sel_lost->promise, NULL, NULL); //data, clear_func
+ eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type));
seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost);
free(sel_lost);
}
}
- //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_LOST, NULL);
seat_sel->sel_list[type].owner = NULL;
}
#endif
diff --git a/src/lib/elementary/efl_selection_manager.eo b/src/lib/elementary/efl_selection_manager.eo
index 3e15590f93..169e31e58c 100644
--- a/src/lib/elementary/efl_selection_manager.eo
+++ b/src/lib/elementary/efl_selection_manager.eo
@@ -10,7 +10,7 @@ class Efl.Selection.Manager (Efl.Object, Efl.Ui.Dnd) {
@in data: Eina.Slice;
@in seat: uint @optional;[[Specified seat for multiple seats case.]]
}
- return: future<void_ptr>; [[Future for tracking when the selection is lost]]
+ return: ptr(Eina.Future); [[Future for tracking when the selection is lost]]
}
selection_get @beta {
params {
diff --git a/src/lib/elementary/efl_selection_manager_private.h b/src/lib/elementary/efl_selection_manager_private.h
index f628a1c729..474f0eb79d 100644
--- a/src/lib/elementary/efl_selection_manager_private.h
+++ b/src/lib/elementary/efl_selection_manager_private.h
@@ -137,7 +137,7 @@ typedef struct _Sel_Manager_Selection_Lost Sel_Manager_Selection_Lost;
struct _Sel_Manager_Selection_Lost
{
Efl_Object *request;
- Efl_Promise *promise;
+ Eina_Promise *promise;
Efl_Selection_Type type;
};